diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java | 22 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt | 20 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt | 12 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/ShyCruxWarnings.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt) | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt | 119 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java | 10 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 107 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt | 26 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt | 13 |
11 files changed, 289 insertions, 50 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 9739e4aa5..c033b886c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -95,7 +95,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.19.Beta.1", + version = "0.19.Beta.2", ) class SkyHanniMod { @Mod.EventHandler @@ -305,8 +305,9 @@ class SkyHanniMod { loadModule(GhostCounter) loadModule(RiftTimer()) loadModule(HighlightRiftGuide()) - loadModule(CruxWarnings()) + loadModule(ShyCruxWarnings()) loadModule(RiftLarva()) + loadModule(VoltHighlighter()) loadModule(RiftOdonata()) loadModule(RiftAgaricusCap()) loadModule(EnigmaSoulWaypoints) 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 8cff848fd..a32d8bf84 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -47,6 +47,28 @@ public class RiftConfig { "Useful if you play without volume.") @ConfigEditorBoolean public boolean shyWarning = true; + + + @Expose + @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.") + @ConfigEditorBoolean + public boolean voltRange = true; + + @Expose + @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 color", desc = "Change the color of the volt enemy depending on their mood.") + @ConfigEditorBoolean + public boolean voltMoodMeter = false; + } @ConfigOption(name = "Larvas", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt new file mode 100644 index 000000000..9d7bfd3a9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.entity.Entity +import net.minecraft.item.ItemStack + +data class EntityEquipmentChangeEvent( + val entity: Entity, + 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 + val EQUIPMENT_SLOT_LEGGINGS = 2 + val EQUIPMENT_SLOT_FEET = 1 + val EQUIPMENT_SLOT_HAND = 0 + } +}
\ No newline at end of file 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 3dbba1cfb..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 @@ -117,6 +117,9 @@ object UpdateManager { CurrentVersion.ofTag(SkyHanniMod.version), SkyHanniMod.MODID, ) + init { + context.cleanup() + } enum class UpdateState { AVAILABLE, diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt index 3901d8370..fb43a5faf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.features.rift import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzActionBarEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -26,17 +25,6 @@ class RiftTimer { } @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - if (!isEnabled()) return - - val message = event.message - " §r§7You have §r§a(?<time>.*)ф §r§7left before the rift collapses!".toPattern().matchMatcher(message) { - val time = group("time") - maxTime = getTime(time) - } - } - - @SubscribeEvent fun onActionBar(event: LorenzActionBarEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/ShyCruxWarnings.kt index 39834a6bd..0b7f60d30 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/ShyCruxWarnings.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CruxWarnings { +class ShyCruxWarnings { private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!") @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt new file mode 100644 index 000000000..4b03e9b6c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt @@ -0,0 +1,119 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +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.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SpecialColour +import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.item.ItemStack +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + +class VoltHighlighter { + private val config get() = SkyHanniMod.feature.rift.crux + + private val LIGHTNING_DISTANCE = 7F + private val ARMOR_SLOT_HEAD = 3 + private val CHARGE_TIME = 12.seconds + private var chargingSince = mapOf<Entity, SimpleTimeMark>() + + @SubscribeEvent + fun onArmorChange(event: EntityEquipmentChangeEvent) { + if (!RiftAPI.inRift() || !config.voltWarning) return + val player = Minecraft.getMinecraft().thePlayer ?: return + if (event.isHead && getVoltState(event.entity) == VoltState.DOING_LIGHTNING + && event.entity.positionVector.squareDistanceTo(player.positionVector) <= LIGHTNING_DISTANCE * LIGHTNING_DISTANCE + ) { + chargingSince = chargingSince.editCopy { + this[event.entity] = SimpleTimeMark.now() + } + } + } + + @SubscribeEvent + fun onRender(event: RenderWorldLastEvent) { + if (!RiftAPI.inRift() || !(config.voltRange || config.voltMoodMeter)) return + 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( + entity, when (state) { + VoltState.FRIENDLY -> 0x8000FF00.toInt() + VoltState.DOING_LIGHTNING -> 0x800000FF.toInt() + VoltState.HOSTILE -> 0x80FF0000.toInt() + else -> 0 + } + ) { config.voltMoodMeter } + if (state == VoltState.DOING_LIGHTNING && config.voltRange) { + RenderUtils.drawCylinderInWorld( + Color(SpecialColour.specialToChromaRGB(config.voltColour), true), + entity.posX, + entity.posY - 4f, + entity.posZ, + radius = LIGHTNING_DISTANCE, + partialTicks = event.partialTicks, + height = 20F + ) + val dischargingSince = chargingSince.getOrDefault(entity, SimpleTimeMark.farPast()) + val dischargeTimeLeft = CHARGE_TIME - dischargingSince.passedSince() + if (dischargeTimeLeft > Duration.ZERO) { + event.drawDynamicText( + event.exactLocation(entity).add(0.0, 2.5, 0.0), + "§eLightning: ${TimeUtils.formatDuration(dischargeTimeLeft, showMilliSeconds = true)}", + 2.5 + ) + } + } + } + } + + enum class VoltState { + NO_VOLT, + FRIENDLY, + HOSTILE, + DOING_LIGHTNING, + ; + } + + private fun getVoltState(itemStack: ItemStack): VoltState { + return when (itemStack.getSkullTexture()) { + "ewogICJ0aW1lc3RhbXAiIDogMTY3Mzg4MzU3MjAzNSwKICAicHJvZmlsZUlkIiA6ICI0MDU4NDhjMmJjNTE0ZDhkOThkOTJkMGIwYzhiZDQ0YiIsCiAgInByb2ZpbGVOYW1lIiA6ICJMb3ZlT3dPIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2UxYjFiZmI1MzZiNjQxNmIyNmEyODNkMmQ4YWQ0YjE3NzFiYmU1Yjc2ODk2ZTI3MjdkNWU4MzNiYzg5NDk4MmQiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==" -> { + VoltState.DOING_LIGHTNING + } + + "ewogICJ0aW1lc3RhbXAiIDogMTY3MzYzNzQ1OTAwOCwKICAicHJvZmlsZUlkIiA6ICJmMTA0NzMxZjljYTU0NmI0OTkzNjM4NTlkZWY5N2NjNiIsCiAgInByb2ZpbGVOYW1lIiA6ICJ6aWFkODciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2FlYTYyNTFlNThlM2QyMDU1MmEwMzVkNDI0NTYxZWFlZTA4M2ZlYWNkMWU2Y2IzYzJhNWNmOTQ1Y2U2ZDc2ZSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" -> { + VoltState.FRIENDLY + } + + "ewogICJ0aW1lc3RhbXAiIDogMTY3Mzg4MzEwNjAwMywKICAicHJvZmlsZUlkIiA6ICI5NTE3OTkxNjljYzE0MGY1OGM2MmRjOGZmZTU3NjBiZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJZdWFyaWciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGY5ZWRlOTcwZDQwYzViMjQ1Y2JkNjUxMzQ5ZWUxNjZmNjk1ZDI1MDM0NWY4ZjBlNjNmY2IxMGNmYjVhMmI3OCIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" -> { + VoltState.HOSTILE + } + + else -> VoltState.NO_VOLT + } + + } + + private fun getVoltState(entity: Entity): VoltState { + 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/mixins/transformers/MixinNetHandlerPlayClient.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java index bd4107369..8d2f6c5d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java @@ -1,15 +1,19 @@ package at.hannibal2.skyhanni.mixins.transformers; +import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent; import at.hannibal2.skyhanni.mixins.hooks.NetHandlerPlayClientHookKt; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.Entity; import net.minecraft.network.Packet; import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.server.S04PacketEntityEquipment; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(value = NetHandlerPlayClient.class, priority = 1001) public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient { @@ -21,4 +25,10 @@ public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient private void onSendPacket(Packet<?> packet, CallbackInfo ci) { NetHandlerPlayClientHookKt.onSendPacket(packet, ci); } + + @Inject(method = "handleEntityEquipment", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setCurrentItemOrArmor(ILnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) + public void onEntityEquipment(S04PacketEntityEquipment packetIn, CallbackInfo ci, Entity entity) { + new EntityEquipmentChangeEvent(entity, packetIn.getEquipmentSlot(), packetIn.getItemStack()).postAndCatch(); + } + } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 58e000ce7..69df66afa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -93,28 +93,56 @@ object RenderUtils { * @author Moulberry * @author Mojang */ - fun drawFilledBoundingBox(aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f) { + fun drawFilledBoundingBox( + aabb: AxisAlignedBB, + c: Color, + alphaMultiplier: Float = 1f, + /** + * If set to `true`, renders the box relative to the camera instead of relative to the world. + * If set to `false`, will be relativized to [RenderUtils.getViewerPos]. Setting this to `false` requires + * specifying [partialTicks]] + */ + renderRelativeToCamera: Boolean = true, + drawVerticalBarriers: Boolean = true, + partialTicks: Float = 0F, + ) { GlStateManager.enableBlend() GlStateManager.disableLighting() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) GlStateManager.disableTexture2D() + GlStateManager.disableCull() + val effectiveAABB = if (!renderRelativeToCamera) { + val vp = getViewerPos(partialTicks) + AxisAlignedBB( + aabb.minX - vp.x, aabb.minY - vp.y, aabb.minZ - vp.z, + aabb.maxX - vp.x, aabb.maxY - vp.y, aabb.maxZ - vp.z, + ) + } else { + aabb + } val tessellator = Tessellator.getInstance() val worldRenderer = tessellator.worldRenderer - GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) //vertical - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex() - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() - tessellator.draw() + if (drawVerticalBarriers) { + GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + 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) + 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( c.red / 255f * 0.8f, c.green / 255f * 0.8f, @@ -124,16 +152,20 @@ object RenderUtils { //x worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.minY, aabb.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(aabb.maxX, aabb.minY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.minY, aabb.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, @@ -143,18 +175,23 @@ object RenderUtils { ) //z worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.minY, aabb.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(aabb.minX, aabb.minY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() - worldRenderer.pos(aabb.minX, aabb.maxY, aabb.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() GlStateManager.disableBlend() } @@ -180,7 +217,7 @@ object RenderUtils { GlStateManager.enableTexture2D() GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0) GlStateManager.enableBlend() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) val time = Minecraft.getMinecraft().theWorld.totalWorldTime + partialTicks.toDouble() val d1 = MathHelper.func_181162_h( -time * 0.2 - MathHelper.floor_double(-time * 0.1) @@ -321,7 +358,7 @@ object RenderUtils { GlStateManager.disableLighting() GlStateManager.depthMask(false) GlStateManager.enableBlend() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) val tessellator = Tessellator.getInstance() val worldrenderer = tessellator.worldRenderer val i = 0 @@ -514,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 @@ -591,7 +628,7 @@ object RenderUtils { GlStateManager.enableBlend() GlStateManager.depthFunc(GL11.GL_LEQUAL) GlStateManager.disableCull() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) GlStateManager.enableAlpha() GlStateManager.disableTexture2D() color.bindColor() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt new file mode 100644 index 000000000..bd682b913 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt @@ -0,0 +1,26 @@ +package at.hannibal2.skyhanni.utils + +import java.time.Instant +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds + +@JvmInline +value class SimpleTimeMark(val millis: Long) { + operator fun minus(other: SimpleTimeMark) = + (millis - other.millis).milliseconds + + operator fun plus(other: Duration) = + SimpleTimeMark(millis + other.inWholeMilliseconds) + + fun passedSince() = if (millis == 0L) Duration.INFINITE else now() - this + + override fun toString(): String { + if (millis == 0L) return "The Far Past" + return Instant.ofEpochMilli(millis).toString() + } + + companion object { + fun now() = SimpleTimeMark(System.currentTimeMillis()) + fun farPast() = SimpleTimeMark(0) + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index f7cd79b40..a0b6e91d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -2,11 +2,23 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import kotlin.time.Duration object TimeUtils { private val pattern = "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?".toPattern() + + fun formatDuration( + duration: Duration, + biggestUnit: TimeUnit = TimeUnit.YEAR, + showMilliSeconds: Boolean = false, + longName: Boolean = false, + maxUnits: Int = -1 + ): String = formatDuration( + duration.inWholeMilliseconds - 999, biggestUnit, showMilliSeconds, longName, maxUnits + ) + fun formatDuration( millis: Long, biggestUnit: TimeUnit = TimeUnit.YEAR, @@ -14,6 +26,7 @@ object TimeUtils { longName: Boolean = false, maxUnits: Int = -1 ): String { + // TODO: if this weird offset gets removed, also remove that subtraction from formatDuration(kotlin.time.Duration) var milliseconds = millis + 999 val map = mutableMapOf<TimeUnit, Int>() for (unit in TimeUnit.values()) { |