From ca686a46e4044108773d4e0422bedad9558f8afb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 8 Aug 2023 00:07:49 +0200 Subject: code cleanup in mixins --- .../java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt | 9 +++++---- .../hannibal2/skyhanni/mixins/hooks/GuiPlayerTabOverlayHook.kt | 2 +- .../at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt | 3 +-- .../java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt | 9 +-------- 4 files changed, 8 insertions(+), 15 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks') diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt index cfdff8a73..5b41f87c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt @@ -20,19 +20,20 @@ class GuiContainerHook(guiAny: Any) { if (CloseWindowEvent(gui, gui.inventorySlots).postAndCatch()) ci.cancel() } - fun backgroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) { + fun backgroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float) { GuiContainerEvent.BackgroundDrawnEvent(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch() } - fun foregroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) { + fun foregroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float) { GuiContainerEvent.ForegroundDrawnEvent(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch() } fun onDrawSlot(slot: Slot, ci: CallbackInfo) { - if (GuiContainerEvent.DrawSlotEvent.GuiContainerDrawSlotPre(gui, gui.inventorySlots, slot).postAndCatch()) ci.cancel() + val event = GuiContainerEvent.DrawSlotEvent.GuiContainerDrawSlotPre(gui, gui.inventorySlots, slot) + if (event.postAndCatch()) ci.cancel() } - fun onDrawSlotPost(slot: Slot, ci: CallbackInfo) { + fun onDrawSlotPost(slot: Slot) { GuiContainerEvent.DrawSlotEvent.GuiContainerDrawSlotPost(gui, gui.inventorySlots, slot).postAndCatch() } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiPlayerTabOverlayHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiPlayerTabOverlayHook.kt index 5d0542e9a..158995e55 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiPlayerTabOverlayHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiPlayerTabOverlayHook.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.events.TabListLineRenderEvent import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable import kotlin.reflect.KProperty -var tabListGuard by object : ThreadLocal() { +var tabListGuard by object : ThreadLocal() { override fun initialValue(): Boolean { return false } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt index b5b4ec0ea..1466ed44d 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt @@ -1,11 +1,10 @@ package at.hannibal2.skyhanni.mixins.hooks import at.hannibal2.skyhanni.events.PacketEvent -import io.netty.channel.ChannelHandlerContext import net.minecraft.network.Packet import org.spongepowered.asm.mixin.injection.callback.CallbackInfo -fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) { +fun onReceivePacket(packet: Packet<*>, ci: CallbackInfo) { if (packet != null) { if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt index b94fad0d2..ae9b02354 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt @@ -4,12 +4,6 @@ import at.hannibal2.skyhanni.events.GuiRenderItemEvent import at.hannibal2.skyhanni.events.RenderRealOverlayEvent import net.minecraft.client.gui.FontRenderer import net.minecraft.item.ItemStack -import net.minecraft.util.ResourceLocation -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo - -val RES_ITEM_GLINT = ResourceLocation("textures/misc/enchanted_item_glint.png") - -var skipGlint = false fun renderItemOverlayPost( fr: FontRenderer, @@ -17,7 +11,6 @@ fun renderItemOverlayPost( xPosition: Int, yPosition: Int, text: String?, - ci: CallbackInfo ) { GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost( fr, @@ -28,6 +21,6 @@ fun renderItemOverlayPost( ).postAndCatch() } -fun renderItemReturn(stack: ItemStack, x: Int, y: Int, ci: CallbackInfo) { +fun renderItemReturn(stack: ItemStack, x: Int, y: Int) { RenderRealOverlayEvent(stack, x, y).postAndCatch() } -- cgit