Posted May 30, 20169 yr I am using the code worldIn.destroyBlock(pos.add(0, 0, i), false); (i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?
May 30, 20169 yr Author I am using the code worldIn.destroyBlock(pos.add(0, 0, i), false); (i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?
May 30, 20169 yr Are you calling this ONLY (!world.isRemote) server side? 1.7.10 is no longer supported by forge, you are on your own.
May 30, 20169 yr Are you calling this ONLY (!world.isRemote) server side? 1.7.10 is no longer supported by forge, you are on your own.
May 30, 20169 yr Author Are you calling this ONLY (!world.isRemote) server side? Yes, here is my whole code for the action. public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { for (int i = 0; i < 2; i++){ if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){ worldIn.destroyBlock(pos.add(0, 0, i), false); //worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)), //worldIn, pos.add(0,0,i), playerIn, true); worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100); } } } The first block is the only one that actually gets updated and is shown breaking. The second one does not update.
May 30, 20169 yr Author Are you calling this ONLY (!world.isRemote) server side? Yes, here is my whole code for the action. public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { for (int i = 0; i < 2; i++){ if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){ worldIn.destroyBlock(pos.add(0, 0, i), false); //worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)), //worldIn, pos.add(0,0,i), playerIn, true); worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100); } } } The first block is the only one that actually gets updated and is shown breaking. The second one does not update.
May 30, 20169 yr Author Why are you calling scheduleBlockUpdate? To attempt to update the block since it is broken but doesn't update until relog. Is there another thing I could use?
May 30, 20169 yr Author Why are you calling scheduleBlockUpdate? To attempt to update the block since it is broken but doesn't update until relog. Is there another thing I could use?
May 30, 20169 yr Author Just tried it, works just fine with just destroyBlock : Mine's done on right click, if that changes anything. public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { int dir = MathHelper.floor_double((double)((playerIn.rotationYaw * 4F) / 360F) + 0.5D) & 3; if (dir == 0){ for (int i = 0; i < 2; i++){ if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE)){ worldIn.destroyBlock(pos.add(0, 0, i), false); } if (worldIn.getBlockState(pos.add(1, 0, i)).getBlock().equals(Blocks.STONE)){ worldIn.destroyBlock(pos.add(1, 0, i), false); } if (worldIn.getBlockState(pos.add(-1, 0, i)).getBlock().equals(Blocks.STONE)){ worldIn.destroyBlock(pos.add(-1, 0, i), false); } } } } return null; } Full code EDIT: Longer gif
May 30, 20169 yr Author Why in god's name are you returning null? Just changed it to return SUCCESS and it worked. Thank you so much!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.