aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-24 19:24:54 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-24 19:24:54 +0200
commit891675f68a1c4786c2e288ef3f1a191a0070e9ac (patch)
tree898ef9b5b50ce4c4d20135217e7c2edbd184f6ba /src/main/java/at/hannibal2/skyhanni/features
parent847100cb50dea171d494e541bc3a19bf8438ba3d (diff)
downloadskyhanni-891675f68a1c4786c2e288ef3f1a191a0070e9ac.tar.gz
skyhanni-891675f68a1c4786c2e288ef3f1a191a0070e9ac.tar.bz2
skyhanni-891675f68a1c4786c2e288ef3f1a191a0070e9ac.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt71
2 files changed, 34 insertions, 39 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
index 9e998514c..e5f6d9568 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
@@ -129,4 +129,4 @@ object UpdateManager {
}
var potentialUpdate: PotentialUpdate? = null
-}
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
index 0d1a824e4..2538fb8ff 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleUtils
import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SpecialColour
@@ -11,9 +12,7 @@ import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
-import net.minecraft.item.ItemSkull
import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NBTUtil
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color
@@ -21,19 +20,18 @@ import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
class VoltHighlighter {
- val config get() = SkyHanniMod.feature.rift.crux
+ private val config get() = SkyHanniMod.feature.rift.crux
- val LIGHTNING_DISTANCE = 7F
- val ARMOR_SLOT_HEAD = 3
- val CHARGE_TIME = 12.seconds
- var dischargingSince = SimpleTimeMark.farPast()
+ private val LIGHTNING_DISTANCE = 7F
+ private val ARMOR_SLOT_HEAD = 3
+ private val CHARGE_TIME = 12.seconds
+ private var dischargingSince = SimpleTimeMark.farPast()
@SubscribeEvent
fun onArmorChange(event: EntityEquipmentChangeEvent) {
if (!RiftAPI.inRift() || !config.voltWarning) return
val player = Minecraft.getMinecraft().thePlayer ?: return
- if (EntityEquipmentChangeEvent.EQUIPMENT_SLOT_HEAD == event.equipmentSlot
- && getVoltState(event.entity) == VoltState.AVoltThatIsCurrentlyAtThisMomentActivelySpawningLightning
+ if (event.isHead && getVoltState(event.entity) == VoltState.DOING_LIGHTNING
&& event.entity.positionVector.squareDistanceTo(player.positionVector) <= LIGHTNING_DISTANCE * LIGHTNING_DISTANCE
) {
dischargingSince = SimpleTimeMark.now()
@@ -50,27 +48,27 @@ class VoltHighlighter {
50
)
}
- val e = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
- for (e in e) {
- if (e !is EntityLivingBase) continue
- val s = getVoltState(e)
- if (s == VoltState.NotAVolt) continue
+ val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
+ for (entity in list) {
+ if (entity !is EntityLivingBase) continue
+ val state = getVoltState(entity)
+ if (state == VoltState.NO_VOLT) continue
if (config.voltMoodMeter)
RenderLivingEntityHelper.setEntityColor(
- e, when (s) {
- VoltState.AVoltThatIsFriendly -> 0x8000FF00.toInt()
- VoltState.AVoltThatIsCurrentlyAtThisMomentActivelySpawningLightning -> 0x800000FF.toInt()
- VoltState.AVoltThatIsAggressiveButDoesNotDischargeAtmosphericElectricity -> 0x80FF0000.toInt()
+ entity, when (state) {
+ VoltState.FRIENDLY -> 0x8000FF00.toInt()
+ VoltState.DOING_LIGHTNING -> 0x800000FF.toInt()
+ VoltState.HOSTILE -> 0x80FF0000.toInt()
else -> 0
}
- ) { true }
- if (s == VoltState.AVoltThatIsCurrentlyAtThisMomentActivelySpawningLightning && config.voltRange) {
+ ) { config.voltMoodMeter }
+ if (state == VoltState.DOING_LIGHTNING && config.voltRange) {
RenderUtils.drawCylinderInWorld(
Color(SpecialColour.specialToChromaRGB(config.voltColour), true),
- e.posX,
- e.posY - 4f,
- e.posZ,
+ entity.posX,
+ entity.posY - 4f,
+ entity.posZ,
radius = LIGHTNING_DISTANCE,
partialTicks = event.partialTicks,
height = 20F
@@ -80,38 +78,35 @@ class VoltHighlighter {
}
enum class VoltState {
- NotAVolt,
- AVoltThatIsFriendly,
- AVoltThatIsAggressiveButDoesNotDischargeAtmosphericElectricity,
- AVoltThatIsCurrentlyAtThisMomentActivelySpawningLightning, ;
+ NO_VOLT,
+ FRIENDLY,
+ HOSTILE,
+ DOING_LIGHTNING,
+ ;
}
private fun getVoltState(itemStack: ItemStack): VoltState {
- if (itemStack.item !is ItemSkull) return VoltState.NotAVolt
- val skullOwnerNbt = itemStack.getSubCompound("SkullOwner", false) ?: return VoltState.NotAVolt
- val profile = NBTUtil.readGameProfileFromNBT(skullOwnerNbt) ?: return VoltState.NotAVolt
- val textures = profile.properties["textures"].singleOrNull() ?: return VoltState.NotAVolt
- return when (textures.value) {
+ return when (itemStack.getSkullTexture()) {
"ewogICJ0aW1lc3RhbXAiIDogMTY3Mzg4MzU3MjAzNSwKICAicHJvZmlsZUlkIiA6ICI0MDU4NDhjMmJjNTE0ZDhkOThkOTJkMGIwYzhiZDQ0YiIsCiAgInByb2ZpbGVOYW1lIiA6ICJMb3ZlT3dPIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2UxYjFiZmI1MzZiNjQxNmIyNmEyODNkMmQ4YWQ0YjE3NzFiYmU1Yjc2ODk2ZTI3MjdkNWU4MzNiYzg5NDk4MmQiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==" -> {
- VoltState.AVoltThatIsCurrentlyAtThisMomentActivelySpawningLightning
+ VoltState.DOING_LIGHTNING
}
"ewogICJ0aW1lc3RhbXAiIDogMTY3MzYzNzQ1OTAwOCwKICAicHJvZmlsZUlkIiA6ICJmMTA0NzMxZjljYTU0NmI0OTkzNjM4NTlkZWY5N2NjNiIsCiAgInByb2ZpbGVOYW1lIiA6ICJ6aWFkODciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2FlYTYyNTFlNThlM2QyMDU1MmEwMzVkNDI0NTYxZWFlZTA4M2ZlYWNkMWU2Y2IzYzJhNWNmOTQ1Y2U2ZDc2ZSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" -> {
- VoltState.AVoltThatIsFriendly
+ VoltState.FRIENDLY
}
"ewogICJ0aW1lc3RhbXAiIDogMTY3Mzg4MzEwNjAwMywKICAicHJvZmlsZUlkIiA6ICI5NTE3OTkxNjljYzE0MGY1OGM2MmRjOGZmZTU3NjBiZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJZdWFyaWciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGY5ZWRlOTcwZDQwYzViMjQ1Y2JkNjUxMzQ5ZWUxNjZmNjk1ZDI1MDM0NWY4ZjBlNjNmY2IxMGNmYjVhMmI3OCIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" -> {
- VoltState.AVoltThatIsAggressiveButDoesNotDischargeAtmosphericElectricity
+ VoltState.HOSTILE
}
- else -> VoltState.NotAVolt
+ else -> VoltState.NO_VOLT
}
}
private fun getVoltState(entity: net.minecraft.entity.Entity): VoltState {
- if (entity !is EntityArmorStand) return VoltState.NotAVolt
- val helmet = entity.getCurrentArmor(ARMOR_SLOT_HEAD) ?: return VoltState.NotAVolt
+ if (entity !is EntityArmorStand) return VoltState.NO_VOLT
+ val helmet = entity.getCurrentArmor(ARMOR_SLOT_HEAD) ?: return VoltState.NO_VOLT
return getVoltState(helmet)
}
} \ No newline at end of file