aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-16 00:41:34 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-16 00:41:34 +0200
commitf3799c580bcb6b7c6d139796f2dc8b84c7b0e644 (patch)
tree28152226437df4fc4ed50b7649712e795529d3dd /src/main
parent478a41184ea08a490f5d6834ea8019dc10f769b1 (diff)
downloadskyhanni-f3799c580bcb6b7c6d139796f2dc8b84c7b0e644.tar.gz
skyhanni-f3799c580bcb6b7c6d139796f2dc8b84c7b0e644.tar.bz2
skyhanni-f3799c580bcb6b7c6d139796f2dc8b84c7b0e644.zip
Added Inventory Numbers - Show the number of the teleport pads inside the 'Change Destination' inventory as stack size
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenTeleportPadInventoryNumber.kt83
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt5
4 files changed, 94 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 100076625..b645d6e69 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -32,10 +32,7 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterDisplay;
import at.hannibal2.skyhanni.features.garden.composter.ComposterInventoryNumbers;
import at.hannibal2.skyhanni.features.garden.composter.GardenComposterInventoryFeatures;
import at.hannibal2.skyhanni.features.garden.farming.*;
-import at.hannibal2.skyhanni.features.garden.inventory.GardenDeskInSBMenu;
-import at.hannibal2.skyhanni.features.garden.inventory.GardenInventoryNumbers;
-import at.hannibal2.skyhanni.features.garden.inventory.GardenNextPlotPrice;
-import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice;
+import at.hannibal2.skyhanni.features.garden.inventory.*;
import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames;
import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures;
import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer;
@@ -271,6 +268,7 @@ public class SkyHanniMod {
loadModule(new ToolTooltipTweaks());
loadModule(new CropSpeedMeter());
loadModule(new AshfangMinisNametagHider());
+ loadModule(new GardenTeleportPadInventoryNumber());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index 0341b341a..79657ae5b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -726,6 +726,12 @@ public class Garden {
public boolean teleportPadsCompactName = false;
@Expose
+ @ConfigOption(name = "Inventory Numbers", desc = "Show the number of the teleport pads inside the 'Change Destination' inventory as stack size.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 19)
+ public boolean teleportPadsInventoryNumbers = false;
+
+ @Expose
@ConfigOption(name = "Anita Medal Profit", desc = "")
@ConfigEditorAccordion(id = 16)
public boolean anitaMedalProfit = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenTeleportPadInventoryNumber.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenTeleportPadInventoryNumber.kt
new file mode 100644
index 000000000..757e03a62
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenTeleportPadInventoryNumber.kt
@@ -0,0 +1,83 @@
+package at.hannibal2.skyhanni.features.garden.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent
+import at.hannibal2.skyhanni.features.garden.GardenAPI
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class GardenTeleportPadInventoryNumber {
+ private val numbers: Map<String, Int> by lazy {
+ val baseNumber = mapOf(
+ "one" to 1,
+ "two" to 2,
+ "three" to 3,
+ "four" to 4,
+ "five" to 5,
+ "six" to 6,
+ "seven" to 7,
+ "eight" to 8,
+ "nine" to 9,
+ "ten" to 10,
+ "eleven" to 11,
+ "twelve" to 12,
+ "thirteen" to 13,
+ "fourteen" to 14,
+ "fifteen" to 15,
+ "sixteen" to 16,
+ "seventeen" to 17,
+ "eighteen" to 18,
+ "nineteen" to 19,
+ )
+ val multipliers = mapOf(
+ "twenty" to 20,
+ "thirty" to 30,
+ "forty" to 40,
+ "fifty" to 50,
+ "sixty" to 60,
+ "seventy" to 70,
+ "eighty" to 80,
+ "ninety" to 90,
+ )
+
+ val result = mutableMapOf<String, Int>()
+ for (entry in baseNumber) {
+ result[entry.key] = entry.value
+ }
+
+ for ((multiplyText, multiplyNumber) in multipliers) {
+ result[multiplyText] = multiplyNumber
+ for ((baseText, number) in baseNumber) {
+ if (number > 9) continue
+ result[multiplyText + baseText] = multiplyNumber + number
+ }
+ }
+ result
+ }
+
+ private var inTeleportPad = false
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ inTeleportPad = event.inventoryName == "Set Destination" && SkyHanniMod.feature.garden.teleportPadsInventoryNumbers
+ }
+
+ @SubscribeEvent
+ fun onRenderItemTip(event: RenderInventoryItemTipEvent) {
+ if (!GardenAPI.inGarden()) return
+ if (!inTeleportPad) return
+
+ val name = event.stack.name?.lowercase() ?: return
+ val pattern = "ยง.(.*) teleport pad".toPattern()
+
+ val matcher = pattern.matcher(name)
+ if (!matcher.matches()) return
+ val text = matcher.group(1)
+
+ numbers[text]?.let {
+ event.stackTip = "$it"
+ return
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 480d08341..17823d52a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.SBInfo
import net.minecraft.client.Minecraft
+import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.network.play.client.C02PacketUseEntity
@@ -566,9 +567,9 @@ class GardenVisitorFeatures {
var inSacks: Boolean = false,
val items: MutableMap<String, Int> = mutableMapOf(),
) {
- fun getEntity() = Minecraft.getMinecraft().theWorld.getEntityByID(entityId)
+ fun getEntity(): Entity? = Minecraft.getMinecraft().theWorld.getEntityByID(entityId)
- fun getNameTagEntity() = Minecraft.getMinecraft().theWorld.getEntityByID(nameTagEntityId)
+ fun getNameTagEntity(): Entity? = Minecraft.getMinecraft().theWorld.getEntityByID(nameTagEntityId)
}
enum class VisitorStatus(val displayName: String, val color: Int) {