diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
3 files changed, 94 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt new file mode 100644 index 000000000..79d0107c7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.entity.EntityLivingBase +import net.minecraft.network.play.server.S1CPacketEntityMetadata +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class EntityData { + + @SubscribeEvent + fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) { + val packet = event.packet + if (packet !is S1CPacketEntityMetadata) return + + if (packet == null) { + LorenzUtils.debug("packet is null in CorruptedMobHigh light!") + return + } + + val watchableObjects = packet.func_149376_c() ?: return + for (watchableObject in watchableObjects) { + if (watchableObject.dataValueId != 6) continue + + val theWorld = Minecraft.getMinecraft().theWorld + if (theWorld == null) { + LorenzUtils.debug("theWorld is null in CorruptedMobHighlight!") + continue + } + val entityId = packet.entityId + if (entityId == null) { + LorenzUtils.debug("entityId is null in CorruptedMobHighlight!") + continue + } + + val entity = theWorld.getEntityByID(entityId) ?: continue + if (entity !is EntityLivingBase) continue + + val health = watchableObject.`object` as Float + EntityHealthUpdateEvent(entity, health).postAndCatch() + return + } + } +}
\ 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 new file mode 100644 index 000000000..908aae388 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementHelper.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 EntityMovementHelper { + + companion object { + private val entityLocation = mutableMapOf<Entity, LorenzVec>() + + 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/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 8351991ab..a9fbcb04a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -28,7 +28,7 @@ class RepoManager(private val configLocation: File) { } } - private val atomicShouldManuallyReload = AtomicBoolean(false)//TODO FIX + private val atomicShouldManuallyReload = AtomicBoolean(false)//TODO remove the workaround fun updateRepo() { atomicShouldManuallyReload.set(true) |
