Posted July 11, 20187 yr I have the following code, to check if the player destroyed a stone block while wearing a certain tool (a fire sword), and if that is the case, replace the block in question by lava. @SubscribeEvent public void breakBlock(BlockEvent.BreakEvent event) { System.out.println("Event active: breakBlock"); if (event.getPlayer().inventory.getCurrentItem().getItem() == ItemInit.SWORD_FIRE) { System.out.println("Fire Sword found"); if (event.getState().getBlock() == Blocks.STONE) { System.out.println("Stone Block found"); event.getWorld().setBlockState((new BlockPos(event.getPos().getX() + 1, event.getPos().getY(), event.getPos().getZ())), Blocks.LAVA.getDefaultState()); } } } However, there is a problem: The code will replace any block, anywhere, just fine, except for the position of the destroyed block. So in the code above, I made it adjust the X position by +1, and it works. If I however do not do that, and use the actual broken block's positon, the lava will simply not be placed. (I know that the position can be accessed/set much better, but for testing reasons I split up all the coordinates.) Edited July 11, 20187 yr by Alekseyev
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.