aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/mixin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/mixin')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java b/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
index e40c5fc..6618094 100644
--- a/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
+++ b/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
@@ -3,15 +3,16 @@ package cc.polyfrost.oneconfig.mixin;
import cc.polyfrost.oneconfig.OneConfig;
import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.*;
-import cc.polyfrost.oneconfig.libs.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Timer;
import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.fml.common.eventhandler.Event;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
@@ -49,14 +50,18 @@ public class MinecraftMixin {
EventManager.INSTANCE.post(new TickEvent(Stage.END));
}
- @ModifyExpressionValue(method = "displayGuiScreen", at = @At(value = "NEW", target = "Lnet/minecraftforge/client/event/GuiOpenEvent;<init>(Lnet/minecraft/client/gui/GuiScreen;)V", remap = false), remap = true)
- private GuiOpenEvent onGuiOpenEvent(GuiOpenEvent screen) {
- ScreenOpenEvent event = new ScreenOpenEvent(screen.gui);
- EventManager.INSTANCE.post(event);
- if (event.isCancelled) {
- screen.setCanceled(true);
+ @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true)
+ private Event onGuiOpenEvent(Event a) {
+ if (a instanceof GuiOpenEvent) {
+ GuiOpenEvent forgeEvent = (GuiOpenEvent) a;
+ ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.gui);
+ EventManager.INSTANCE.post(event);
+ if (event.isCancelled) {
+ forgeEvent.setCanceled(true);
+ }
+ return forgeEvent;
}
- return screen;
+ return a;
}
@Inject(method = "runGameLoop", at = @At(value = "FIELD", target = "Lnet/minecraft/util/Timer;renderPartialTicks:F", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER))