From 163cc857b0b1e6f52d56e663b8cb1c55f5e1bff2 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Wed, 7 Sep 2022 11:42:48 +0200 Subject: Hiding the flame particles when using the Fire Veil Wand ability. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 4 +- .../skyhanni/config/features/Abilities.java | 5 +++ .../hannibal2/skyhanni/data/EntityMovementData.kt | 47 ++++++++++++++++++++ .../skyhanni/data/EntityMovementHelper.kt | 47 -------------------- .../at/hannibal2/skyhanni/data/ItemClickData.kt | 32 ++++++++++++++ .../skyhanni/events/ItemClickInHandEvent.kt | 10 +++++ .../skyhanni/features/FireVeilWandParticles.kt | 50 ++++++++++++++++++++++ .../skyhanni/features/diana/GriffinBurrowFinder.kt | 5 +-- .../skyhanni/features/dungeon/DungeonHideItems.kt | 8 ++-- .../java/at/hannibal2/skyhanni/utils/LorenzVec.kt | 5 ++- 10 files changed, 156 insertions(+), 57 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/data/EntityMovementHelper.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/FireVeilWandParticles.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 353a00614..51dcd490a 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -60,7 +60,8 @@ public class SkyHanniMod { registerEvent(new SeaCreatureManager()); registerEvent(new ItemRenderBackground()); registerEvent(new EntityData()); - registerEvent(new EntityMovementHelper()); + registerEvent(new EntityMovementData()); + registerEvent(new ItemClickData()); registerEvent(new BazaarOrderHelper()); registerEvent(new ChatFilter()); @@ -107,6 +108,7 @@ public class SkyHanniMod { registerEvent(new DungeonHideItems()); registerEvent(new DungeonCopilot()); registerEvent(new EndermanSlayerBeacon()); + registerEvent(new FireVeilWandParticles()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java index a6c9c50f4..4e93679d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java @@ -50,4 +50,9 @@ public class Abilities { @ConfigEditorBoolean @ConfigAccordionId(id = 0) public boolean summoningMobColored = false; + + @Expose + @ConfigOption(name = "Fire Veil Particles", desc = "Hiding the flame particles when using the Fire Veil Wand ability.") + @ConfigEditorBoolean + public boolean fireVeilWandHider = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt new file mode 100644 index 000000000..1e07a6eaa --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -0,0 +1,47 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.EntityMoveEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.Entity +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class EntityMovementData { + + companion object { + private val entityLocation = mutableMapOf() + + fun addToTrack(entity: Entity) { + if (entity !in entityLocation) { + entityLocation[entity] = entity.getLorenzVec() + } + } + } + + var tick = 0 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!LorenzUtils.inSkyblock) return + + for (entity in entityLocation.keys) { + if (entity.isDead) continue + + val newLocation = entity.getLorenzVec() + val oldLocation = entityLocation[entity]!! + val distance = newLocation.distance(oldLocation) + if (distance > 0.01) { + entityLocation[entity] = newLocation + EntityMoveEvent(entity).postAndCatch() + } + } + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + entityLocation.clear() + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementHelper.kt deleted file mode 100644 index 908aae388..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementHelper.kt +++ /dev/null @@ -1,47 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.events.EntityMoveEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.entity.Entity -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -class EntityMovementHelper { - - companion object { - private val entityLocation = mutableMapOf() - - fun addToTrack(entity: Entity) { - if (entity !in entityLocation) { - entityLocation[entity] = entity.getLorenzVec() - } - } - } - - var tick = 0 - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!LorenzUtils.inSkyblock) return - - for (entity in entityLocation.keys) { - if (entity.isDead) continue - - val newLocation = entity.getLorenzVec() - val oldLocation = entityLocation[entity]!! - val distance = newLocation.distance(oldLocation) - if (distance > 0.01) { - entityLocation[entity] = newLocation - EntityMoveEvent(entity).postAndCatch() - } - } - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - entityLocation.clear() - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt new file mode 100644 index 000000000..e359c619e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -0,0 +1,32 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.ItemClickInHandEvent +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.InputEvent +import org.lwjgl.input.Mouse + +class ItemClickData { + + @SubscribeEvent + fun onClick(event: InputEvent.MouseInputEvent) { + if (!Mouse.getEventButtonState()) return + + val clickType = when (Mouse.getEventButton()) { + 0 -> { + ItemClickInHandEvent.ClickType.LEFT_CLICK + } + + 1 -> { + ItemClickInHandEvent.ClickType.RIGHT_CLICK + } + + else -> { + return + } + } + + val itemStack = Minecraft.getMinecraft().thePlayer.heldItem + ItemClickInHandEvent(clickType, itemStack).postAndCatch() + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt new file mode 100644 index 000000000..e1271b0a3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.item.ItemStack + +class ItemClickInHandEvent(val clickType: ClickType, val itemInHand: ItemStack?): LorenzEvent() { + + enum class ClickType { + LEFT_CLICK, RIGHT_CLICK + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/FireVeilWandParticles.kt new file mode 100644 index 000000000..1205c202b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/FireVeilWandParticles.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ItemClickInHandEvent +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.network.play.server.S2APacketParticles +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class FireVeilWandParticles { + + var lastClick = 0L + + @SubscribeEvent + fun onChatPacket(event: PacketEvent.ReceiveEvent) { + if (!isEnabled()) return + + val packet = event.packet + if (packet !is S2APacketParticles) return + + if (System.currentTimeMillis() > lastClick + 5_500) return + + if (packet.particleType == EnumParticleTypes.FLAME && packet.particleCount == 1 && packet.particleSpeed == 0f && + packet.xOffset == 0f && + packet.yOffset == 0f && + packet.zOffset == 0f + ) { + event.isCanceled = true + } + } + + @SubscribeEvent + fun onItemClick(event: ItemClickInHandEvent) { + if (!isEnabled()) return + if (event.clickType != ItemClickInHandEvent.ClickType.RIGHT_CLICK) return + + val itemInHand = event.itemInHand ?: return + + val internalName = itemInHand.getInternalName() + if (internalName == "FIRE_VEIL_WAND") { + lastClick = System.currentTimeMillis() + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.abilities.fireVeilWandHider + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/diana/GriffinBurrowFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/diana/GriffinBurrowFinder.kt index d98f46100..524a94259 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/diana/GriffinBurrowFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/diana/GriffinBurrowFinder.kt @@ -71,10 +71,7 @@ class GriffinBurrowFinder { fun onChatPacket(event: PacketEvent.ReceiveEvent) { val packet = event.packet if (packet is S2APacketParticles) { - val x = packet.xCoordinate - val y = packet.yCoordinate - val z = packet.zCoordinate - val distance = LorenzVec(x, y, z).distance(LocationUtils.playerLocation()) + val distance = packet.toLorenzVec().distance(LocationUtils.playerLocation()) if (distance < 20) { // LorenzDebug.log("") // LorenzDebug.log("S2APacketParticles close") diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt index faf48e95c..acc0de8a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt @@ -1,14 +1,14 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.EntityMovementHelper +import at.hannibal2.skyhanni.data.EntityMovementData import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.item.EntityItem import net.minecraft.network.play.server.S2APacketParticles @@ -121,7 +121,7 @@ class DungeonHideItems { } if (isSkeletonSkull(entity)) { - EntityMovementHelper.addToTrack(entity) + EntityMovementData.addToTrack(entity) if (SkyHanniMod.feature.dungeon.hideSkeletonSkull) { val lastMove = movingSkeletonSkulls.getOrDefault(entity, 0) if (lastMove + 100 > System.currentTimeMillis()) { @@ -139,7 +139,7 @@ class DungeonHideItems { val packet = event.packet if (packet is S2APacketParticles) { - val packetLocation = LorenzVec(packet.xCoordinate, packet.yCoordinate, packet.zCoordinate) + val packetLocation = packet.toLorenzVec() for (armorStand in hideParticles.filter { it.value + 100 > System.currentTimeMillis() }.map { it.key }) { val distance = packetLocation.distance(armorStand.getLorenzVec()) if (distance < 2) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 95ab29433..117a35f77 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils import net.minecraft.entity.Entity +import net.minecraft.network.play.server.S2APacketParticles import net.minecraft.util.BlockPos import net.minecraft.util.Rotations import net.minecraft.util.Vec3 @@ -107,4 +108,6 @@ fun Entity.getLorenzVec(): LorenzVec = LorenzVec(posX, posY, posZ) fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord) -fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z) \ No newline at end of file +fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z) + +fun S2APacketParticles.toLorenzVec(): LorenzVec = LorenzVec(xCoordinate, yCoordinate, zCoordinate) \ No newline at end of file -- cgit