aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Chat.java12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt184
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/NewChatFilter.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt69
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt17
12 files changed, 293 insertions, 91 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 353cfa934..d77c4f9cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod;
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper;
import at.hannibal2.skyhanni.features.chat.ChatFilter;
import at.hannibal2.skyhanni.features.chat.ChatManager;
-import at.hannibal2.skyhanni.features.chat.NewChatFilter;
import at.hannibal2.skyhanni.features.chat.PlayerChatFilter;
import at.hannibal2.skyhanni.features.commands.WikiCommand;
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager;
@@ -68,7 +67,6 @@ public class SkyHanniMod {
registerEvent(new BazaarOrderHelper());
registerEvent(new ChatFilter());
- registerEvent(new NewChatFilter());
registerEvent(new PlayerChatFilter());
registerEvent(new DungeonChatFilter());
registerEvent(new HideNotClickableItems());
@@ -98,6 +96,7 @@ public class SkyHanniMod {
registerEvent(new RealTime());
registerEvent(new RngMeterInventory());
registerEvent(new WikiCommand());
+ registerEvent(new SummoningMobManager());
Commands.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index ba3b49129..16e2b42f0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -71,6 +71,11 @@ public class Features {
editOverlay(activeConfigCategory, 200, 16, minions.hopperProfitPos);
return;
}
+
+ if (runnableId.equals("summoningMobDisplay")) {
+ editOverlay(activeConfigCategory, 200, 16, abilities.summoningMobDisplayPos);
+ return;
+ }
}
@Expose
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 646047710..6a6995b23 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.config.features;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption;
+import at.hannibal2.skyhanni.config.gui.core.config.Position;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.*;
import com.google.gson.annotations.Expose;
public class Abilities {
@@ -15,4 +15,27 @@ public class Abilities {
@ConfigOption(name = "Ability Cooldown Background", desc = "Show the cooldown color of item abilities in the background.")
@ConfigEditorBoolean
public boolean itemAbilityCooldownBackground = false;
+
+ @Expose
+ @ConfigOption(name = "Summoning Mob", desc = "")
+ @ConfigEditorAccordion(id = 0)
+ public boolean summoningMob = false;
+
+ @Expose
+ @ConfigOption(name = "Summoning Mob Display", desc = "Show the health of your spawned summoning mobs")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean summoningMobDisplay = false;
+
+ @Expose
+ @ConfigOption(name = "Summoning Mob Display Position", desc = "")
+ @ConfigEditorButton(runnableId = "summoningMobDisplay", buttonText = "Edit")
+ @ConfigAccordionId(id = 0)
+ public Position summoningMobDisplayPos = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Summoning Mob Nametag", desc = "Hide the nametag of your spawned summoning mobs")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean summoningMobHideNametag = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java
index bdd7e8f0d..c7bfa2973 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java
@@ -10,38 +10,38 @@ public class Chat {
@Expose
@ConfigOption(name = "Chat Filter Types", desc = "")
- @ConfigEditorAccordion(id = 1)
+ @ConfigEditorAccordion(id = 0)
public boolean filterTypes = false;
@Expose
@ConfigOption(name = "HyPixel Hub", desc = "Block messages outside SkyBlock in the HyPixel lobby: player joins, loot boxes, prototype lobby messages, radiating generosity and HyPixel tournaments.")
@ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
+ @ConfigAccordionId(id = 0)
public boolean hypixelHub = false;
@Expose
@ConfigOption(name = "Empty", desc = "Hide all the empty messages from the chat.")
@ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
+ @ConfigAccordionId(id = 0)
public boolean empty = false;
@Expose
@ConfigOption(name = "Warping", desc = "Block 'sending request to join ..' and 'warping ..' messages.")
@ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
+ @ConfigAccordionId(id = 0)
public boolean warping = false;
@Expose
@ConfigOption(name = "Welcome", desc = "Hide the 'welcome to skyblock' message.")
@ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
+ @ConfigAccordionId(id = 0)
public boolean welcome = false;
//TODO remove
@Expose
@ConfigOption(name = "Others", desc = "Hide other annoying messages.")
@ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
+ @ConfigAccordionId(id = 0)
public boolean others = false;
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
new file mode 100644
index 000000000..5dca40d1b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
@@ -0,0 +1,184 @@
+package at.hannibal2.skyhanni.features
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
+import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.EntityLiving
+import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.client.event.RenderLivingEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import java.util.regex.Pattern
+
+class SummoningMobManager {
+
+ private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>()
+ private val summoningMobNametags = mutableListOf<EntityArmorStand>()
+ private var summoningsSpawned = 0
+ private var searchArmorStands = false
+ private var searchMobs = false
+
+ //§aYou have spawned your Tank Zombie §r§asoul! §r§d(249 Mana)
+ private val spawnPatter = Pattern.compile("§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)")
+ private val despawnPatter = Pattern.compile("§cYou have despawned your (monster|monsters)!")
+
+ //§a§ohannibal2's Tank Zombie§r §a160k§c❤
+ private val healthPattern = Pattern.compile("§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤")
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.isOnHypixel) return
+
+ val message = event.message
+ val matcher = spawnPatter.matcher(message)
+ if (matcher.matches()) {
+ if (SkyHanniMod.feature.abilities.summoningMobDisplay) {
+ event.blockedReason = "summoning_soul"
+ }
+ summoningsSpawned++
+ searchArmorStands = true
+ searchMobs = true
+ }
+
+ if (despawnPatter.matcher(message).matches() || message.startsWith("§c ☠ §r§7You ")) {
+ despawned()
+ if (SkyHanniMod.feature.abilities.summoningMobDisplay && !message.contains("☠")) {
+ event.blockedReason = "summoning_soul"
+ }
+ }
+ }
+
+ var tick = 0
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ if (SkyHanniMod.feature.abilities.summoningMobDisplay) {
+ if (tick++ % 20 == 0) {
+ updateData()
+ }
+ }
+
+ if (searchArmorStands) {
+ Minecraft.getMinecraft().theWorld.loadedEntityList
+ .filter { it is EntityArmorStand && it !in summoningMobNametags }
+ .forEach {
+ val name = it.displayName.unformattedText
+ val matcher = healthPattern.matcher(name)
+ if (matcher.matches()) {
+ val playerName = Minecraft.getMinecraft().thePlayer.name
+ if (name.contains(playerName)) {
+ summoningMobNametags.add(it as EntityArmorStand)
+ if (summoningMobNametags.size == summoningsSpawned) {
+ searchArmorStands = false
+ }
+ }
+ }
+ }
+ }
+ if (searchMobs) {
+
+ val playerLocation = LocationUtils.playerLocation()
+ Minecraft.getMinecraft().theWorld.loadedEntityList
+ .filter {
+ it is EntityLiving && it !in summoningMobs.keys && it.getLorenzVec().distance(playerLocation) < 3
+ }
+ .forEach {
+ summoningMobs[it as EntityLiving] = SummoningMob(System.currentTimeMillis(), name = "Mob")
+ updateData()
+ if (summoningMobs.size == summoningsSpawned) {
+ searchMobs = false
+ }
+ }
+ }
+ }
+
+ private fun updateData() {
+ if (summoningMobs.isEmpty()) return
+
+ for (entry in HashMap(summoningMobs)) {
+ val entityLiving = entry.key
+ val summoningMob = entry.value
+
+ val currentHealth = entityLiving.health.toInt()
+ val name = summoningMob.name
+ if (currentHealth == 0) {
+ summoningMobs.remove(entityLiving)
+ LorenzUtils.chat("§e[SkyHanni] your Summoning Mob just §cdied!")
+ continue
+ }
+
+ val maxHealth = entityLiving.baseMaxHealth.toInt()
+ val color = NumberUtil.percentageColor(currentHealth, maxHealth).getChatColor()
+
+ val currentFormat = NumberUtil.format(currentHealth)
+ val maxFormat = NumberUtil.format(maxHealth)
+ summoningMob.lastDisplayName = "§a$name $color$currentFormat/$maxFormat"
+ }
+ }
+
+ @SubscribeEvent
+ fun renderOverlay(event: RenderGameOverlayEvent.Post) {
+ if (!SkyHanniMod.feature.abilities.summoningMobDisplay) return
+ if (summoningMobs.isEmpty()) return
+
+ val list = mutableListOf<String>()
+ list.add("Summoning mobs: " + summoningMobs.size)
+ var id = 1
+ for (mob in summoningMobs) {
+ val name = mob.value.lastDisplayName
+ list.add("#$id $name")
+ id++
+ }
+
+ SkyHanniMod.feature.abilities.summoningMobDisplayPos.renderStrings(list)
+ }
+
+ @SubscribeEvent
+ fun renderOverlay(event: WorldEvent.Load) {
+ despawned()
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
+ fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) {
+ if (!LorenzUtils.inSkyblock) return
+ if (!SkyHanniMod.feature.abilities.summoningMobHideNametag) return
+
+ val entity = event.entity
+ if (entity !is EntityArmorStand) return
+ if (!entity.hasCustomName()) return
+ if (entity.isDead) return
+
+ event.isCanceled = entity in summoningMobNametags
+ }
+
+ private fun despawned() {
+ summoningMobs.clear()
+ summoningMobNametags.clear()
+ summoningsSpawned = 0
+ searchArmorStands = false
+ searchMobs = false
+ println("despawning")
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && (SkyHanniMod.feature.abilities.summoningMobDisplay || SkyHanniMod.feature.abilities.summoningMobHideNametag)
+ }
+
+ class SummoningMob(
+ val spawnTime: Long,
+ var name: String = "",
+ var lastDisplayName: String = "",
+ )
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
index 1f0144620..1a659f171 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
@@ -2,12 +2,12 @@ package at.hannibal2.skyhanni.features
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.test.GriffinJavaUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.getLorenzVec
-import at.hannibal2.skyhanni.utils.getNameTagWith
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.item.EntityArmorStand
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/NewChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/NewChatFilter.kt
deleted file mode 100644
index bf73917aa..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/NewChatFilter.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package at.hannibal2.skyhanni.features.chat
-
-import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class NewChatFilter {
-
- @SubscribeEvent
- fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.isOnHypixel) return
-
-// val blockReason = block(event.message)
-// if (blockReason != "") {
-// event.blockedReason = blockReason
-// }
- }
-} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
index 047b4c7ed..0004d9e97 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
@@ -7,6 +7,8 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonData
import at.hannibal2.skyhanni.test.LorenzTest
import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith
+import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -239,7 +241,7 @@ class DamageIndicatorManager {
if (customHealthText.isNotEmpty()) {
entityData.healthText = customHealthText
} else {
- val color = percentageColor(health, maxHealth)
+ val color = NumberUtil.percentageColor(health, maxHealth)
entityData.healthText = color.getChatColor() + NumberUtil.format(health)
}
entityData.timeLastTick = System.currentTimeMillis()
@@ -316,7 +318,7 @@ class DamageIndicatorManager {
18 -> "§e4/6"
16 -> "§e5/6"
else -> {
- val color = percentageColor(health, 10_000_000)
+ val color = NumberUtil.percentageColor(health, 10_000_000)
entityData.namePrefix = "§a6/6"
return color.getChatColor() + NumberUtil.format(health)
}
@@ -352,7 +354,7 @@ class DamageIndicatorManager {
}
if (calcHealth == -1) return null
- val color = percentageColor(calcHealth, maxHealth)
+ val color = NumberUtil.percentageColor(calcHealth, maxHealth)
return color.getChatColor() + NumberUtil.format(calcHealth)
}
@@ -408,7 +410,8 @@ class DamageIndicatorManager {
}
else -> return null
}
- val result = percentageColor(calcHealth, calcMaxHealth).getChatColor() + NumberUtil.format(calcHealth)
+ val result =
+ NumberUtil.percentageColor(calcHealth, calcMaxHealth).getChatColor() + NumberUtil.format(calcHealth)
//Hit phase
@@ -423,7 +426,7 @@ class DamageIndicatorManager {
}
val name = armorStandHits.name.removeColor()
val hits = name.between("Seraph ", " Hit").toInt()
- return percentageColor(hits, maxHits).getChatColor() + "$hits Hits"
+ return NumberUtil.percentageColor(hits, maxHits).getChatColor() + "$hits Hits"
}
//Laser phase
@@ -436,7 +439,7 @@ class DamageIndicatorManager {
if (SkyHanniMod.feature.damageIndicator.showHealthDuringLaser) {
entityData.nameSuffix = " §f" + formatDelay(remainingTicks * 50)
} else {
- return formatDelay(remainingTicks * 50)
+ return formatDelay(remainingTicks * 50)
}
}
@@ -486,7 +489,7 @@ class DamageIndicatorManager {
LorenzUtils.error("Invalid thorn floor!")
return null
}
- val color = percentageColor(health, maxHealth)
+ val color = NumberUtil.percentageColor(health, maxHealth)
return color.getChatColor() + health + "/" + maxHealth
}
@@ -508,20 +511,6 @@ class DamageIndicatorManager {
}
}
- private fun percentageColor(
- have: Int,
- max: Int,
- ): LorenzColor {
- val percentage = have.toDouble() / max.toDouble()
- return when {
- percentage > 0.9 -> LorenzColor.DARK_GREEN
- percentage > 0.75 -> LorenzColor.GREEN
- percentage > 0.5 -> LorenzColor.YELLOW
- percentage > 0.25 -> LorenzColor.GOLD
- else -> LorenzColor.RED
- }
- }
-
private fun grabData(entity: EntityLivingBase): EntityData? {
if (data.contains(entity.uniqueID)) return data[entity.uniqueID]
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
index 636fff106..537a9850f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
@@ -1,12 +1,12 @@
package at.hannibal2.skyhanni.features.damageindicator
import at.hannibal2.skyhanni.features.dungeon.DungeonData
+import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.getLorenzVec
-import at.hannibal2.skyhanni.utils.hasNameTagWith
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.Entity
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index acfcd86d4..143ba4ca1 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -4,43 +4,42 @@ import net.minecraft.entity.EntityLiving
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.util.AxisAlignedBB
-class EntityUtils {
-}
+object EntityUtils {
-//TODO move into utils method
-fun EntityLiving.hasNameTagWith(
- y: Int,
- contains: String,
- debugRightEntity: Boolean = false,
- inaccuracy: Double = 1.6,
- debugWrongEntity: Boolean = false,
-): Boolean {
- return getNameTagWith(y, contains, debugRightEntity, inaccuracy, debugWrongEntity) != null
-}
+ fun EntityLiving.hasNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+ ): Boolean {
+ return getNameTagWith(y, contains, debugRightEntity, inaccuracy, debugWrongEntity) != null
+ }
-fun EntityLiving.getNameTagWith(
- y: Int,
- contains: String,
- debugRightEntity: Boolean = false,
- inaccuracy: Double = 1.6,
- debugWrongEntity: Boolean = false,
-): EntityArmorStand? {
- val center = getLorenzVec().add(0, y, 0)
- val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
- val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
- val alignedBB = AxisAlignedBB(a, b)
- val clazz = EntityArmorStand::class.java
- val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
- return found.find {
- val result = it.name.contains(contains)
- if (debugWrongEntity && !result) {
- println("wrong entity in aabb: '" + it.name + "'")
- }
- if (debugRightEntity && result) {
- println("mob: " + center.printWithAccuracy(2))
- println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
- println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
+ fun EntityLiving.getNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+ ): EntityArmorStand? {
+ val center = getLorenzVec().add(0, y, 0)
+ val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
+ val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
+ val alignedBB = AxisAlignedBB(a, b)
+ val clazz = EntityArmorStand::class.java
+ val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
+ return found.find {
+ val result = it.name.contains(contains)
+ if (debugWrongEntity && !result) {
+ println("wrong entity in aabb: '" + it.name + "'")
+ }
+ if (debugRightEntity && result) {
+ println("mob: " + center.printWithAccuracy(2))
+ println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
+ println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
+ }
+ result
}
- result
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index 1d4701397..afc35b3ec 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -156,4 +156,18 @@ object NumberUtil {
fun String.isInt(): Boolean {
return isNotEmpty() && pattern.matcher(this).matches()
}
+
+ fun percentageColor(
+ have: Int,
+ max: Int,
+ ): LorenzColor {
+ val percentage = have.toDouble() / max.toDouble()
+ return when {
+ percentage > 0.9 -> LorenzColor.DARK_GREEN
+ percentage > 0.75 -> LorenzColor.GREEN
+ percentage > 0.5 -> LorenzColor.YELLOW
+ percentage > 0.25 -> LorenzColor.GOLD
+ else -> LorenzColor.RED
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 9de886f37..39c7217f6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -409,7 +409,7 @@ object RenderUtils {
return lastValue + (currentValue - lastValue) * multiplier
}
- fun Position.renderString(string: String) {
+ fun Position.renderString(string: String, offsetY: Int = 0) {
if (string == "") return
val textToRender = "§f$string"
@@ -421,14 +421,21 @@ object RenderUtils {
val offsetX = (200 - renderer.getStringWidth(textToRender.removeColor())) / 2
val x = getAbsX(resolution, 200) + offsetX
- val y = getAbsY(resolution, 16)
-
-
+ val y = getAbsY(resolution, 16) + offsetY
GlStateManager.translate(x + 1.0, y + 1.0, 0.0)
renderer.drawStringWithShadow(textToRender, 0f, 0f, 0)
-
GlStateManager.popMatrix()
}
+
+ fun Position.renderStrings(list: List<String>) {
+ if (list.isEmpty()) return
+
+ var offsetY = 0
+ for (s in list) {
+ renderString(s, offsetY)
+ offsetY += 14
+ }
+ }
} \ No newline at end of file