I don't understand why this isn't working. No matter what I do, the blocks always fall strait down.
public void execute(Chunk chunk, int topIn){
World world = chunk.getWorld();
if(world.isRemote) return;
Random rand = new Random();
int x = (chunk.getPos().getXEnd() - chunk.getPos().getXStart())/2 + chunk.getPos().getXStart();
int z = (chunk.getPos().getZEnd() - chunk.getPos().getZStart())/2 + chunk.getPos().getZStart();
BlockPos top = new BlockPos(x,topIn,z);
for(MutableBlockPos pos : BlockPos.getAllInBoxMutable(top.add(-3, -3, -3), top.add(3, 3, 3))){
EntityFallingBlock entity = new EntityFallingBlock(world, pos.getX(), pos.getY()+2, pos.getZ(), Blocks.STONE.getDefaultState());
if(rand.nextInt(100)+1 < 20){
world.spawnEntity(entity);
entity.fallTime = 1;
entity.addVelocity(range(rand,10,20), range(rand,10,20), range(rand,10,20));
}
}
}
private int range(Random rand, int min, int max){
return rand.nextInt((max - min) + 1) + min;
}
Any help is appreciated, Thanks!