I'm trying to make a simple block that just makes a pillar of itself when used. Everything is working when I run it, however problems arise when I save the world and reload it. All of the new blocks placed by the block disappear when the world is reloaded. I haven't been able to find much information on this and I'm relatively new to Minecraft modding and Java my background is in C/C++ for research and robotics.
@Override
public boolean onBlockActivated(
World world,
BlockPos pos,
IBlockState state,
EntityPlayer player,
EnumHand hand,
@Nullable ItemStack heldItem,
EnumFacing side,
float hitX,
float hitY,
float hitZ) {
if (!world.isRemote){
return false;
}
Random rand = new Random();
IBlockState block = world.getBlockState(pos);
for(int i = 0; i < 7; i++){
world.setBlockState(pos.add(0, i, 0), block);
}
for(int k = 0; k < 20; k++){
int x, z;
x= rand.nextInt(16)-8;
z= rand.nextInt(16)-8;
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX()+x, pos.getY(), pos.getZ()+z, false);
world.addWeatherEffect(lightning);
}
return true;
}
I'm working by deconstructing examples but I seem to be missing something. Any advice is appreciated, thanks in advance.