aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiZe_ <superhize@hotmail.com>2023-06-04 13:13:06 +0200
committerGitHub <noreply@github.com>2023-06-04 13:13:06 +0200
commitfe815d80f1d995ebaa65c52da8f9efd9bf166cf3 (patch)
tree59ec51851c148de7444a170575422f44c0ab7b23 /src
parent0d8183794b3342e7cc0a1f306612c18d10952693 (diff)
downloadskyhanni-fe815d80f1d995ebaa65c52da8f9efd9bf166cf3.tar.gz
skyhanni-fe815d80f1d995ebaa65c52da8f9efd9bf166cf3.tar.bz2
skyhanni-fe815d80f1d995ebaa65c52da8f9efd9bf166cf3.zip
Pocket sack in a sack display (#193)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt8
5 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index f7361ad5f..a5a2ffcff 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -288,6 +288,7 @@ class SkyHanniMod {
loadModule(ServerRestartTitle())
loadModule(CityProjectFeatures())
loadModule(GardenPlotIcon)
+ loadModule(PocketSackInASackDisplay())
loadModule(ShowFishingItemName())
loadModule(WarpTabComplete)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 41d187421..0d2fd71ba 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -485,6 +485,11 @@ public class Misc {
public boolean serverRestartTitle = true;
@Expose
+ @ConfigOption(name = "Pocket Sack-In-A-Sack Applied", desc = "Show numbers of Pocket Sack-In-A-Sack applied on a sack.")
+ @ConfigEditorBoolean
+ public boolean sackInASackApplied = true;
+
+ @Expose
@ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
@ConfigEditorBoolean
public boolean configButtonOnPause = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt
new file mode 100644
index 000000000..3c4e4849c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt
@@ -0,0 +1,41 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class PocketSackInASackDisplay {
+
+ @SubscribeEvent
+ fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) {
+ val stack = event.stack ?: return
+ if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return
+ if (!SkyHanniMod.feature.misc.sackInASackApplied) return
+ val pocketSackInASackApplied = stack.getAppliedPocketSackInASack() ?: return
+
+ val stackTip = "§a$pocketSackInASackApplied"
+
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
+ GlStateManager.disableBlend()
+
+ val fontRenderer = event.fontRenderer
+ val x = event.x + 13 - fontRenderer.getStringWidth(stackTip)
+ val y = event.y + 1
+
+ val scale = 0.9
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(x.toFloat(), y.toFloat(), 0f)
+ GlStateManager.scale(scale, scale, scale)
+ fontRenderer.drawStringWithShadow(stackTip, 0f, 0f, 16777215)
+ val reverseScale = 1 / 0.7
+ GlStateManager.scale(reverseScale, reverseScale, reverseScale)
+ GlStateManager.popMatrix()
+
+ GlStateManager.enableLighting()
+ GlStateManager.enableDepth()
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt
index 91eeb04fd..b6cf391b7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt
@@ -3,4 +3,5 @@ package at.hannibal2.skyhanni.utils
data class CachedItemData(
/** -1 = not loaded */ var petCandies: Int? = -1,
/** "" = not loaded */ var heldItem: String? = "",
+ /** -1 = not loaded */ var sackInASack: Int? = -1,
) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
index d9f121951..19177aaa5 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
@@ -145,6 +145,14 @@ object SkyBlockItemModifierUtils {
enchantments.keySet.associateWith { enchantments.getInteger(it) }
}
+ fun ItemStack.getAppliedPocketSackInASack(): Int?{
+ val data = cachedData
+ if (data.sackInASack == -1) {
+ data.sackInASack = getAttributeInt("sack_pss")
+ }
+ return data.sackInASack
+ }
+
fun ItemStack.getGemstones() = getExtraAttributes()?.let {
val list = mutableListOf<GemstoneSlot>()
for (attributes in it.keySet) {