diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-04-08 20:27:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 20:27:38 +0200 |
commit | 4aaf4295152d211b1c8853a173cc4cf6a9d000a2 (patch) | |
tree | 9ebd0a44cad5329bdd2452e99395e7cc7ba16f41 /src/main/java/at | |
parent | 451a9b5636c113d1da15fc6419ea99f306f66e55 (diff) | |
download | skyhanni-4aaf4295152d211b1c8853a173cc4cf6a9d000a2.tar.gz skyhanni-4aaf4295152d211b1c8853a173cc4cf6a9d000a2.tar.bz2 skyhanni-4aaf4295152d211b1c8853a173cc4cf6a9d000a2.zip |
Fix/Backend: Renderable.itemStack itemScale (#1390)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
15 files changed, 163 insertions, 89 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 26ce3dfbc..9de3e4eba 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -11,7 +11,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 31 + const val CONFIG_VERSION = 32 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java index be8d085a7..60dbf508e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java @@ -67,6 +67,9 @@ public class DevConfig { public Position debugLocationPos = new Position(1, 160, false, true); @Expose + public Position debugItemPos = new Position(90, 70); + + @Expose @Category(name = "Minecraft Console", desc = "Minecraft Console Settings") public MinecraftConsoleConfig minecraftConsoles = new MinecraftConsoleConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java index 2673aa246..e172fcefd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java @@ -17,7 +17,7 @@ public class SkyMartConfig { @Expose @ConfigOption(name = "Item Scale", desc = "Change the size of the items.") @ConfigEditorSlider(minValue = 0.3f, maxValue = 5, minStep = 0.1f) - public double itemScale = 1.7; + public double itemScale = 1; @Expose public Position copperPricePos = new Position(211, 132, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 01712fec4..c80573e32 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -64,7 +64,7 @@ object BestiaryData { if (!isEnabled()) return if (inInventory) { config.position.renderStringsAndItems( - display, extraSpace = -1, itemScale = 1.3, posLabel = "Bestiary Data" + display, extraSpace = -1, itemScale = 0.7, posLabel = "Bestiary Data" ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index 497932ae4..e6d78b25e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -72,7 +72,7 @@ class AnitaMedalProfit { val newList = mutableListOf<Renderable>() newList.add(Renderable.string("§eMedal Profit")) - newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = 1.7)) + newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = 0.7)) display = newList } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 9fba9db86..8377c5777 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -494,7 +494,7 @@ object GardenNextJacobContest { if (display.isEmpty()) { config.pos.renderStrings(simpleDisplay, posLabel = "Garden Next Jacob Contest") } else { - config.pos.renderSingleLineWithItems(display, 1.7, posLabel = "Garden Next Jacob Contest") + config.pos.renderSingleLineWithItems(display, 1.0, posLabel = "Garden Next Jacob Contest") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 29623653b..adedbb150 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull @@ -20,6 +21,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import com.google.gson.JsonPrimitive import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -93,7 +95,16 @@ class SkyMartCopperPrice { add("§7Copper amount: §c${copper.addSeparators()} ") add("§7Profit per copper: §6${perFormat} ") } - table.add(DisplayTableEntry("$itemName§f:", "§6§l$perFormat", factor, internalName, hover, highlightsOnHoverSlots = listOf(slot))) + table.add( + DisplayTableEntry( + "$itemName§f:", + "§6§l$perFormat", + factor, + internalName, + hover, + highlightsOnHoverSlots = listOf(slot) + ) + ) } } @@ -126,5 +137,8 @@ class SkyMartCopperPrice { event.move(3, "garden.skyMartCopperPrice", "garden.skyMart.copperPrice") event.move(3, "garden.skyMartCopperPriceAdvancedStats", "garden.skyMart.copperPriceAdvancedStats") event.move(3, "garden.skyMartCopperPricePos", "garden.skyMart.copperPricePos") + event.transform(32, "garden.skyMart.itemScale") { + JsonPrimitive((it.asDouble / 1.851).round(1)) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index f0b1418ba..80d3c390a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -52,7 +52,7 @@ class ChestValue { config.position.renderStringsAndItems( display, extraSpace = -1, - itemScale = 1.3, + itemScale = 0.7, posLabel = "Estimated Chest Value" ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 54063b835..9d9c98115 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -38,7 +38,7 @@ object SackDisplay { if (SackAPI.inSackInventory) { if (!isEnabled()) return config.position.renderStringsAndItems( - display, extraSpace = config.extraSpace, itemScale = 1.3, posLabel = "Sacks Items" + display, extraSpace = config.extraSpace, itemScale = 0.7, posLabel = "Sacks Items" ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index 88269a643..f5f0ac58a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -46,7 +46,7 @@ class ShowMotesNpcSellPrice { if (inInventory) { config.inventoryValue.position.renderStringsAndItems( display, - itemScale = 1.3, + itemScale = 0.7, posLabel = "Inventory Motes Value" ) } @@ -146,7 +146,14 @@ class ShowMotesNpcSellPrice { add("") add("§6Total value: §d$price coins") } - add(Renderable.hoverTips("§6${stack.displayName}: §b$price", tips, highlightsOnHoverSlots = index, stack = stack)) + add( + Renderable.hoverTips( + "§6${stack.displayName}: §b$price", + tips, + highlightsOnHoverSlots = index, + stack = stack + ) + ) }) } val total = itemMap.values.fold(0.0) { acc, pair -> acc + pair.second }.formatPrice() diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index a4b36db3b..4ece06c55 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull @@ -30,6 +31,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzDebug import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -41,12 +43,18 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.Renderable.Companion.renderBounds import kotlinx.coroutines.launch import net.minecraft.client.Minecraft +import net.minecraft.init.Blocks +import net.minecraft.init.Items +import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -482,6 +490,11 @@ class SkyHanniDebugsAndTests { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return + @Suppress("ConstantConditionIf") + if (false) { + itemRenderDebug() + } + if (Minecraft.getMinecraft().gameSettings.showDebugInfo && debugConfig.currentAreaDebug) { config.debugLocationPos.renderString( "Current Area: ${HypixelData.skyBlockArea}", @@ -497,6 +510,34 @@ class SkyHanniDebugsAndTests { config.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") } + private fun itemRenderDebug() { + val scale = 0.1 + val renderables = listOf( + ItemStack(Blocks.glass_pane), ItemStack(Items.diamond_sword), ItemStack(Items.skull), + ItemStack(Blocks.melon_block) + ).map { item -> + generateSequence(scale) { it + 0.1 }.take(25).map { + Renderable.itemStack(item, it, xSpacing = 0).renderBounds() + }.toList() + }.editCopy { + this.add( + 0, + generateSequence(scale) { it + 0.1 }.take(25).map { Renderable.string(it.round(1).toString()) }.toList() + ) + } + config.debugItemPos.renderRenderables( + listOf( + Renderable.table(renderables), + Renderable.horizontalContainer( + listOf( + Renderable.string("Test:").renderBounds(), + Renderable.itemStack(ItemStack(Items.diamond_sword)).renderBounds() + ), spacing = 1 + ) + ), posLabel = "Item Debug" + ) + } + @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { // val particleType = event.type diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 40f6a9c94..d0064c4b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -170,7 +170,11 @@ object LorenzUtils { fun getPlayerName(): String = Minecraft.getMinecraft().thePlayer.name - fun fillTable(data: List<DisplayTableEntry>, padding: Int = 1, itemScale: Double = 1.0): Renderable { + fun fillTable( + data: List<DisplayTableEntry>, + padding: Int = 1, + itemScale: Double = NEUItems.itemFontSize, + ): Renderable { val sorted = data.sortedByDescending { it.sort } val outerList = mutableListOf<List<Renderable>>() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index ce834e28c..0dea5fac5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -159,22 +159,24 @@ object NEUItems { fun isVanillaItem(item: ItemStack): Boolean = manager.auctionManager.isVanillaItem(item.getInternalName().asString()) - fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = 1.0) { + const val itemFontSize = 2.0 / 3.0 + + fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = itemFontSize) { val item = checkBlinkItem() val isSkull = item.item === Items.skull - val baseScale = (if (isSkull) 0.8f else 0.6f) + val baseScale = (if (isSkull) 4f / 3f else 1f) val finalScale = baseScale * scaleMultiplier - val diff = ((finalScale - baseScale) * 10).toFloat() val translateX: Float val translateY: Float if (isSkull) { - translateX = x - 2 - diff - translateY = y - 2 - diff + val skulldiff = ((scaleMultiplier) * 2.5).toFloat() + translateX = x - skulldiff + translateY = y - skulldiff } else { - translateX = x - diff - translateY = y - diff + translateX = x + translateY = y } GlStateManager.pushMatrix() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index f38354f17..4e8f41757 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -528,7 +528,7 @@ object RenderUtils { fun Position.renderStringsAndItems( list: List<List<Any?>>, extraSpace: Int = 0, - itemScale: Double = 1.0, + itemScale: Double = NEUItems.itemFontSize, posLabel: String, ) { if (list.isEmpty()) return @@ -556,13 +556,17 @@ object RenderUtils { * Accepts a single line to print. * This line is a list of things to print. Can print String or ItemStack objects. */ - fun Position.renderSingleLineWithItems(list: List<Any?>, itemScale: Double = 1.0, posLabel: String) { + fun Position.renderSingleLineWithItems( + list: List<Any?>, + itemScale: Double = NEUItems.itemFontSize, + posLabel: String + ) { if (list.isEmpty()) return val longestX = renderLine(list, 0, itemScale) GuiEditManager.add(this, posLabel, longestX, 10) } - private fun Position.renderLine(line: List<Any?>, offsetY: Int, itemScale: Double = 1.0): Int { + private fun Position.renderLine(line: List<Any?>, offsetY: Int, itemScale: Double = NEUItems.itemFontSize): Int { GlStateManager.pushMatrix() val (x, y) = transform() GlStateManager.translate(0f, offsetY.toFloat(), 0F) @@ -739,9 +743,11 @@ object RenderUtils { worldrenderer.pos(x1, y1, z1).endVertex() worldrenderer.pos(x2, y2, z2).endVertex() - val x3 = x + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val x3 = + x + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) val y3 = y + radius * cos(Math.PI * (phi + 1) / segments) - val z3 = z + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val z3 = + z + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) val x4 = x + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) val y4 = y + radius * cos(Math.PI * phi / segments) @@ -800,9 +806,11 @@ object RenderUtils { val y2 = y + radius * cos(Math.PI * (phi + 1) / segments) val z2 = z + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * theta / (segments * 2)) - val x3 = x + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val x3 = + x + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) val y3 = y + radius * cos(Math.PI * (phi + 1) / segments) - val z3 = z + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val z3 = + z + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) val x4 = x + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) val y4 = y + radius * cos(Math.PI * phi / segments) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 3b1249808..542b62c42 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.ColorUtils import at.hannibal2.skyhanni.utils.ColorUtils.darker import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment @@ -18,8 +19,8 @@ import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.calculateTableYOf import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned -import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.notenoughupdates.util.Utils +import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper import net.minecraft.client.Minecraft import net.minecraft.client.gui.Gui import net.minecraft.client.gui.inventory.GuiEditSign @@ -39,8 +40,7 @@ interface Renderable { val horizontalAlign: HorizontalAlignment val verticalAlign: VerticalAlignment fun isHovered(posX: Int, posY: Int) = currentRenderPassMousePosition?.let { (x, y) -> - x in (posX..posX + width) - && y in (posY..posY + height) // TODO: adjust for variable height? + x in (posX..posX + width) && y in (posY..posY + height) // TODO: adjust for variable height? } ?: false /** @@ -65,7 +65,7 @@ interface Renderable { } } - fun fromAny(any: Any?, itemScale: Double = 1.0): Renderable? = when (any) { + fun fromAny(any: Any?, itemScale: Double = NEUItems.itemFontSize): Renderable? = when (any) { null -> placeholder(12) is Renderable -> any is String -> string(any) @@ -81,8 +81,7 @@ interface Renderable { onClick: () -> Unit, bypassChecks: Boolean = false, condition: () -> Boolean = { true }, - ): Renderable = - link(string(text), onClick, bypassChecks, condition) + ): Renderable = link(string(text), onClick, bypassChecks, condition) fun link( renderable: Renderable, @@ -119,28 +118,25 @@ interface Renderable { button: Int = 0, bypassChecks: Boolean = false, condition: () -> Boolean = { true }, - ) = - object : Renderable { - override val width = render.width - override val height = render.height - override val horizontalAlign = render.horizontalAlign - override val verticalAlign = render.verticalAlign + ) = object : Renderable { + override val width = render.width + override val height = render.height + override val horizontalAlign = render.horizontalAlign + override val verticalAlign = render.verticalAlign - private var wasDown = false + private var wasDown = false - override fun render(posX: Int, posY: Int) { - val isDown = Mouse.isButtonDown(button) - if (isDown > wasDown && isHovered(posX, posY) && condition() && shouldAllowLink( - true, - bypassChecks - ) - ) { - onClick() - } - wasDown = isDown - render.render(posX, posY) + override fun render(posX: Int, posY: Int) { + val isDown = Mouse.isButtonDown(button) + if (isDown > wasDown && isHovered(posX, posY) && condition() && + shouldAllowLink(true, bypassChecks) + ) { + onClick() } + wasDown = isDown + render.render(posX, posY) } + } fun hoverTips( content: Any, @@ -248,43 +244,40 @@ interface Renderable { unhovered: Renderable, bypassChecks: Boolean = false, condition: () -> Boolean = { true }, - ) = - object : Renderable { - override val width: Int - get() = max(hovered.width, unhovered.width) - override val height = 10 - override val horizontalAlign get() = if (isHovered) hovered.horizontalAlign else unhovered.horizontalAlign - override val verticalAlign get() = if (isHovered) hovered.verticalAlign else unhovered.verticalAlign + ) = object : Renderable { + override val width: Int + get() = max(hovered.width, unhovered.width) + override val height = 10 + override val horizontalAlign get() = if (isHovered) hovered.horizontalAlign else unhovered.horizontalAlign + override val verticalAlign get() = if (isHovered) hovered.verticalAlign else unhovered.verticalAlign - var isHovered = false + var isHovered = false - override fun render(posX: Int, posY: Int) { - isHovered = if (isHovered(posX, posY) && condition() && shouldAllowLink(true, bypassChecks)) { - hovered.render(posX, posY) - true - } else { - unhovered.render(posX, posY) - false - } + override fun render(posX: Int, posY: Int) { + isHovered = if (isHovered(posX, posY) && condition() && shouldAllowLink(true, bypassChecks)) { + hovered.render(posX, posY) + true + } else { + unhovered.render(posX, posY) + false } } + } fun itemStack( - any: ItemStack, - scale: Double = 1.0, + item: ItemStack, + scale: Double = NEUItems.itemFontSize, + xSpacing: Int = 2, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, - verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + verticalAlign: VerticalAlignment = VerticalAlignment.CENTER, ) = object : Renderable { - override val width: Int - get() = 12 - override val height = 10 + override val width = (15.5 * scale + 1.5).toInt() + xSpacing + override val height = (15.5 * scale + 1.5).toInt() override val horizontalAlign = horizontalAlign override val verticalAlign = verticalAlign override fun render(posX: Int, posY: Int) { - GlStateManager.pushMatrix() - any.renderOnScreen(0F, 0F, scaleMultiplier = scale) - GlStateManager.popMatrix() + item.renderOnScreen(xSpacing / 2.0f, 0F, scaleMultiplier = scale) } } @@ -297,7 +290,7 @@ interface Renderable { scale: Double = 1.0, color: Color = Color.WHITE, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, - verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + verticalAlign: VerticalAlignment = VerticalAlignment.CENTER, ) = object : Renderable { override val width by lazy { (Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) * scale).toInt() + 1 } @@ -449,18 +442,12 @@ interface Renderable { } } else { val (textureX, textureY) = if (texture == SkillProgressBarConfig.TexturedBar.UsedTexture.MATCH_PACK) Pair( - 0, - 64 + 0, 64 ) else Pair(0, 0) Minecraft.getMinecraft().renderEngine.bindTexture(ResourceLocation(texture.path)) Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect( - posX, - posY, - textureX, - textureY, - width, - height + posX, posY, textureX, textureY, width, height ) if (useChroma) { @@ -470,12 +457,7 @@ interface Renderable { GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f) } Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect( - posX, - posY, - textureX, - textureY + height, - progress, - height + posX, posY, textureX, textureY + height, progress, height ) if (useChroma) { @@ -485,6 +467,19 @@ interface Renderable { } } + fun Renderable.renderBounds(color: Color = LorenzColor.GREEN.toColor()) = object : Renderable { + override val width = this@renderBounds.width + override val height = this@renderBounds.height + override val horizontalAlign = this@renderBounds.horizontalAlign + override val verticalAlign = this@renderBounds.verticalAlign + + override fun render(posX: Int, posY: Int) { + Gui.drawRect(0, 0, width, height, color.rgb) + this@renderBounds.render(posX, posY) + } + + } + fun fixedSizeLine( content: Renderable, width: Int, |