How to distinguish pick up events from break events?
hammertater opened this issue ยท 3 comments
Using carryon-1.16.3-1.15.1.7, attempting to pick up a block with CarryOn triggers a BreakEvent:
CarryOn/src/main/java/tschipp/carryon/common/handler/PickupHandler.java
Lines 180 to 191 in 171abb8
This is fine, but I'm not sure how to distinguish CarryOn pickup attempts from normal block break attempts. What about defining an event that extends the normal BreakEvent? Something like
class PickUpEvent extends BlockEvent.BreakEvent {
public PickUpEvent(World world, BlockPos pos, BlockState state, PlayerEntity player) {
super(world, pos, state, player);
}
}
then post the event with
BlockEvent.BreakEvent event = new PickUpEvent(world, pos, state, player);
MinecraftForge.EVENT_BUS.post(event);
so that other mods can check for this event with
public static void onBreakEvent(BlockEvent.BreakEvent event) {
if (event instanceof PickUpEvent) {
...
}
}
or maybe there's a better way of doing this.
For context - someone using my TreeChop mod and CarryOn at the same time noticed a conflict of our BreakEvent behaviors (https://www.curseforge.com/minecraft/mc-mods/treechop?comment=60). A hacky fix from my end is to disable TreeChop during RightClickBlock events (when CarryOn posts BreakEvents), but I'm worried that this might cause unexpected conflicts with other mods.