File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/main/java/org/embeddedt/modernfix/common/mixin/perf/forge_cap_retrieval Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .embeddedt .modernfix .common .mixin .perf .forge_cap_retrieval ;
2+
3+ import net .minecraftforge .event .AttachCapabilitiesEvent ;
4+ import net .minecraftforge .eventbus .api .Event ;
5+ import org .spongepowered .asm .mixin .Mixin ;
6+
7+ @ Mixin (AttachCapabilitiesEvent .class )
8+ public abstract class AttachCapabilitiesEventMixin extends Event {
9+ /**
10+ * @author embeddedt
11+ * @reason EventSubclassTransformer is supposed to inject an override returning a constant on the class to avoid the
12+ * {@link net.minecraftforge.eventbus.api.EventListenerHelper#isCancelable(Class)} slow path.
13+ * However, the false case is only done for direct subclasses of Event (the true case is done for
14+ * any cancelable event). This works for normal events because they must subclass Event directly, or be a subclass
15+ * of an event that does. However, AttachCapabilitiesEvent subclasses GenericEvent, which does not pass through
16+ * the EventSubclassTransformer as it comes from the EventBus library (where transformers are not run) rather than
17+ * Forge which is on the GAME layer. The transformer on AttachCapabilitiesEvent then does not add the override as
18+ * it expects it to be present on GenericEvent already.
19+ * <p>
20+ * The simplest workaround to that whole mess is to just inject the override ourselves.
21+ */
22+ @ Override
23+ public boolean isCancelable () {
24+ return false ;
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments