diff options
author | inglettronald <inglettronald@gmail.com> | 2023-06-09 18:38:24 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-06-09 18:38:24 -0500 |
commit | 480f3cc93b3b77aa53225b3d65a5eb30de81bc30 (patch) | |
tree | 143020f565a3d28fac9d8f766aa8b59f032fa14c /src/main/java | |
parent | c0eb625a9b937bcb9256e98afb80d32443daa795 (diff) | |
download | DulkirMod-Fabric-480f3cc93b3b77aa53225b3d65a5eb30de81bc30.tar.gz DulkirMod-Fabric-480f3cc93b3b77aa53225b3d65a5eb30de81bc30.tar.bz2 DulkirMod-Fabric-480f3cc93b3b77aa53225b3d65a5eb30de81bc30.zip |
Some event stuff
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/dulkirfabric/mixin/render/GameMenuScreenMixin.java | 13 | ||||
-rw-r--r-- | src/main/java/com/dulkirfabric/mixin/render/KeyboardMixin.java | 16 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/render/GameMenuScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/render/GameMenuScreenMixin.java index b644595..6f09e51 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/GameMenuScreenMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/GameMenuScreenMixin.java @@ -14,7 +14,6 @@ package com.dulkirfabric.mixin.render; import com.dulkirfabric.config.DulkirConfig; -import com.dulkirfabric.events.WidgetInitEvent; import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -30,8 +29,6 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.function.Supplier; -import static com.dulkirfabric.DulkirModFabric.EVENT_BUS; - @Mixin(GameMenuScreen.class) public abstract class GameMenuScreenMixin extends ScreenMixin { @@ -48,14 +45,4 @@ public abstract class GameMenuScreenMixin extends ScreenMixin { adder.add(this.createButton(buttonText, new DulkirConfig()::getScreen)); } - @Inject(method = "initWidgets", at = @At(value = "HEAD")) - private void initWidgetPre(CallbackInfo ci) { - EVENT_BUS.post(WidgetInitEvent.get(false)); - } - - @Inject(method = "initWidgets", at = @At(value = "TAIL")) - private void initWidgetPost(CallbackInfo ci) { - EVENT_BUS.post(WidgetInitEvent.get(true)); - } - }
\ No newline at end of file diff --git a/src/main/java/com/dulkirfabric/mixin/render/KeyboardMixin.java b/src/main/java/com/dulkirfabric/mixin/render/KeyboardMixin.java new file mode 100644 index 0000000..c2c5a45 --- /dev/null +++ b/src/main/java/com/dulkirfabric/mixin/render/KeyboardMixin.java @@ -0,0 +1,16 @@ +package com.dulkirfabric.mixin.render; + +import com.dulkirfabric.events.WorldKeyPressEvent; +import net.minecraft.client.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Keyboard.class) +public class KeyboardMixin { + @Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V")) + public void onKeyBoardInWorld(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { + new WorldKeyPressEvent(key, scancode, modifiers).post(); + } +} |