From 8792f7ae92ac6a1cd5b44a5fb9d3bd07498385d4 Mon Sep 17 00:00:00 2001 From: odtheking Date: Sat, 27 Apr 2024 16:47:37 +0300 Subject: [PATCH] Cleaned up GuiEvents --- .../odin/mixin/mixins/MixinGuiContainer.java | 36 ++++++++-------- .../me/odin/mixin/mixins/MixinGuiScreen.java | 9 +++- .../me/odin/mixin/mixins/MixinRenderItem.java | 4 +- .../mixin/mixins/MixinGuiContainer.java | 17 +++----- .../mixin/mixins/MixinGuiScreen.java | 9 +++- .../mixin/mixins/MixinRenderItem.java | 4 +- .../src/main/kotlin/me/odinclient/ModCore.kt | 8 +++- .../features/impl/floor7/p3/AutoTerms.kt | 4 +- .../features/impl/render/EtherWarpHelper.kt | 14 ++++-- .../features/impl/skyblock/AutoExperiments.kt | 4 +- .../me/odinmain/events/EventDispatcher.kt | 7 +-- .../me/odinmain/events/impl/GuiEvents.kt | 43 +++++++++++-------- .../odinmain/events/impl/RenderChestEvent.kt | 1 - ...erminalOpenedEvent.kt => TerminalEvent.kt} | 0 .../features/impl/dungeon/BlessingDisplay.kt | 8 +++- .../features/impl/dungeon/LeapMenu.kt | 15 +++---- .../impl/dungeon/puzzlesolvers/TPMaze.kt | 4 +- .../features/impl/floor7/p3/MelodyMessage.kt | 7 ++- .../features/impl/floor7/p3/TerminalSolver.kt | 15 ++++--- .../impl/floor7/p3/termsim/CorrectPanes.kt | 4 +- .../impl/floor7/p3/termsim/InOrder.kt | 4 +- .../impl/floor7/p3/termsim/SameColor.kt | 4 +- .../impl/floor7/p3/termsim/SelectAll.kt | 8 ++-- .../impl/floor7/p3/termsim/StartsWith.kt | 4 +- .../impl/floor7/p3/termsim/TermSimGui.kt | 12 ++++-- .../features/impl/kuudra/RemovePerks.kt | 7 ++- .../features/impl/render/BlockOverlay.kt | 1 - .../features/impl/skyblock/CopyChat.kt | 4 +- .../features/impl/skyblock/HidePlayers.kt | 3 -- .../features/impl/skyblock/PartyNote.kt | 1 - .../main/kotlin/me/odinmain/utils/Utils.kt | 4 ++ 31 files changed, 146 insertions(+), 119 deletions(-) rename odinmain/src/main/kotlin/me/odinmain/events/impl/{TerminalOpenedEvent.kt => TerminalEvent.kt} (100%) diff --git a/odin/src/main/java/me/odin/mixin/mixins/MixinGuiContainer.java b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiContainer.java index c88ea1795..011ac8ee5 100644 --- a/odin/src/main/java/me/odin/mixin/mixins/MixinGuiContainer.java +++ b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiContainer.java @@ -1,10 +1,9 @@ package me.odin.mixin.mixins; -import me.odinmain.events.impl.*; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(value = GuiContainer.class, priority = 1) -public class MixinGuiContainer { +public abstract class MixinGuiContainer { @Unique private final GuiContainer gui = (GuiContainer) (Object) this; @@ -30,38 +29,39 @@ public class MixinGuiContainer { @Shadow protected int guiTop; + @Shadow private Slot theSlot; + + @Shadow protected abstract boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY); + @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) private void onDrawSlot(Slot slotIn, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawSlotEvent(inventorySlots, gui, slotIn, slotIn.xDisplayPosition, slotIn.yDisplayPosition))) - ci.cancel(); - } - - @Inject(method = "drawItemStack", at = @At("HEAD"), cancellable = true) - private void onDrawItemStack(ItemStack stack, int x, int y, String altText, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawItemStackEvent(inventorySlots, gui, stack, x, y))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.DrawSlotEvent(inventorySlots, gui, slotIn, slotIn.xDisplayPosition, slotIn.yDisplayPosition))) ci.cancel(); } @Inject(method = "drawScreen", at = @At(value = "HEAD"), cancellable = true) private void startDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawGuiContainerScreenEvent(gui.inventorySlots, gui, this.xSize, this.ySize, guiLeft, guiTop))) + GuiEvent.DrawGuiContainerScreenEvent event = new GuiEvent.DrawGuiContainerScreenEvent(gui.inventorySlots, gui, this.xSize, this.ySize, guiLeft, guiTop); + if (MinecraftForge.EVENT_BUS.post(event)) { ci.cancel(); - } - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void onMouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new GuiClickEvent(gui.inventorySlots, gui, mouseX, mouseY, mouseButton))) - ci.cancel(); + this.theSlot = null; + for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) { + Slot slot = this.inventorySlots.inventorySlots.get(i); + if (!this.isMouseOverSlot(slot, mouseX, mouseY) || !slot.canBeHovered()) continue; + this.theSlot = slot; + } + } } @Inject(method = "keyTyped", at = @At("HEAD"), cancellable = true) private void keyTyped(char typedChar, int keyCode, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new GuiKeyPressEvent(gui.inventorySlots, gui, keyCode))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiKeyPressEvent(gui.inventorySlots, gui, keyCode))) ci.cancel(); } @Inject(method = "onGuiClosed", at = @At("HEAD")) private void onGuiClosed(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new GuiClosedEvent(gui)); + MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiClosedEvent(gui)); } } \ No newline at end of file diff --git a/odin/src/main/java/me/odin/mixin/mixins/MixinGuiScreen.java b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiScreen.java index 4a42c294a..b552b2b44 100644 --- a/odin/src/main/java/me/odin/mixin/mixins/MixinGuiScreen.java +++ b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiScreen.java @@ -1,10 +1,11 @@ package me.odin.mixin.mixins; -import me.odinmain.events.impl.PreGuiClickEvent; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.MinecraftForge; import org.lwjgl.input.Mouse; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -12,12 +13,16 @@ @Mixin(GuiScreen.class) public class MixinGuiScreen { + @Unique + private final GuiScreen odin$gui = (GuiScreen) (Object) this; + @Inject(method = "handleMouseInput", at = @At(value = "INVOKE", target = "net/minecraft/client/gui/GuiScreen.mouseClicked(III)V"), cancellable = true) private void onMouseInput(CallbackInfo ci){ int k = Mouse.getEventButton(); if (Mouse.getEventButtonState()) { - if (MinecraftForge.EVENT_BUS.post(new PreGuiClickEvent(k))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiMouseClickEvent(odin$gui, k, Mouse.getEventX(), Mouse.getEventY()))) { ci.cancel(); + } } } } diff --git a/odin/src/main/java/me/odin/mixin/mixins/MixinRenderItem.java b/odin/src/main/java/me/odin/mixin/mixins/MixinRenderItem.java index d154bdfcf..339652c73 100644 --- a/odin/src/main/java/me/odin/mixin/mixins/MixinRenderItem.java +++ b/odin/src/main/java/me/odin/mixin/mixins/MixinRenderItem.java @@ -1,6 +1,6 @@ package me.odin.mixin.mixins; -import me.odinmain.events.impl.DrawSlotOverlayEvent; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; @@ -15,7 +15,7 @@ public abstract class MixinRenderItem { @Inject(method = "renderItemOverlayIntoGUI", at = @At("HEAD"), cancellable = true) private void renderItemOverlayPost(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawSlotOverlayEvent(stack, xPosition, yPosition, text))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.DrawSlotOverlayEvent(stack, xPosition, yPosition, text))) ci.cancel(); } } diff --git a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiContainer.java b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiContainer.java index 6c2f6056c..196a91227 100644 --- a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiContainer.java +++ b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiContainer.java @@ -1,6 +1,6 @@ package me.odinclient.mixin.mixins; -import me.odinmain.events.impl.*; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; @@ -35,13 +35,13 @@ public abstract class MixinGuiContainer { @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) private void onDrawSlot(Slot slotIn, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawSlotEvent(inventorySlots, gui, slotIn, slotIn.xDisplayPosition, slotIn.yDisplayPosition))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.DrawSlotEvent(inventorySlots, gui, slotIn, slotIn.xDisplayPosition, slotIn.yDisplayPosition))) ci.cancel(); } @Inject(method = "drawScreen", at = @At(value = "HEAD"), cancellable = true) private void startDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { - DrawGuiContainerScreenEvent event = new DrawGuiContainerScreenEvent(gui.inventorySlots, gui, this.xSize, this.ySize, guiLeft, guiTop); + GuiEvent.DrawGuiContainerScreenEvent event = new GuiEvent.DrawGuiContainerScreenEvent(gui.inventorySlots, gui, this.xSize, this.ySize, guiLeft, guiTop); if (MinecraftForge.EVENT_BUS.post(event)) { ci.cancel(); @@ -54,21 +54,14 @@ private void startDrawScreen(int mouseX, int mouseY, float partialTicks, Callbac } } - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void onMouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new GuiClickEvent(gui.inventorySlots, gui, mouseX, mouseY, mouseButton))) - ci.cancel(); - } - @Inject(method = "keyTyped", at = @At("HEAD"), cancellable = true) private void keyTyped(char typedChar, int keyCode, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new GuiKeyPressEvent(gui.inventorySlots, gui, keyCode))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiKeyPressEvent(gui.inventorySlots, gui, keyCode))) ci.cancel(); } @Inject(method = "onGuiClosed", at = @At("HEAD")) private void onGuiClosed(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new GuiClosedEvent(gui)); + MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiClosedEvent(gui)); } - } \ No newline at end of file diff --git a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiScreen.java b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiScreen.java index af30286b1..f4e9dc3a4 100644 --- a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiScreen.java +++ b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiScreen.java @@ -1,10 +1,11 @@ package me.odinclient.mixin.mixins; -import me.odinmain.events.impl.PreGuiClickEvent; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.MinecraftForge; import org.lwjgl.input.Mouse; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -12,12 +13,16 @@ @Mixin(GuiScreen.class) public class MixinGuiScreen { + @Unique + private final GuiScreen odin$gui = (GuiScreen) (Object) this; + @Inject(method = "handleMouseInput", at = @At(value = "INVOKE", target = "net/minecraft/client/gui/GuiScreen.mouseClicked(III)V"), cancellable = true) private void onMouseInput(CallbackInfo ci){ int k = Mouse.getEventButton(); if (Mouse.getEventButtonState()) { - if (MinecraftForge.EVENT_BUS.post(new PreGuiClickEvent(k))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.GuiMouseClickEvent(odin$gui, k, Mouse.getEventX(), Mouse.getEventY()))) { ci.cancel(); + } } } } diff --git a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinRenderItem.java b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinRenderItem.java index d584a45b9..5ecd259a0 100644 --- a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinRenderItem.java +++ b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinRenderItem.java @@ -1,6 +1,6 @@ package me.odinclient.mixin.mixins; -import me.odinmain.events.impl.DrawSlotOverlayEvent; +import me.odinmain.events.impl.GuiEvent; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; @@ -15,7 +15,7 @@ public abstract class MixinRenderItem { @Inject(method = "renderItemOverlayIntoGUI", at = @At("HEAD"), cancellable = true) private void renderItemOverlayPost(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { - if (MinecraftForge.EVENT_BUS.post(new DrawSlotOverlayEvent(stack, xPosition, yPosition, text))) + if (MinecraftForge.EVENT_BUS.post(new GuiEvent.DrawSlotOverlayEvent(stack, xPosition, yPosition, text))) ci.cancel(); } } diff --git a/odinclient/src/main/kotlin/me/odinclient/ModCore.kt b/odinclient/src/main/kotlin/me/odinclient/ModCore.kt index 0cea9e18a..8dd002630 100644 --- a/odinclient/src/main/kotlin/me/odinclient/ModCore.kt +++ b/odinclient/src/main/kotlin/me/odinclient/ModCore.kt @@ -5,7 +5,9 @@ import com.google.gson.reflect.TypeToken import me.odinclient.commands.impl.autoSellCommand import me.odinclient.features.impl.dungeon.* import me.odinclient.features.impl.dungeon.AutoSell.sellList -import me.odinclient.features.impl.floor7.* +import me.odinclient.features.impl.floor7.DioriteFucker +import me.odinclient.features.impl.floor7.FreezeGame +import me.odinclient.features.impl.floor7.RelicAura import me.odinclient.features.impl.floor7.p3.* import me.odinclient.features.impl.render.* import me.odinclient.features.impl.skyblock.* @@ -20,7 +22,9 @@ import me.odinmain.utils.render.RenderUtils import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventHandler -import net.minecraftforge.fml.common.event.* +import net.minecraftforge.fml.common.event.FMLInitializationEvent +import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/floor7/p3/AutoTerms.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/floor7/p3/AutoTerms.kt index 598ce5c07..3f4fc6072 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/floor7/p3/AutoTerms.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/floor7/p3/AutoTerms.kt @@ -1,7 +1,7 @@ package me.odinclient.features.impl.floor7.p3 import me.odinclient.utils.skyblock.PlayerUtils -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.impl.floor7.p3.TerminalSolver @@ -30,7 +30,7 @@ object AutoTerms : Module( @SubscribeEvent - fun onGuiOpen(event: GuiLoadedEvent) { + fun onGuiOpen(event: GuiEvent.GuiLoadedEvent) { clickedThisWindow = false } diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt index 7bfbad665..0f6f807d4 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt @@ -8,17 +8,25 @@ import me.odinmain.features.Module import me.odinmain.features.impl.dungeon.DungeonWaypoints.toBlockPos import me.odinmain.features.impl.dungeon.DungeonWaypoints.toVec3 import me.odinmain.features.settings.Setting.Companion.withDependency -import me.odinmain.features.settings.impl.* +import me.odinmain.features.settings.impl.BooleanSetting +import me.odinmain.features.settings.impl.ColorSetting +import me.odinmain.features.settings.impl.DualSetting +import me.odinmain.features.settings.impl.NumberSetting import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha -import me.odinmain.utils.* +import me.odinmain.utils.PositionLook import me.odinmain.utils.clock.Clock +import me.odinmain.utils.equal +import me.odinmain.utils.etherwarpRotateTo import me.odinmain.utils.render.Color import me.odinmain.utils.render.RenderUtils.renderVec import me.odinmain.utils.render.Renderer -import me.odinmain.utils.skyblock.* import me.odinmain.utils.skyblock.EtherWarpHelper import me.odinmain.utils.skyblock.EtherWarpHelper.etherPos import me.odinmain.utils.skyblock.dungeon.DungeonUtils +import me.odinmain.utils.skyblock.extraAttributes +import me.odinmain.utils.skyblock.getBlockAt +import me.odinmain.utils.skyblock.holdingEtherWarp +import me.odinmain.utils.smoothRotateTo import net.minecraft.util.MathHelper import net.minecraft.util.Vec3 import net.minecraftforge.client.event.RenderWorldLastEvent diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoExperiments.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoExperiments.kt index a371b4d67..b42d29645 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoExperiments.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoExperiments.kt @@ -1,6 +1,6 @@ package me.odinclient.features.impl.skyblock -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.settings.impl.BooleanSetting @@ -43,7 +43,7 @@ object AutoExperiments : Module( } @SubscribeEvent - fun onGuiOpen(event: GuiLoadedEvent) { + fun onGuiOpen(event: GuiEvent.GuiLoadedEvent) { reset() if (LocationUtils.currentArea != Island.PrivateIsland) return val chestName = event.name diff --git a/odinmain/src/main/kotlin/me/odinmain/events/EventDispatcher.kt b/odinmain/src/main/kotlin/me/odinmain/events/EventDispatcher.kt index 300547757..2d167f5b1 100644 --- a/odinmain/src/main/kotlin/me/odinmain/events/EventDispatcher.kt +++ b/odinmain/src/main/kotlin/me/odinmain/events/EventDispatcher.kt @@ -15,15 +15,10 @@ import net.minecraft.network.play.server.S02PacketChat import net.minecraft.network.play.server.S32PacketConfirmTransaction import net.minecraftforge.client.event.GuiOpenEvent import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.fml.common.eventhandler.Event import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object EventDispatcher { - /** Used to make code simpler. */ - fun post(event: Event) = MinecraftForge.EVENT_BUS.post(event) - /** * Dispatches [ChatPacketEvent] and [RealServerTick]. */ @@ -62,7 +57,7 @@ object EventDispatcher { val deferred = waitUntilLastItem(container) try { deferred.await() } catch (e: Exception) { return@launch } // Wait until the last item in the chest isn't null - GuiLoadedEvent(chestName, container).postAndCatch() + GuiEvent.GuiLoadedEvent(chestName, container).postAndCatch() } } diff --git a/odinmain/src/main/kotlin/me/odinmain/events/impl/GuiEvents.kt b/odinmain/src/main/kotlin/me/odinmain/events/impl/GuiEvents.kt index b24eed741..762b3ba20 100644 --- a/odinmain/src/main/kotlin/me/odinmain/events/impl/GuiEvents.kt +++ b/odinmain/src/main/kotlin/me/odinmain/events/impl/GuiEvents.kt @@ -1,34 +1,41 @@ package me.odinmain.events.impl +import net.minecraft.client.gui.GuiScreen import net.minecraft.client.gui.inventory.GuiContainer -import net.minecraft.inventory.* +import net.minecraft.inventory.Container +import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.Cancelable import net.minecraftforge.fml.common.eventhandler.Event -@Cancelable -class DrawGuiContainerScreenEvent(val container: Container, val gui: GuiContainer, val xSize: Int, val ySize: Int, val guiLeft: Int, val guiTop: Int) : Event() -class GuiLoadedEvent(val name: String, val gui: ContainerChest) : Event() +abstract class GuiEvent : Event() { -@Cancelable -class GuiClickEvent(val container: Container, val gui: GuiContainer, val x: Int, val y: Int, val button: Int) : Event() + data class GuiLoadedEvent(val name: String, val gui: ContainerChest) : GuiEvent() + + @Cancelable + data class DrawGuiContainerScreenEvent(val container: Container, val gui: GuiContainer, val xSize: Int, val ySize: Int, val guiLeft: Int, val guiTop: Int) : GuiEvent() + + @Cancelable + class DrawSlotEvent(val container: Container, val gui: GuiContainer, var slot: Slot, val x: Int, val y: Int) : GuiEvent() + + @Cancelable + class DrawSlotOverlayEvent(val stack: ItemStack?, val x: Int?, val y: Int?, val text: String?) : GuiEvent() + + @Cancelable + data class GuiMouseClickEvent(val gui: GuiScreen, val button: Int, val x: Int, val y: Int) : GuiEvent() + + @Cancelable + class GuiKeyPressEvent(val container: Container, val gui: GuiContainer, val keyCode: Int) : Event() + + + class GuiClosedEvent(val gui: GuiContainer) : GuiEvent() +} -@Cancelable -class PreGuiClickEvent(val button: Int) : Event() -@Cancelable -class GuiKeyPressEvent(val container: Container, val gui: GuiContainer, val keyCode: Int) : Event() -@Cancelable -class GuiClosedEvent(val gui: GuiContainer) : Event() -@Cancelable -class DrawSlotOverlayEvent(val stack: ItemStack?, val x: Int?, val y: Int?, val text: String?) : Event() -@Cancelable -class DrawSlotEvent(val container: Container, val gui: GuiContainer, var slot: Slot, val x: Int, val y: Int) : Event() -@Cancelable -class DrawItemStackEvent(val container: Container, val gui: GuiContainer, val stack: ItemStack, val x: Int, val y: Int) : Event() diff --git a/odinmain/src/main/kotlin/me/odinmain/events/impl/RenderChestEvent.kt b/odinmain/src/main/kotlin/me/odinmain/events/impl/RenderChestEvent.kt index c4bb2a8e3..4c602e45b 100644 --- a/odinmain/src/main/kotlin/me/odinmain/events/impl/RenderChestEvent.kt +++ b/odinmain/src/main/kotlin/me/odinmain/events/impl/RenderChestEvent.kt @@ -8,5 +8,4 @@ open class RenderChestEvent(var chest: TileEntityChest, var x: Double, var y: Do class Pre(tileEntity: TileEntityChest, x: Double, y: Double, z: Double, partialTicks: Float) : RenderChestEvent(tileEntity, x, y, z, partialTicks) class Post(tileEntity: TileEntityChest, x: Double, y: Double, z: Double, partialTicks: Float) : RenderChestEvent(tileEntity, x, y, z, partialTicks) - } \ No newline at end of file diff --git a/odinmain/src/main/kotlin/me/odinmain/events/impl/TerminalOpenedEvent.kt b/odinmain/src/main/kotlin/me/odinmain/events/impl/TerminalEvent.kt similarity index 100% rename from odinmain/src/main/kotlin/me/odinmain/events/impl/TerminalOpenedEvent.kt rename to odinmain/src/main/kotlin/me/odinmain/events/impl/TerminalEvent.kt diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/BlessingDisplay.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/BlessingDisplay.kt index 4a3177572..e28575ab8 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/BlessingDisplay.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/BlessingDisplay.kt @@ -4,10 +4,14 @@ import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.settings.AlwaysActive import me.odinmain.features.settings.Setting.Companion.withDependency -import me.odinmain.features.settings.impl.* +import me.odinmain.features.settings.impl.BooleanSetting +import me.odinmain.features.settings.impl.ColorSetting +import me.odinmain.features.settings.impl.HudSetting import me.odinmain.ui.hud.HudElement import me.odinmain.utils.noControlCodes -import me.odinmain.utils.render.* +import me.odinmain.utils.render.Color +import me.odinmain.utils.render.getMCTextWidth +import me.odinmain.utils.render.mcText import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter import kotlin.math.max diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/LeapMenu.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/LeapMenu.kt index 26d07fe69..f4c4b775f 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/LeapMenu.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/LeapMenu.kt @@ -1,8 +1,6 @@ package me.odinmain.features.impl.dungeon -import me.odinmain.events.impl.DrawGuiContainerScreenEvent -import me.odinmain.events.impl.GuiClickEvent -import me.odinmain.events.impl.GuiKeyPressEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.impl.dungeon.LeapHelper.getPlayer @@ -54,7 +52,7 @@ object LeapMenu : Module( private val EMPTY = DungeonUtils.DungeonPlayer("Empty", DungeonUtils.Classes.Archer, ResourceLocation("textures/entity/steve.png")) @SubscribeEvent - fun onDrawScreen(event: DrawGuiContainerScreenEvent) { + fun onDrawScreen(event: GuiEvent.DrawGuiContainerScreenEvent) { val chest = (event.gui as? GuiChest)?.inventorySlots ?: return if (chest !is ContainerChest || chest.name != "Spirit Leap" || leapTeammates.isEmpty() || leapTeammates.all { it == EMPTY }) return hoveredQuadrant = getQuadrant() @@ -105,8 +103,9 @@ object LeapMenu : Module( } @SubscribeEvent - fun mouseClicked(event: GuiClickEvent) { - if (event.gui !is GuiChest || event.container !is ContainerChest || event.container.name != "Spirit Leap" || leapTeammates.isEmpty()) return + fun mouseClicked(event: GuiEvent.GuiMouseClickEvent) { + val gui = event.gui as? GuiChest ?: return + if (event.gui.inventorySlots !is ContainerChest || gui.inventorySlots.name != "Spirit Leap" || leapTeammates.isEmpty()) return val quadrant = getQuadrant() if ((type.equalsOneOf(1,2,3)) && leapTeammates.size < quadrant) return @@ -115,13 +114,13 @@ object LeapMenu : Module( if (playerToLeap == EMPTY) return if (playerToLeap.isDead) return modMessage("This player is dead, can't leap.") - leapTo(playerToLeap.name, event.container) + leapTo(playerToLeap.name, gui.inventorySlots as? ContainerChest ?: return) event.isCanceled = true } @SubscribeEvent - fun keyTyped(event: GuiKeyPressEvent) { + fun keyTyped(event: GuiEvent.GuiKeyPressEvent) { if ( event.container !is ContainerChest || event.container.name != "Spirit Leap" || diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMaze.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMaze.kt index 253628ef7..8aced70a0 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMaze.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMaze.kt @@ -13,7 +13,9 @@ import me.odinmain.utils.skyblock.dungeon.DungeonUtils import me.odinmain.utils.toAABB import net.minecraft.init.Blocks import net.minecraft.network.play.server.S08PacketPlayerPosLook -import net.minecraft.util.* +import net.minecraft.util.AxisAlignedBB +import net.minecraft.util.BlockPos +import net.minecraft.util.Vec3 import java.util.concurrent.CopyOnWriteArraySet object TPMaze { diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/MelodyMessage.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/MelodyMessage.kt index 7a1430040..91a9ce707 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/MelodyMessage.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/MelodyMessage.kt @@ -1,7 +1,6 @@ package me.odinmain.features.impl.floor7.p3 -import me.odinmain.events.impl.GuiClosedEvent -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.settings.Setting.Companion.withDependency @@ -26,7 +25,7 @@ object MelodyMessage : Module( private var claySlots = hashMapOf(25 to "Melody terminal is at 25%", 34 to "Melody terminal is at 50%", 43 to "Melody terminal is at 75%",) @SubscribeEvent - fun onGuiLoad(event: GuiLoadedEvent) { + fun onGuiLoad(event: GuiEvent.GuiLoadedEvent) { if (!DungeonUtils.inDungeons || saidMelody || !event.name.startsWith("Click the button on time!")) return if (sendMelodyMessage) partyMessage(melodyMessage) @@ -35,7 +34,7 @@ object MelodyMessage : Module( } @SubscribeEvent - fun onGuiClose(event: GuiClosedEvent) { + fun onGuiClose(event: GuiEvent.GuiClosedEvent) { saidMelody = false } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt index e59e6d260..df795a581 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt @@ -1,6 +1,9 @@ package me.odinmain.features.impl.floor7.p3 -import me.odinmain.events.impl.* +import me.odinmain.events.impl.ChatPacketEvent +import me.odinmain.events.impl.GuiEvent +import me.odinmain.events.impl.TerminalClosedEvent +import me.odinmain.events.impl.TerminalOpenedEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.impl.floor7.p3.termGUI.CustomTermGui @@ -76,7 +79,7 @@ object TerminalSolver : Module( var solution = listOf() @SubscribeEvent - fun onGuiLoad(event: GuiLoadedEvent) { + fun onGuiLoad(event: GuiEvent.GuiLoadedEvent) { val newTerm = TerminalTypes.entries.find { event.name.startsWith(it.guiName) } ?: TerminalTypes.NONE if (newTerm != currentTerm) { currentTerm = newTerm @@ -104,7 +107,7 @@ object TerminalSolver : Module( } @SubscribeEvent - fun onGuiRender(event: DrawGuiContainerScreenEvent) { + fun onGuiRender(event: GuiEvent.DrawGuiContainerScreenEvent) { if (currentTerm == TerminalTypes.NONE || !enabled || !renderType.equalsOneOf(0,3) || event.container !is ContainerChest) return if (renderType == 3) { CustomTermGui.render() @@ -129,7 +132,7 @@ object TerminalSolver : Module( } @SubscribeEvent - fun drawSlot(event: DrawSlotEvent) { + fun drawSlot(event: GuiEvent.DrawSlotEvent) { if ((removeWrong || renderType == 0) && enabled && getShouldBlockWrong() && event.slot.slotIndex <= event.container.inventorySlots.size - 37 && event.slot.slotIndex !in solution) event.isCanceled = true if (event.slot.slotIndex !in solution || event.slot.slotIndex > event.container.inventorySlots.size - 37 || event.slot.inventory == mc.thePlayer.inventory || !enabled || renderType == 3) return val stack = event.slot.stack?.item?.registryName ?: return @@ -182,14 +185,14 @@ object TerminalSolver : Module( } @SubscribeEvent - fun guiClick(event: PreGuiClickEvent) { + fun guiClick(event: GuiEvent.GuiMouseClickEvent) { if (renderType != 3 || currentTerm == TerminalTypes.NONE || !enabled) return CustomTermGui.mouseClicked(MouseUtils.mouseX.toInt(), MouseUtils.mouseY.toInt(), event.button) event.isCanceled = true } @SubscribeEvent - fun itemStack(event: DrawSlotOverlayEvent) { + fun itemStack(event: GuiEvent.DrawSlotOverlayEvent) { val stack = event.stack?.item?.registryName ?: return if (currentTerm != TerminalTypes.ORDER || !enabled || stack != "minecraft:stained_glass_pane") return event.isCanceled = true diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/CorrectPanes.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/CorrectPanes.kt index 29b483c92..fe09723ae 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/CorrectPanes.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/CorrectPanes.kt @@ -1,6 +1,6 @@ package me.odinmain.features.impl.floor7.p3.termsim -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.impl.floor7.p3.TerminalTimes import me.odinmain.utils.postAndCatch import net.minecraft.inventory.ContainerChest @@ -29,7 +29,7 @@ object CorrectPanes : TermSimGui( override fun slotClick(slot: Slot, button: Int) { if (slot.stack?.metadata == 14) slot.putStack(greenPane) else slot.putStack(redPane) mc.thePlayer.playSound("random.orb", 1f, 1f) - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() if (inventorySlots.inventorySlots.subList(0, 45).none { it?.stack?.metadata == 14 }) { solved(this.name, TerminalTimes.simPanesPB) } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/InOrder.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/InOrder.kt index 5496ffd67..7f1c7323e 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/InOrder.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/InOrder.kt @@ -1,6 +1,6 @@ package me.odinmain.features.impl.floor7.p3.termsim -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.impl.floor7.p3.TerminalTimes import me.odinmain.utils.postAndCatch import net.minecraft.inventory.ContainerChest @@ -32,7 +32,7 @@ object InOrder : TermSimGui( ) return slot.putStack(ItemStack(pane, slot.stack.stackSize, 5).apply { setStackDisplayName("") }) mc.thePlayer.playSound("random.orb", 1f, 1f) - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() if (inventorySlots.inventorySlots.subList(0, size).none { it?.stack?.metadata == 14 }) { solved(this.name, TerminalTimes.simNumbersPB) } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SameColor.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SameColor.kt index 60117d421..005bf9b2b 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SameColor.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SameColor.kt @@ -1,6 +1,6 @@ package me.odinmain.features.impl.floor7.p3.termsim -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.impl.floor7.p3.TerminalTimes import me.odinmain.utils.postAndCatch import net.minecraft.inventory.ContainerChest @@ -34,7 +34,7 @@ object SameColor : TermSimGui( else -> return } mc.thePlayer.playSound("random.orb", 1f, 1f) - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() if (grid.all { it?.stack?.metadata == grid.firstOrNull()?.stack?.metadata }) { solved(this.name, TerminalTimes.simColorPB) } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SelectAll.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SelectAll.kt index e4be8cf98..8651b8243 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SelectAll.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/SelectAll.kt @@ -1,13 +1,15 @@ package me.odinmain.features.impl.floor7.p3.termsim -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.impl.floor7.p3.TerminalTimes import me.odinmain.utils.getRandom import me.odinmain.utils.postAndCatch import net.minecraft.enchantment.Enchantment import net.minecraft.inventory.ContainerChest import net.minecraft.inventory.Slot -import net.minecraft.item.* +import net.minecraft.item.EnumDyeColor +import net.minecraft.item.Item +import net.minecraft.item.ItemStack import kotlin.math.floor class SelectAll(private val color: String) : TermSimGui( @@ -51,7 +53,7 @@ class SelectAll(private val color: String) : TermSimGui( slot.stack.addEnchantment(Enchantment.infinity, 1) mc.thePlayer.playSound("random.orb", 1f, 1f) - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() if (inventorySlots.inventorySlots.subList(0, size).none { it.stack?.isItemEnchanted == false && it.stack?.item in items && if (it.stack?.item == dye) it.stack?.metadata == correctDye else it.stack?.metadata == correctMeta }) solved(this.name, TerminalTimes.simSelectAllPB) diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/StartsWith.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/StartsWith.kt index 5263434c7..d76a5c285 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/StartsWith.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/StartsWith.kt @@ -1,6 +1,6 @@ package me.odinmain.features.impl.floor7.p3.termsim -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.impl.floor7.p3.TerminalTimes import me.odinmain.utils.getRandom import me.odinmain.utils.postAndCatch @@ -44,7 +44,7 @@ class StartsWith(private val letter: String) : TermSimGui( slot.stack.addEnchantment(Enchantment.infinity, 1) mc.thePlayer.playSound("random.orb", 1f, 1f) - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() if (inventorySlots.inventorySlots.subList(0, size).none { it.stack.displayName.startsWith(letter, true) && !it.stack.isItemEnchanted }) { solved(this.name, TerminalTimes.simStartsWithPB) } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/TermSimGui.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/TermSimGui.kt index 2226c9741..56c0d1994 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/TermSimGui.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/floor7/p3/termsim/TermSimGui.kt @@ -3,14 +3,18 @@ package me.odinmain.features.impl.floor7.p3.termsim import me.odinmain.OdinMain.display import me.odinmain.config.Config -import me.odinmain.events.impl.GuiLoadedEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.events.impl.PacketSentEvent import me.odinmain.features.settings.impl.NumberSetting -import me.odinmain.utils.* +import me.odinmain.utils.postAndCatch +import me.odinmain.utils.round +import me.odinmain.utils.runIn import me.odinmain.utils.skyblock.modMessage import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.inventory.* +import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.InventoryBasic +import net.minecraft.inventory.Slot import net.minecraft.item.Item import net.minecraft.item.ItemStack import net.minecraft.network.play.client.C0EPacketClickWindow @@ -44,7 +48,7 @@ open class TermSimGui(val name: String, val size: Int, private val inv: Inventor this.ping = ping display = this startTime = System.currentTimeMillis() - GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() + GuiEvent.GuiLoadedEvent(name, inventorySlots as ContainerChest).postAndCatch() } fun solved(name: String, oldPb: NumberSetting) { diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/kuudra/RemovePerks.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/kuudra/RemovePerks.kt index 571dd22fc..e6f2c3464 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/kuudra/RemovePerks.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/kuudra/RemovePerks.kt @@ -1,7 +1,6 @@ package me.odinmain.features.impl.kuudra -import me.odinmain.events.impl.DrawSlotEvent -import me.odinmain.events.impl.GuiClickEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.settings.impl.BooleanSetting @@ -20,13 +19,13 @@ object RemovePerks : Module( ) { private val renderStun: Boolean by BooleanSetting("Render Stun", false, description = "Renders the stun perk") @SubscribeEvent - fun renderSlot(event: DrawSlotEvent) { + fun renderSlot(event: GuiEvent.DrawSlotEvent) { if (event.gui !is GuiChest || event.gui.inventorySlots !is ContainerChest || (event.gui.inventorySlots as ContainerChest).name != "Perk Menu") return val slot = event.slot.stack?.displayName.noControlCodes if (slotCheck(slot)) event.isCanceled = true } @SubscribeEvent - fun guiMouseClick(event: GuiClickEvent) { + fun guiMouseClick(event: GuiEvent.GuiMouseClickEvent) { if (event.gui !is GuiChest || event.gui.inventorySlots !is ContainerChest || (event.gui.inventorySlots as ContainerChest).name != "Perk Menu") return val slot = event.gui.slotUnderMouse?.stack?.displayName.noControlCodes if (slotCheck(slot)) event.isCanceled = true diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/render/BlockOverlay.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/BlockOverlay.kt index 0aed3e3a4..26a196059 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/render/BlockOverlay.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/BlockOverlay.kt @@ -24,7 +24,6 @@ object BlockOverlay : Module( category = Category.RENDER, description = "Lets you customize the vanilla block overlay", ) { - private var fullBlock: Boolean by BooleanSetting("Full Block", false) private var disableDepth: Boolean by BooleanSetting("Disable Depth", false) private var lineSmoothing: Boolean by BooleanSetting("Line Smoothing", false) diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/CopyChat.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/CopyChat.kt index a7efbb2ca..d1aa1955c 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/CopyChat.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/CopyChat.kt @@ -1,6 +1,6 @@ package me.odinmain.features.impl.skyblock -import me.odinmain.events.impl.PreMouseInputEvent +import me.odinmain.events.impl.GuiEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.utils.copyToClipboard @@ -18,7 +18,7 @@ object CopyChat : Module( description = "Allows you to right click messages in chat to copy them.", ) { @SubscribeEvent - fun mouseClicked(event: PreMouseInputEvent) { + fun mouseClicked(event: GuiEvent.GuiMouseClickEvent) { if (event.button != 1 || mc.currentScreen !is GuiChat) return val mx = Mouse.getX() diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/HidePlayers.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/HidePlayers.kt index 9f3338ce6..f8b16996c 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/HidePlayers.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/HidePlayers.kt @@ -1,8 +1,6 @@ package me.odinmain.features.impl.skyblock -import com.sun.org.apache.xpath.internal.operations.Bool import me.odinmain.OdinMain.onLegitVersion -import me.odinmain.events.impl.ServerTickEvent import me.odinmain.features.Category import me.odinmain.features.Module import me.odinmain.features.settings.Setting.Companion.withDependency @@ -11,7 +9,6 @@ import me.odinmain.features.settings.impl.NumberSetting import me.odinmain.utils.ServerUtils.getPing import me.odinmain.utils.skyblock.Island import me.odinmain.utils.skyblock.dungeon.DungeonUtils -import me.odinmain.utils.skyblock.modMessage import net.minecraftforge.client.event.RenderPlayerEvent import net.minecraftforge.event.entity.living.LivingEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/PartyNote.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/PartyNote.kt index 5bd8bd65b..c3d1a0319 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/PartyNote.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/skyblock/PartyNote.kt @@ -21,5 +21,4 @@ object PartyNote { .replace(Regex("§([0-9a-fklmnor])")) { "§§${it.groupValues[1]}${it.groupValues[1]}" } packet.clickedItem.setStackDisplayName(itemName) } - } \ No newline at end of file diff --git a/odinmain/src/main/kotlin/me/odinmain/utils/Utils.kt b/odinmain/src/main/kotlin/me/odinmain/utils/Utils.kt index dd51cc75f..4a9573500 100644 --- a/odinmain/src/main/kotlin/me/odinmain/utils/Utils.kt +++ b/odinmain/src/main/kotlin/me/odinmain/utils/Utils.kt @@ -7,6 +7,7 @@ import me.odinmain.features.ModuleManager import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha import me.odinmain.utils.render.Color import me.odinmain.utils.skyblock.modMessage +import net.minecraft.inventory.Container import net.minecraft.inventory.ContainerChest import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event @@ -91,6 +92,9 @@ fun Float.round(decimals: Int): Float { val ContainerChest.name: String get() = this.lowerChestInventory.displayName.unformattedText +val Container.name: String + get() = (this as? ContainerChest)?.name ?: "Undefined Container" + operator fun Number.div(number: Number): Number { return this.toDouble() / number.toDouble() }