From 67ed7a34d52067dd83f93d8ab8e81401149b5659 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 13 Feb 2023 22:54:08 +0100 Subject: Fixed fire veil particle hider bug. --- .../at/hannibal2/skyhanni/data/ItemClickData.kt | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt index b7dccd76b..a2a22a865 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -1,9 +1,13 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.EntityClickEvent -import at.hannibal2.skyhanni.events.ItemClickInHandEvent +import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft +import net.minecraft.network.play.client.C07PacketPlayerDigging +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Mouse @@ -11,17 +15,17 @@ import org.lwjgl.input.Mouse class ItemClickData { @SubscribeEvent - fun onClick(event: InputEvent.MouseInputEvent) { - if (!Mouse.getEventButtonState()) return - - val clickType = when (Mouse.getEventButton()) { - 0 -> ClickType.LEFT_CLICK - 1 -> ClickType.RIGHT_CLICK - else -> return + fun onItemClickSend(event: PacketEvent.SendEvent) { + val packet = event.packet + if (packet is C08PacketPlayerBlockPlacement) { + val position = packet.position.toLorenzVec() + BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch() + } + if (packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) { + val position = packet.position.toLorenzVec() + val itemInHand = Minecraft.getMinecraft().thePlayer.heldItem + BlockClickEvent(ClickType.LEFT_CLICK, position, itemInHand).postAndCatch() } - - val itemStack = Minecraft.getMinecraft().thePlayer.heldItem - ItemClickInHandEvent(clickType, itemStack).postAndCatch() } @SubscribeEvent -- cgit