aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt70
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt30
8 files changed, 79 insertions, 147 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 1456a78f0..5c36395a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -79,6 +79,7 @@ public class SkyHanniMod {
public void preInit(FMLPreInitializationEvent event) {
logger = LogManager.getLogger("SkyHanni");
+ //API and utils
new BazaarApi();
registerEvent(this);
registerEvent(new ChatManager());
@@ -93,7 +94,9 @@ public class SkyHanniMod {
registerEvent(new ItemClickData());
registerEvent(new MinecraftData());
registerEvent(new SendTitleHelper());
+ registerEvent(new ItemTipHelper());
+ //features
registerEvent(new BazaarOrderHelper());
registerEvent(new ChatFilter());
registerEvent(new PlayerChatFormatter());
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
new file mode 100644
index 000000000..baa9fa75e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class ItemTipHelper {
+
+ @SubscribeEvent
+ fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
+ val stack = event.stack ?: return
+ if (!LorenzUtils.inSkyblock || stack.stackSize != 1) return
+
+ val itemTipEvent = RenderItemTipEvent(stack)
+ itemTipEvent.postAndCatch()
+ val stackTip = itemTipEvent.stackTip
+ if (stackTip.isEmpty()) return
+
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
+ GlStateManager.disableBlend()
+
+ val x = event.x + 17 + itemTipEvent.offsetX - if (itemTipEvent.alignLeft) {
+ event.fontRenderer.getStringWidth(stackTip)
+ } else 0
+ val y = event.y + 9 + itemTipEvent.offsetY
+
+ event.fontRenderer.drawStringWithShadow(stackTip, x.toFloat(), y.toFloat(), 16777215)
+ GlStateManager.enableLighting()
+ GlStateManager.enableDepth()
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt
new file mode 100644
index 000000000..4da9f6e37
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt
@@ -0,0 +1,11 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.item.ItemStack
+
+class RenderItemTipEvent(
+ val stack: ItemStack,
+ var stackTip: String = "",
+ var offsetX: Int = 0,
+ var offsetY: Int = 0,
+ var alignLeft: Boolean = true,
+) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
index 650d68a17..6ff33fd86 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
@@ -1,41 +1,21 @@
package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
-import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ItemDisplayOverlayFeatures {
@SubscribeEvent
- fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
- val stack = event.stack ?: return
-
- if (!LorenzUtils.inSkyblock || stack.stackSize != 1) return
-
- val stackTip = getStackTip(stack)
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(),
- (event.y + 9).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
- }
+ fun onRenderItemTip(event: RenderItemTipEvent) {
+ event.stackTip = getStackTip(event.stack)
}
private fun getStackTip(item: ItemStack): String {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt
index 0e503c052..000a2f93a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt
@@ -1,11 +1,10 @@
package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -62,28 +61,12 @@ class ItemStars {
}
@SubscribeEvent
- fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
- if (!LorenzUtils.inSkyblock) return
+ fun onRenderItemTip(event: RenderItemTipEvent) {
if (!SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(6)) return
- val stack = event.stack ?: return
- if (stack.stackSize != 1) return
+ val stack = event.stack
val number = getCrimsonStars(stack.name ?: return)
- val stackTip = if (number == -1) "" else number.toString()
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(),//TODO search for this line and replace all other methods into an api
- (event.y + 9).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
- }
+ event.stackTip = if (number == -1) "" else number.toString()
}
private fun getStars(name: String): Int {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt
index 51d81c5af..feb489349 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt
@@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.client.renderer.GlStateManager
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -21,40 +20,22 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class RngMeterInventory {
@SubscribeEvent
- fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
- if (!LorenzUtils.inSkyblock) return
-
+ fun onRenderItemTip(event: RenderItemTipEvent) {
val screen = Minecraft.getMinecraft().currentScreen
if (screen !is GuiChest) return
val chest = screen.inventorySlots as ContainerChest
val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
- var stackTip = ""
- val stack = event.stack ?: return
+ val stack = event.stack
if (SkyHanniMod.feature.inventory.rngMeterFloorName) {
if (chestName == "Catacombs RNG Meter") {
val name = stack.name ?: return
if (name.removeColor() == "RNG Meter") {
- stackTip = stack.getLore()[0].between("(", ")")
+ event.stackTip = stack.getLore()[0].between("(", ")")
}
}
}
-
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(),
- (event.y + 9).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
- }
}
@SubscribeEvent(priority = EventPriority.LOW)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt
index 95b323719..d25c2a0eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt
@@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.client.renderer.GlStateManager
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,18 +21,14 @@ class StatsTuning {
private val patternStatPoints = Pattern.compile("§7Stat has: §e(\\d+) point(s)?")
@SubscribeEvent
- fun onRenderTemplates(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
- if (!LorenzUtils.inSkyblock) return
-
+ fun onRenderItemTip(event: RenderItemTipEvent) {
val screen = Minecraft.getMinecraft().currentScreen
if (screen !is GuiChest) return
val chest = screen.inventorySlots as ContainerChest
val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
- var stackTip = ""
- var offsetX = 0
+ val stack = event.stack
- val stack = event.stack ?: return
if (SkyHanniMod.feature.inventory.statsTuningTemplateStats) {
if (chestName == "Stats Tuning") {
val name = stack.name ?: return
@@ -55,8 +50,11 @@ class StatsTuning {
}
}
if (list.isNotEmpty()) {
- stackTip = list.joinToString(" + ")
- offsetX = 20
+ event.stackTip = list.joinToString(" + ")
+ event.offsetX = 20
+ event.offsetY = -5
+ event.alignLeft = false
+ return
}
}
}
@@ -82,67 +80,27 @@ class StatsTuning {
}
}
if (list.isNotEmpty()) {
- stackTip = list.joinToString(" + ")
- offsetX = 3
+ event.stackTip = list.joinToString(" + ")
+ event.offsetX = 3
+ event.offsetY = -5
+ event.alignLeft = false
+ return
}
}
}
}
-
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 + offsetX).toFloat(),
- (event.y + 9 + -5).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
- }
- }
-
- @SubscribeEvent
- fun onRenderTuningPoints(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
- if (!LorenzUtils.inSkyblock) return
-
- val screen = Minecraft.getMinecraft().currentScreen
- if (screen !is GuiChest) return
- val chest = screen.inventorySlots as ContainerChest
- val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
-
- var stackTip = ""
-
- val stack = event.stack ?: return
if (SkyHanniMod.feature.inventory.statsTuningPoints) {
if (chestName == "Stats Tuning") {
for (line in stack.getLore()) {
val matcher = patternStatPoints.matcher(line)
if (matcher.matches()) {
val points = matcher.group(1)
- stackTip = points
+ event.stackTip = points
}
}
}
}
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(),
- (event.y + 9).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
- }
}
@SubscribeEvent(priority = EventPriority.LOW)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index 92aad363f..cbd75608a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -2,10 +2,10 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
-import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import net.minecraft.client.Minecraft
-import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C07PacketPlayerDigging
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
@@ -136,42 +135,25 @@ class ItemAbilityCooldown {
}
@SubscribeEvent
- fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
+ fun onRenderItemTip(event: RenderItemTipEvent) {
if (!isEnabled()) return
- val item = event.stack ?: return
- if (item.stackSize != 1) return
-
- var stackTip = ""
+ val stack = event.stack
val guiOpen = Minecraft.getMinecraft().currentScreen != null
- val itemText = items.filter { it.key == item }
+ val itemText = items.filter { it.key == stack }
.firstNotNullOfOrNull { it.value } ?: return
if (guiOpen && !itemText.onCooldown) return
val color = itemText.color
- stackTip = color.getChatColor() + itemText.text
+ event.stackTip = color.getChatColor() + itemText.text
if (SkyHanniMod.feature.itemAbilities.itemAbilityCooldownBackground) {
var opacity = 130
if (color == LorenzColor.GREEN) {
opacity = 80
}
- item.background = color.addOpacity(opacity).rgb
- }
-
- if (stackTip.isNotEmpty()) {
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
- event.fontRenderer.drawStringWithShadow(
- stackTip,
- (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(),
- (event.y + 9).toFloat(),
- 16777215
- )
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
+ stack.background = color.addOpacity(opacity).rgb
}
}