diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-05-03 19:20:39 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 11:20:39 +0200 |
commit | 897c06d368471e2d3de88bcc95a427579c3e7150 (patch) | |
tree | 63f6dda5abf3017d633c8f9064e0d943221cb614 | |
parent | c18aa60c33a8d70938c023ccef79bd4666b1921b (diff) | |
download | NotEnoughUpdates-897c06d368471e2d3de88bcc95a427579c3e7150.tar.gz NotEnoughUpdates-897c06d368471e2d3de88bcc95a427579c3e7150.tar.bz2 NotEnoughUpdates-897c06d368471e2d3de88bcc95a427579c3e7150.zip |
Fix insta buy warning not working with long item names (#1139)
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarPriceWarning.kt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarPriceWarning.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarPriceWarning.kt index 8dc656ba..1779611a 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarPriceWarning.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarPriceWarning.kt @@ -27,6 +27,7 @@ import io.github.moulberry.notenoughupdates.util.ItemUtils import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.init.Items import net.minecraft.inventory.Slot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -44,8 +45,16 @@ class BazaarPriceWarning : WarningPopUp() { val limit get() = NotEnoughUpdates.INSTANCE.config.bazaarTweaks.bazaarOverpayWarning @SubscribeEvent fun onClick(event: SlotClickEvent) { - if (!Utils.getOpenChestName().contains("Instant Buy")) - return + val openSlots = Minecraft.getMinecraft().thePlayer?.openContainer?.inventorySlots ?: return + if (openSlots.size < 17) return + //both insta buy and buy order screens have this sign + //we check the name of the buy order page and return if its that + //however the custom amount insta buy page doesnt have a sign so we also have to check its title + val signStack = openSlots[16]?.stack ?: return + if ((signStack.item != Items.sign || + ItemUtils.getDisplayName(signStack) != "§aCustom Amount" || + Utils.getOpenChestName().contains("How many do you want?")) && + !Utils.getOpenChestName().contains("Confirm Instant Buy")) return if (shouldShow()) return val stack = event.slot.stack ?: return val lore = ItemUtils.getLore(stack) |