From b8e54dd10bb6383d11d15863c2d90c0cabd7ee2e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 10 Jul 2023 17:18:09 +0200 Subject: Adding Motes NPC price to item lore --- .../at/hannibal2/skyhanni/features/rift/RiftAPI.kt | 11 ++++++++ .../features/rift/ShowMotesNpcSellPrice.kt | 29 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift') diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt index ea2f929e6..e0ff66926 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt @@ -1,8 +1,19 @@ package at.hannibal2.skyhanni.features.rift +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.RiftConfig import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.item.ItemStack object RiftAPI { fun inRift() = LorenzUtils.inIsland(IslandType.THE_RIFT) + + val config: RiftConfig get() = SkyHanniMod.feature.rift + + // internal name -> motes + var motesPrice = emptyMap() + + fun ItemStack.motesNpcPrice() = motesPrice[getInternalName()] } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt new file mode 100644 index 000000000..41fb1f0b5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt @@ -0,0 +1,29 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ShowMotesNpcSellPrice { + + @SubscribeEvent + fun onItemTooltipLow(event: ItemTooltipEvent) { +// if (!SkyHanniMod.feature.dev.showInternalName) return + + if (!isEnabled()) return + + val itemStack = event.itemStack ?: return + + val motesPerItem = itemStack.motesNpcPrice() ?: return + val size = itemStack.stackSize + if (size > 1) { + val motes = motesPerItem * size + event.toolTip.add("§6NPC price: §d${motes.addSeparators()} Motes §7($size x §d${motesPerItem.addSeparators()} Motes§7)") + } else { + event.toolTip.add("§6NPC price: §d${motesPerItem.addSeparators()} Motes") + } + } + + fun isEnabled() = RiftAPI.inRift() && RiftAPI.config.showMotesPrice +} -- cgit