Propagate cancellation status of Forge event when creating Sponge event
Fixes
// ==================================== FORGE TO SPONGE START ==================================== \\
public static Event createSpongeEvent(net.minecraftforge.fml.common.eventhandler.Event forgeEvent) {
+ return propgateCancellation(createSpongeEventImpl(forgeEvent), forgeEvent);
+ }
+
+ private static Event createSpongeEventImpl(net.minecraftforge.fml.common.eventhandler.Event forgeEvent) {
if (forgeEvent instanceof BlockEvent.MultiPlaceEvent) {
return createChangeBlockEventPlace((BlockEvent.MultiPlaceEvent) forgeEvent);
}
@@ -275,6 +279,13 @@ public static Event createSpongeEvent(net.minecraftforge.fml.common.eventhandler
return null;
}
+ private static Event propgateCancellation(Event spongeEvent, net.minecraftforge.fml.common.eventhandler.Event forgeEvent) {
+ if (spongeEvent instanceof Cancellable && forgeEvent.isCancelable()) {
+ ((Cancellable) spongeEvent).setCancelled(forgeEvent.isCanceled());
+ }
+ return spongeEvent;
+ }
+
private static Event createUseItemStackEvent(LivingEntityUseItemEvent forgeEvent) {
final Entity entity = forgeEvent.getEntity();
