I am creating a mod that destroys blocks between two points, but when I use it in game, the blocks that get destroyed aren't actually disappearing until I log out and back in again. I am pretty new to modding but I believe it is caused by some disconnect between server and client. Anyone know how to fix this? I attached the whole file but here is the snippet where I am doing the destruction:
int sX = 1, sY = 1, sZ = 1;
if (((int)(posA[1].getX()) - (int)(posA[0].getX())) > 0)
sX = -1;
if (((int)(posA[1].getY()) - (int)(posA[0].getY())) > 0)
sY = -1;
if (((int)(posA[1].getZ()) - (int)(posA[0].getZ())) > 0)
sZ = -1;
for (int i = 0; i <= Math.abs((int)(posA[1].getX()) - (int)(posA[0].getX())); i++ ){
for (int j = 0; j <= Math.abs((int)(posA[1].getY()) - (int)(posA[0].getY())); j++ ){
for (int k = 0; k <= Math.abs((int)(posA[1].getZ()) - (int)(posA[0].getZ())); k++ ){
//somehow need to refresh client from server side for each block being destroyed
worldIn.destroyBlock(new BlockPos(i * sX + posA[1].getX(), j * sY + posA[1].getY(), k * sZ + posA[1].getZ()), true);
worldIn.scheduleBlockUpdate(new BlockPos(i * sX + posA[1].getX(), j * sY + posA[1].getY(), k * sZ + posA[1].getZ()), Blocks.AIR, Blocks.AIR.tickRate(worldIn), 0);
player.sendMessage(new TextComponentString("rm block " + (i * sX + posA[1].getX()) + " " + (j * sY + posA[1].getY()) + " " + (k * sZ + posA[1].getZ())));
}
}
}
ItemMagicStick.java