From d3cd3c4ff4c51a8f047d396fb5edbb7cf523ca84 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 7 Apr 2024 14:23:06 +0200 Subject: Improvement: fillTable now uses Renderable.table (#1376) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/garden/AnitaMedalProfit.kt | 28 ++++++++++++++-------- .../garden/inventory/SkyMartCopperPrice.kt | 17 +++++++------ 2 files changed, 26 insertions(+), 19 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') 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 84ca5b235..497932ae4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils @@ -14,20 +13,21 @@ 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.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils.fillTable +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AnitaMedalProfit { private val config get() = GardenAPI.config.anitaShop - private var display = emptyList>() + private var display = emptyList() companion object { @@ -70,9 +70,9 @@ class AnitaMedalProfit { } } - val newList = mutableListOf>() - newList.addAsSingletonList("§eMedal Profit") - newList.fillTable(table) + val newList = mutableListOf() + newList.add(Renderable.string("§eMedal Profit")) + newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = 1.7)) display = newList } @@ -108,7 +108,16 @@ class AnitaMedalProfit { "§7Material cost: §6${NumberUtil.format(fullCost)} ", "§7Final profit: §6${profitFormat} ", ) - table.add(DisplayTableEntry(itemName, "$color$profitFormat", profit, internalName, hover, highlightsOnHoverSlots = listOf(slot))) + table.add( + DisplayTableEntry( + itemName, + "$color$profitFormat", + profit, + internalName, + hover, + highlightsOnHoverSlots = listOf(slot) + ) + ) } private fun getItemName(item: ItemStack): String? { @@ -167,10 +176,9 @@ class AnitaMedalProfit { @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (inInventory) { - config.medalProfitPos.renderStringsAndItems( + config.medalProfitPos.renderRenderables( display, extraSpace = 5, - itemScale = 1.7, posLabel = "Anita Medal Profit" ) } 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 9e5ec780c..29623653b 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 @@ -5,20 +5,20 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.DisplayTableEntry 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.fillTable +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +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 net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -30,7 +30,7 @@ class SkyMartCopperPrice { "§c(?.*) Copper" ) - private var display = emptyList>() + private var display = emptyList() private val config get() = GardenAPI.config.skyMart companion object { @@ -97,9 +97,9 @@ class SkyMartCopperPrice { } } - val newList = mutableListOf>() - newList.addAsSingletonList("§eCoins per Copper§f:") - newList.fillTable(table) + val newList = mutableListOf() + newList.add(Renderable.string("§eCoins per Copper§f:")) + newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = config.itemScale)) display = newList } @@ -111,10 +111,9 @@ class SkyMartCopperPrice { @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (inInventory) { - config.copperPricePos.renderStringsAndItems( + config.copperPricePos.renderRenderables( display, extraSpace = 5, - itemScale = config.itemScale, posLabel = "SkyMart Copper Price" ) } -- cgit