diff options
Diffstat (limited to 'src/main/java')
6 files changed, 79 insertions, 69 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 4fb73b1ac..a32d8bf84 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -50,22 +50,22 @@ public class RiftConfig { @Expose - @ConfigOption(name = "Volt Warning", desc = "Shows a warning while a volt is discharging lightning") + @ConfigOption(name = "Volt Warning", desc = "Shows a warning while a volt is discharging lightning.") @ConfigEditorBoolean public boolean voltWarning = true; @Expose - @ConfigOption(name = "Volt Range Highlighter", desc = "Shows the area in which a Volt might strike lightning") + @ConfigOption(name = "Volt Range Highlighter", desc = "Shows the area in which a Volt might strike lightning.") @ConfigEditorBoolean public boolean voltRange = true; @Expose - @ConfigOption(name = "Volt Range Highlighter Colour", desc = "In which colour should the volt range be highlighted") + @ConfigOption(name = "Volt Range Highlighter Color", desc = "In which color should the volt range be highlighted?") @ConfigEditorColour public String voltColour = "0:60:0:0:255"; @Expose - @ConfigOption(name = "Volt mood colour", desc = "Change the colour of the volt enemy depending on their mood") + @ConfigOption(name = "Volt mood color", desc = "Change the color of the volt enemy depending on their mood.") @ConfigEditorBoolean public boolean voltMoodMeter = false; diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt index c9a67f154..9d7bfd3a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt @@ -8,6 +8,8 @@ data class EntityEquipmentChangeEvent( val equipmentSlot: Int, val newItemStack: ItemStack? ) : LorenzEvent() { + val isHead get() = equipmentSlot == EQUIPMENT_SLOT_HEAD + companion object { val EQUIPMENT_SLOT_HEAD = 4 val EQUIPMENT_SLOT_CHEST = 3 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 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index cade8b0fe..69df66afa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -104,7 +104,7 @@ object RenderUtils { */ renderRelativeToCamera: Boolean = true, drawVerticalBarriers: Boolean = true, - partialTicks: Float = 0F + partialTicks: Float = 0F, ) { GlStateManager.enableBlend() GlStateManager.disableLighting() @@ -127,16 +127,20 @@ object RenderUtils { if (drawVerticalBarriers) { GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(minX, minY, maxZ).endVertex() + } tessellator.draw() worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() + } tessellator.draw() } GlStateManager.color( @@ -148,16 +152,20 @@ object RenderUtils { //x worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() + worldRenderer.pos(minX, minY, minZ).endVertex() + } tessellator.draw() worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + } tessellator.draw() GlStateManager.color( c.red / 255f * 0.9f, @@ -167,16 +175,20 @@ object RenderUtils { ) //z worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(minX, minY, minZ).endVertex() + } tessellator.draw() worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, maxZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, maxZ).endVertex() + } tessellator.draw() GlStateManager.enableTexture2D() GlStateManager.enableCull() @@ -539,7 +551,7 @@ object RenderUtils { GlStateManager.translate(getAbsX().toFloat(), (getAbsY() + offsetY).toFloat(), 0F) var offsetX = 0 for (any in line) { - val renderable = Renderable.fromAny(any, itemScale = itemScale) ?: throw RuntimeException("Unknown render object: ${any}") + val renderable = Renderable.fromAny(any, itemScale = itemScale) ?: throw RuntimeException("Unknown render object: $any") renderable.render(getAbsX() + offsetX, getAbsY() + offsetY) offsetX += renderable.width diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index a0b6e91d8..8e3cbf78b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -19,6 +19,7 @@ object TimeUtils { duration.inWholeMilliseconds - 999, biggestUnit, showMilliSeconds, longName, maxUnits ) + @Deprecated("Use kotlin.time.Duration instead!") fun formatDuration( millis: Long, biggestUnit: TimeUnit = TimeUnit.YEAR, |