aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-04-04 20:13:29 +0200
committerGitHub <noreply@github.com>2023-04-04 20:13:29 +0200
commita01bce903164749a0574210d1e6958ecd4090a5c (patch)
tree5852f92f8dab801ab232da5bca0e527c2018b6b5
parentbe5d92abdeeaa03cd201065b46e90a843f1663ba (diff)
downloadNotEnoughUpdates-a01bce903164749a0574210d1e6958ecd4090a5c.tar.gz
NotEnoughUpdates-a01bce903164749a0574210d1e6958ecd4090a5c.tar.bz2
NotEnoughUpdates-a01bce903164749a0574210d1e6958ecd4090a5c.zip
Check for buyback slots in npc shop exporter (#662)
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java1
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt10
2 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java
index 90ef93bb..ab1a6516 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java
@@ -32,6 +32,7 @@ public enum NEUDebugFlag {
MAP("Dungeon Map Player Information"),
SEARCH("SearchString Matches"),
API_CACHE("Api Cache"),
+ ALWAYS_EXPORT_SHOPS("Always export shops even without buy back slot"),
;
private final String description;
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt
index e2673125..9cf98e25 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt
@@ -20,6 +20,7 @@
package io.github.moulberry.notenoughupdates.recipes.generators
import com.google.auto.service.AutoService
+import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag
import io.github.moulberry.notenoughupdates.recipes.Ingredient
import io.github.moulberry.notenoughupdates.recipes.ItemShopRecipe
import io.github.moulberry.notenoughupdates.util.ItemUtils
@@ -131,7 +132,14 @@ class ItemShopExporter : RepoExporter {
}
override fun canExport(gui: GuiScreen): Boolean {
- return gui is GuiChest
+ if (NEUDebugFlag.ALWAYS_EXPORT_SHOPS.isSet) return true
+ if (gui !is GuiChest) return false
+ val buyBackSlot = 4 + 9 * 5
+ val stacks = gui.inventorySlots.inventory
+ if (buyBackSlot !in stacks.indices) return false
+ val buyBackStack = stacks[buyBackSlot] ?: return false
+ return Utils.cleanColour(buyBackStack.displayName) == "Sell Item" ||
+ ItemUtils.getLore(buyBackStack).any { Utils.cleanColour(it) == "Click to buyback!" }
}
override val name: String