diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-26 15:37:56 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-26 15:37:56 +0100 |
commit | c15c3d2db212f2fb73e6063aa5ff3cc2b5a7a4f5 (patch) | |
tree | df378748160d120637459ef5e6e0b658cf899fce /src/main/java | |
parent | 52a6ff3c2ce36c2e0c8bccea09f412e6f86c922a (diff) | |
download | skyhanni-c15c3d2db212f2fb73e6063aa5ff3cc2b5a7a4f5.tar.gz skyhanni-c15c3d2db212f2fb73e6063aa5ff3cc2b5a7a4f5.tar.bz2 skyhanni-c15c3d2db212f2fb73e6063aa5ff3cc2b5a7a4f5.zip |
Start fixing gui rendering logic.
Diffstat (limited to 'src/main/java')
5 files changed, 52 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt index b9a217fbc..4de1f5c51 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt @@ -1,6 +1,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.gui.inventory.GuiInventory +import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -8,13 +12,34 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class RenderGuiData { @SubscribeEvent - fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { - if (event.type != RenderGameOverlayEvent.ElementType.ALL) return - GuiRenderEvent(GuiRenderEvent.RenderType.IN_WORLD).postAndCatch() + fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { + if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return + + val currentScreen = Minecraft.getMinecraft().currentScreen + if (currentScreen != null) { + if (currentScreen is GuiInventory || currentScreen is GuiChest) return + } + + GlStateManager.pushMatrix() + GlStateManager.translate(0f, 0f, -1f) + GlStateManager.enableDepth() + + GuiRenderEvent.GameOverlayRenderEvent().postAndCatch() + + GlStateManager.popMatrix() } @SubscribeEvent fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { - GuiRenderEvent(GuiRenderEvent.RenderType.INVENTORY_BACKGROUND).postAndCatch() + val currentScreen = Minecraft.getMinecraft().currentScreen ?: return + + if (currentScreen !is GuiInventory && currentScreen !is GuiChest) return + + GlStateManager.pushMatrix() + GlStateManager.enableDepth() + + GuiRenderEvent.ChestBackgroundRenderEvent().postAndCatch() + + GlStateManager.popMatrix() } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt index 9b7cebced..f7b02466c 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt @@ -1,10 +1,6 @@ package at.hannibal2.skyhanni.events -class GuiRenderEvent(val type: RenderType): LorenzEvent() { - - enum class RenderType { - INVENTORY_BACKGROUND, - IN_WORLD, - ; - } +open class GuiRenderEvent: LorenzEvent() { + class ChestBackgroundRenderEvent: GuiRenderEvent() + class GameOverlayRenderEvent: GuiRenderEvent() }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt index 6bbea13c1..41dd7da9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -15,7 +16,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack -import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.* import java.util.regex.Pattern @@ -91,7 +91,7 @@ class SkyMartBestProfit { } @SubscribeEvent - fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { + fun onBackgroundDraw(event: GuiRenderEvent.ChestBackgroundRenderEvent) { if (isEnabled()) { config.skyMartCopperPricePos.renderStringsAndItems(display) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index dc0683b27..13366c969 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -5,7 +5,9 @@ import io.github.moulberry.notenoughupdates.NEUManager import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.renderer.RenderHelper import net.minecraft.init.Items import net.minecraft.item.ItemStack @@ -79,8 +81,21 @@ object NEUItems { } val scale = if (isSkull) 0.8f else 0.6f - GlStateManager.scale(scale, scale, 1f) - Utils.drawItemStack(this, 0, 0) + GlStateManager.scale(scale, scale, 0f) + drawItemStack(this) GlStateManager.popMatrix() } + + private fun drawItemStack(stack: ItemStack) { + val itemRender = Minecraft.getMinecraft().renderItem + + Utils.disableCustomDungColours = true + RenderHelper.enableGUIStandardItemLighting() + Utils.hasEffectOverride = true + itemRender.renderItemAndEffectIntoGUI(stack, 0, 0) + itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, 0, 0, null) + Utils.hasEffectOverride = false + RenderHelper.disableStandardItemLighting() + Utils.disableCustomDungColours = false + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index cec4cfb3c..6d99f23a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -39,6 +39,7 @@ object RenderUtils { GlStateManager.color(1f, 1f, 1f, 1f) GlStateManager.pushMatrix() + // TODO don't use z GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel) Gui.drawRect( this.xDisplayPosition, |