Sfoglia il codice sorgente

Fix invalid events

shedaniel 4 anni fa
parent
commit
2af34feb2a

+ 1 - 1
common/src/main/java/me/shedaniel/architectury/event/EventFactory.java

@@ -89,7 +89,7 @@ public final class EventFactory {
             @Override
             protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
                 for (T listener : listeners) {
-                    InteractionResult result = (InteractionResult) method.invoke(listener, args);
+                    InteractionResult result = (InteractionResult) Objects.requireNonNull(method.invoke(listener, args));
                     if (result != InteractionResult.PASS) {
                         return result;
                     }

+ 1 - 1
common/src/main/java/me/shedaniel/architectury/event/events/ExplosionEvent.java

@@ -30,7 +30,7 @@ import java.util.List;
 
 public interface ExplosionEvent {
     Event<Pre> PRE = EventFactory.createInteractionResult();
-    Event<Detonate> DETONATE = EventFactory.createInteractionResult();
+    Event<Detonate> DETONATE = EventFactory.createLoop();
     
     interface Pre {
         InteractionResult explode(Level world, Explosion explosion);

+ 1 - 1
common/src/main/java/me/shedaniel/architectury/event/events/GuiEvent.java

@@ -49,7 +49,7 @@ public interface GuiEvent {
      */
     Event<ScreenInitPost> INIT_POST = EventFactory.createLoop();
     Event<ScreenRenderPre> RENDER_PRE = EventFactory.createInteractionResult();
-    Event<ScreenRenderPost> RENDER_POST = EventFactory.createInteractionResult();
+    Event<ScreenRenderPost> RENDER_POST = EventFactory.createLoop();
     
     /**
      * Invoked during Minecraft#setScreen, equivalent to forge's {@code GuiOpenEvent}.

+ 2 - 2
common/src/main/java/me/shedaniel/architectury/event/events/TooltipEvent.java

@@ -44,8 +44,8 @@ public interface TooltipEvent {
      * Render forge events are only invoked on the forge side.
      */
     Event<RenderForge> RENDER_FORGE_PRE = EventFactory.createInteractionResult();
-    Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createInteractionResult();
-    Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createInteractionResult();
+    Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createLoop();
+    Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createLoop();
     
     @Environment(EnvType.CLIENT)
     interface Item {