aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-17 21:59:35 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-17 21:59:35 +0100
commit9929b1b60f22a087369d7a8560d5388f8168872c (patch)
treed48bc8db633222fe9a3d3c213a5f4d63be75cc14 /src/main/java
parentc1586dec2e458388b8b669995bcac8a9bdafba95 (diff)
downloadskyhanni-9929b1b60f22a087369d7a8560d5388f8168872c.tar.gz
skyhanni-9929b1b60f22a087369d7a8560d5388f8168872c.tar.bz2
skyhanni-9929b1b60f22a087369d7a8560d5388f8168872c.zip
Fixing Ghost Entities.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt58
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt4
4 files changed, 70 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 16499a6a9..cb9e5f1a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -232,6 +232,7 @@ import at.hannibal2.skyhanni.features.misc.CurrentPetDisplay
import at.hannibal2.skyhanni.features.misc.CustomTextBox
import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider
import at.hannibal2.skyhanni.features.misc.FandomWikiFromMenus
+import at.hannibal2.skyhanni.features.misc.FixGhostEntities
import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls
import at.hannibal2.skyhanni.features.misc.HideArmor
import at.hannibal2.skyhanni.features.misc.InGameDateDisplay
@@ -368,7 +369,7 @@ import org.apache.logging.log4j.Logger
clientSideOnly = true,
useMetadata = true,
guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop",
- version = "0.23.Beta.8",
+ version = "0.23.Beta.9",
)
class SkyHanniMod {
@@ -710,6 +711,7 @@ class SkyHanniMod {
// test stuff
loadModule(SkyHanniDebugsAndTests())
+ loadModule(FixGhostEntities)
loadModule(CopyNearbyParticlesCommand)
loadModule(ButtonOnPause())
loadModule(PacketTest())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index 69db7f53d..9b3f41417 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -229,4 +229,10 @@ public class MiscConfig {
@Expose
public int limboTimePB = 0;
+
+ @Expose
+ @ConfigOption(name = "Fix Ghost Entities", desc = "Removes ghost entities caused by a Hypixel bug.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean fixGhostEntities = true;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt
new file mode 100644
index 000000000..69a1c6ee6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt
@@ -0,0 +1,58 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.network.play.server.S0CPacketSpawnPlayer
+import net.minecraft.network.play.server.S0FPacketSpawnMob
+import net.minecraft.network.play.server.S13PacketDestroyEntities
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+/**
+ * This feature fixes ghost entities sent by hypixel that are not properly deleted in the correct order.
+ * E.g. Diana or Dingeon mobs or nametags.
+ */
+object FixGhostEntities {
+
+ private val config get() = SkyHanniMod.feature.misc
+
+ private var recentlyRemovedEntities = ArrayDeque<Int>()
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ recentlyRemovedEntities = ArrayDeque()
+ }
+
+ @SubscribeEvent
+ fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) {
+ if (!isEnabled()) return
+
+ val packet = event.packet
+
+ if (packet is S0CPacketSpawnPlayer) {
+ if (packet.entityID in recentlyRemovedEntities) {
+ event.cancel()
+ LorenzUtils.debug("Removed bugged hypixel mob id Player")
+ }
+ }
+
+ if (packet is S0FPacketSpawnMob) {
+ if (packet.entityID in recentlyRemovedEntities) {
+ event.cancel()
+ LorenzUtils.debug("Removed bugged hypixel mob id Mob")
+ }
+ }
+
+ if (packet is S13PacketDestroyEntities) {
+ for (entityID in packet.entityIDs) {
+ recentlyRemovedEntities.add(entityID)
+ if (recentlyRemovedEntities.size == 10) {
+ recentlyRemovedEntities.removeFirst()
+ }
+ }
+ }
+ }
+
+ fun isEnabled() = LorenzUtils.connectedToHypixel && config.fixGhostEntities
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index f931e0f1d..c86dd3688 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -52,7 +52,9 @@ import kotlin.time.Duration.Companion.seconds
object LorenzUtils {
- val onHypixel get() = (HypixelData.hypixelLive || HypixelData.hypixelAlpha) && Minecraft.getMinecraft().thePlayer != null
+ val connectedToHypixel get() = HypixelData.hypixelLive || HypixelData.hypixelAlpha
+
+ val onHypixel get() = connectedToHypixel && Minecraft.getMinecraft().thePlayer != null
val isOnAlphaServer get() = onHypixel && HypixelData.hypixelAlpha