voila, j'ai depuispeu chercher a créé un escalier soumis à la graviter mais lorsque j'ai fait mon block, je me suis rendu compte qu'il y avais un problème avec mon code mais je n'arrive pas à le résoudre, aider moi.
Code:
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Random;
public class BlockStairsGravel extends Block{
public Block modelBlock2;
public static boolean fallInstantly = false;
protected BlockStairsGravel(int i, Block block)
{
super(i, block.blockIndexInTexture, block.blockMaterial);
modelBlock2 = block;
setHardness(block.blockHardness);
setResistance(block.blockResistance / 3F);
setStepSound(block.stepSound);
setLightOpacity(255);
}
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return super.getCollisionBoundingBoxFromPool(world, i, j, k);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 10;
}
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return super.shouldSideBeRendered(iblockaccess, i, j, k, l);
}
public void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist)
{
int l = world.getBlockMetadata(i, j, k);
if (l == 0)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
}
else if (l == 1)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
}
else if (l == 2)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
}
else if (l == 3)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
}
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void randomDisplayTick(World world, int i, int j, int k, Random random)
{
modelBlock2.randomDisplayTick(world, i, j, k, random);
}
public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
{
modelBlock2.onBlockClicked(world, i, j, k, entityplayer);
}
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
{
modelBlock2.onBlockDestroyedByPlayer(world, i, j, k, l);
}
public int getMixedBrightnessForBlock(IBlockAccess iblockaccess, int i, int j, int k)
{
return modelBlock2.getMixedBrightnessForBlock(iblockaccess, i, j, k);
}
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k)
{
return modelBlock2.getBlockBrightness(iblockaccess, i, j, k);
}
public float getExplosionResistance(Entity entity)
{
return modelBlock2.getExplosionResistance(entity);
}
public int getRenderBlockPass()
{
return modelBlock2.getRenderBlockPass();
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
return modelBlock2.getBlockTextureFromSideAndMetadata(i, 0);
}
public int getBlockTextureFromSide(int i)
{
return modelBlock2.getBlockTextureFromSideAndMetadata(i, 0);
}
public int tickRate()
{
if {
return 3;
}
else{
return modelBlock2.tickRate();}
}
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k)
{
return modelBlock2.getSelectedBoundingBoxFromPool(world, i, j, k);
}
public void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d)
{
modelBlock2.velocityToAddToEntity(world, i, j, k, entity, vec3d);
}
public boolean isCollidable()
{
return modelBlock2.isCollidable();
}
public boolean canCollideCheck(int i, boolean flag)
{
return modelBlock2.canCollideCheck(i, flag);
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
return modelBlock2.canPlaceBlockAt(world, i, j, k);
}
public void onBlockAdded(World world, int i, int j, int k)
{
onNeighborBlockChange(world, i, j, k, 0);
modelBlock2.onBlockAdded(world, i, j, k);
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
}
public void onBlockRemoval(World world, int i, int j, int k)
{
modelBlock2.onBlockRemoval(world, i, j, k);
}
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
modelBlock2.onEntityWalking(world, i, j, k, entity);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
modelBlock2.updateTick(world, i, j, k, random);
tryToFall(world, i, j, k);
}
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
return modelBlock2.blockActivated(world, i, j, k, entityplayer);
}
public void onBlockDestroyedByExplosion(World world, int i, int j, int k)
{
modelBlock2.onBlockDestroyedByExplosion(world, i, j, k);
}
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
{
int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(i, j, k, 2);
}
if (l == 1)
{
world.setBlockMetadataWithNotify(i, j, k, 1);
}
if (l == 2)
{
world.setBlockMetadataWithNotify(i, j, k, 3);
}
if (l == 3)
{
world.setBlockMetadataWithNotify(i, j, k, 0);
}
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
}
private void tryToFall(World world, int i, int j, int k)
{
int l = i;
int i1 = j;
int j1 = k;
if (canFallBelow(world, l, i1 - 1, j1) && i1 >= 0)
{
byte byte0 = 32;
if (fallInstantly || !world.checkChunksExist(i - byte0, j - byte0, k - byte0, i + byte0, j + byte0, k + byte0))
{
world.setBlockWithNotify(i, j, k, 0);
for (; canFallBelow(world, i, j - 1, k) && j > 0; j--) { }
if (j > 0)
{
world.setBlockWithNotify(i, j, k, blockID);
}
}
else if (!world.multiplayerWorld)
{
EntityFallingSand entityfallingsand = new EntityFallingSand(world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, blockID);
world.spawnEntityInWorld(entityfallingsand);
}
}
}
public static boolean canFallBelow(World world, int i, int j, int k)
{
int l = world.getBlockId(i, j, k);
if (l == 0)
{
return true;
}
if (l == Block.fire.blockID)
{
return true;
}
Material material = Block.blocksList[l].blockMaterial;
if (material == Material.water)
{
return true;
}
return material == Material.lava;
}
public int idDropped(int i, Random random)
{
return this.blockID;
}
}