diff options
8 files changed, 58 insertions, 31 deletions
diff --git a/build.gradle b/build.gradle index 17e04d5..7639896 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,23 @@ repositories { } maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.terraformersmc.com/releases/" } + + ivy { + url "https://github.com/HotswapProjects/HotswapAgent/releases/download%22" + patternLayout { + artifact("[revision]/[artifact]-[revision].[ext]") + } + content { + includeGroup("virtual.github.hotswapagent") + } + metadataSources { + artifact() + } + } +} + +configurations { + hotswap } dependencies { @@ -42,6 +59,20 @@ dependencies { modApi "me.shedaniel.cloth:cloth-config-fabric:11.0.99" } +loom { + runs { + removeIf { it.name != "client" } + named("client") { + property("devauth.enabled", "true") + property("fabric.log.level", "info") + vmArg("-ea") + vmArg("-XX:+AllowEnhancedClassRedefinition") + vmArg("-XX:HotswapAgent=external") + vmArg("-javaagent:${configurations.hotswap.resolve().single().absolutePath}") + } + } +} + processResources { inputs.property "version", project.version 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(); + } +} diff --git a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt index e32e50a..112bf2a 100644 --- a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt +++ b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt @@ -15,7 +15,6 @@ package com.dulkirfabric import com.dulkirfabric.config.DulkirConfig import meteordevelopment.orbit.EventBus -import meteordevelopment.orbit.EventHandler import net.fabricmc.api.ModInitializer import net.minecraft.client.MinecraftClient import org.slf4j.LoggerFactory @@ -28,7 +27,6 @@ object DulkirModFabric : ModInitializer { val EVENT_BUS = EventBus() @JvmField val mc: MinecraftClient = MinecraftClient.getInstance() - var widgetLoadTime = 0L override fun onInitialize() { logger.info("Initializing DulkirMod...") @@ -46,19 +44,6 @@ object DulkirModFabric : ModInitializer { DulkirConfig.loadConfig() } - - @EventHandler - fun onPreInit(event: WidgetInitEvent) { - if (!event.initialized) println("have not initialized widgets yet!!!!") - widgetLoadTime = System.nanoTime() - } - - @EventHandler - fun onPostInit(event: WidgetInitEvent) { - val time = System.nanoTime() - widgetLoadTime - if (event.initialized) println("widgets initialized!!!!!, took: $time ns") - } - //!this.client.options.getPerspective().isFirstPerson(), this.client.options.getPerspective().isFrontView() }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/InventoryKeyPressEvent.kt b/src/main/kotlin/com/dulkirfabric/events/InventoryKeyPressEvent.kt index f4f9e13..6ba0667 100644 --- a/src/main/kotlin/com/dulkirfabric/events/InventoryKeyPressEvent.kt +++ b/src/main/kotlin/com/dulkirfabric/events/InventoryKeyPressEvent.kt @@ -2,4 +2,5 @@ package com.dulkirfabric.events import com.dulkirfabric.events.base.CancellableEvent -data class InventoryKeyPressEvent(val keyCode: Int, val scanCode: Int, val modifiers: Int): CancellableEvent()
\ No newline at end of file +data class +InventoryKeyPressEvent(val keyCode: Int, val scanCode: Int, val modifiers: Int): CancellableEvent()
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/WorldKeyPressEvent.kt b/src/main/kotlin/com/dulkirfabric/events/WorldKeyPressEvent.kt new file mode 100644 index 0000000..2e6545b --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/WorldKeyPressEvent.kt @@ -0,0 +1,6 @@ +package com.dulkirfabric.events + +import com.dulkirfabric.events.base.Event + +data class +WorldKeyPressEvent(val key: Int, val scancode: Int, val modifiers: Int): Event()
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt index 1c1ddcd..09027ed 100644 --- a/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt +++ b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt @@ -4,7 +4,7 @@ import com.dulkirfabric.DulkirModFabric import meteordevelopment.orbit.ICancellable abstract class CancellableEvent: ICancellable { - + @JvmField var cancelled: Boolean = false override fun isCancelled(): Boolean { diff --git a/src/main/resources/dulkirmod-fabric.mixins.json b/src/main/resources/dulkirmod-fabric.mixins.json index dc450d3..808b58f 100644 --- a/src/main/resources/dulkirmod-fabric.mixins.json +++ b/src/main/resources/dulkirmod-fabric.mixins.json @@ -6,9 +6,10 @@ "defaultRequire": 1 }, "client": [ + "io.HandledScreenMixin", "render.GameMenuScreenMixin", "render.GameRendererMixin", - "io.HandledScreenMixin", + "render.KeyboardMixin", "render.ScreenMixin" ] }
\ No newline at end of file |