@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
Block.dropResources(event.getState(), (World) event.getWorld(), event.getPos());
event.getWorld().setBlock(event.getPos(), Blocks.BEDROCK.defaultBlockState(), Constants.BlockFlags.BLOCK_UPDATE);
event.setCanceled(true);
}
I ended up using the dropResources method in the Block class before placing the bedrock and canceling the event. Thanks for the pointers!
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
event.getWorld().setBlock(event.getPos(), Blocks.BEDROCK.defaultBlockState(), Constants.BlockFlags.BLOCK_UPDATE);
System.out.println(event.getPos());
}
I'm trying to replace a block with bedrock when it is broken. It's currently not working however, I've confirmed that the method is firing properly and that the position is correct with the print statement. Does anyone have experience working with the setBlock() method? I couldn't find much on it.
Forge version: 1.16.5
2 replies
Important Information
By using this site, you agree to our Terms of Use.