From b97d1cf5d943cfcc98de29813874f506dccabdd9 Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 2 Jun 2026 13:15:28 +0200 Subject: [PATCH] the less vanilla crap you use, the better --- changelog | 3 + src/main/java/com/hbm/handler/GUIHandler.java | 74 ++----- .../hbm/inventory/gui/GUIBlastFurnace.java | 6 +- .../hbm/inventory/gui/GUIFusionBreeder.java | 4 +- .../hbm/inventory/gui/GUIFusionKlystron.java | 8 +- .../com/hbm/inventory/gui/GUIFusionTorus.java | 8 +- .../java/com/hbm/inventory/gui/GUIICF.java | 4 +- .../gui/GUIMachineAssemblyFactory.java | 3 +- .../gui/GUIMachineAssemblyMachine.java | 3 +- .../gui/GUIMachineChemicalFactory.java | 3 +- .../gui/GUIMachineChemicalPlant.java | 3 +- .../hbm/inventory/gui/GUIMachineCustom.java | 4 +- .../hbm/inventory/gui/GUIMachinePUREX.java | 3 +- .../inventory/gui/GUIMachinePlasmaForge.java | 8 +- .../hbm/inventory/gui/GUIMachinePrecAss.java | 3 +- .../hbm/inventory/gui/GUIMachinePress.java | 4 +- .../hbm/inventory/gui/GUIMachineTurbofan.java | 6 +- .../java/com/hbm/inventory/gui/GUIPWR.java | 6 +- .../com/hbm/inventory/gui/GUIPneumoTube.java | 4 +- .../gui/GUIScreenRecipeSelector.java | 5 +- .../java/com/hbm/inventory/gui/GUIWatz.java | 6 +- .../hbm/inventory/gui/GuiInfoContainer.java | 6 + .../inventory/gui/element/GUIElements.java | 194 ++++++++++++++++++ .../inventory/gui/element/GuiFileList.java | 7 +- .../java/com/hbm/render/util/GaugeUtil.java | 97 --------- src/main/java/com/hbm/util/Vec3NT.java | 15 +- 26 files changed, 276 insertions(+), 211 deletions(-) create mode 100644 src/main/java/com/hbm/inventory/gui/element/GUIElements.java delete mode 100644 src/main/java/com/hbm/render/util/GaugeUtil.java diff --git a/changelog b/changelog index b88761920..1c026a1eb 100644 --- a/changelog +++ b/changelog @@ -72,6 +72,9 @@ * The analog and integrated circuit boards now have alternate recipes in the assembler * Removed two of the older motor recipes in the arc welder * The only remaining recipe is the dense red copper one +* Using state of the art anti-leave-the-screen technology, recipe tooltips (and most tooltips used by `GuiInfoScreen`) should no longer leave the screen + * This means that the recipe selector can now have the tooltip follow the mouse instead of being eternally stuck in the corner + * Recipe selector tooltips now have a nice orange and yellow border ## Fixed * Fixed RoR graph showing the wrong name in the GUI diff --git a/src/main/java/com/hbm/handler/GUIHandler.java b/src/main/java/com/hbm/handler/GUIHandler.java index 931fedac8..bcd09d897 100644 --- a/src/main/java/com/hbm/handler/GUIHandler.java +++ b/src/main/java/com/hbm/handler/GUIHandler.java @@ -14,67 +14,31 @@ public class GUIHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IGUIProvider) { - return ((IGUIProvider) tileEntity).provideContainer(ID, player, world, x, y, z); - } - - Block block = world.getBlock(x, y, z); - - if(block instanceof IGUIProvider) { - return ((IGUIProvider) block).provideContainer(ID, player, world, x, y, z); - } - - ItemStack item = player.getHeldItem(); - - if(item != null && item.getItem() instanceof IGUIProvider) { - return ((IGUIProvider) item.getItem()).provideContainer(ID, player, world, x, y, z); - } - - Entity entity = player.worldObj.getEntityByID(x); - - if(entity != null && entity instanceof IGUIProvider) { - return ((IGUIProvider) entity).provideContainer(ID, player, world, x, y, z); - } - - //notice: stop doing this, unless you absolutely have to :3 - - //notice: stop doing this completely, period :P - + IGUIProvider provider = this.getGUIProvider(player, world, x, y, z); + if(provider != null) return provider.provideContainer(ID, player, world, x, y, z); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IGUIProvider) { - return ((IGUIProvider) tileEntity).provideGUI(ID, player, world, x, y, z); - } - - Block block = world.getBlock(x, y, z); - - if(block instanceof IGUIProvider) { - return ((IGUIProvider) block).provideGUI(ID, player, world, x, y, z); - } - - ItemStack item = player.getHeldItem(); - - if(item != null && item.getItem() instanceof IGUIProvider) { - return ((IGUIProvider) item.getItem()).provideGUI(ID, player, world, x, y, z); - } - - Entity entity = player.worldObj.getEntityByID(x); - - if(entity != null && entity instanceof IGUIProvider) { - return ((IGUIProvider) entity).provideGUI(ID, player, world, x, y, z); - } - - //stop doing this unless you absolutely have to ;3 - - //stop doing this, period >:3 + IGUIProvider provider = this.getGUIProvider(player, world, x, y, z); + if(provider != null) return provider.provideGUI(ID, player, world, x, y, z); return null; } + public IGUIProvider getGUIProvider(EntityPlayer player, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if(tileEntity instanceof IGUIProvider) return ((IGUIProvider) tileEntity); + + Block block = world.getBlock(x, y, z); + if(block instanceof IGUIProvider) return ((IGUIProvider) block); + + ItemStack item = player.getHeldItem(); + if(item != null && item.getItem() instanceof IGUIProvider) return ((IGUIProvider) item.getItem()); + + Entity entity = player.worldObj.getEntityByID(x); + if(entity != null && entity instanceof IGUIProvider) return ((IGUIProvider) entity); + + return null; + } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIBlastFurnace.java b/src/main/java/com/hbm/inventory/gui/GUIBlastFurnace.java index 4ea1bf066..565424f91 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIBlastFurnace.java +++ b/src/main/java/com/hbm/inventory/gui/GUIBlastFurnace.java @@ -5,8 +5,8 @@ import java.util.List; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerBlastFurnace; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.TileEntityMachineBlastFurnace; import net.minecraft.client.Minecraft; @@ -71,7 +71,7 @@ public class GUIBlastFurnace extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 81, guiTop + 64, 176, 0, 14, 14); } - GaugeUtil.drawSmoothGauge(guiLeft + 34, guiTop + 80, this.zLevel, (double) furnace.tanks[0].getFill() / (double) furnace.tanks[0].getMaxFill(), 5, 2, 1, 0x800000); - GaugeUtil.drawSmoothGauge(guiLeft + 34, guiTop + 26, this.zLevel, (double) furnace.tanks[1].getFill() / (double) furnace.tanks[1].getMaxFill(), 5, 2, 1, 0x800000); + GUIElements.drawSmoothGauge(guiLeft + 34, guiTop + 80, this.zLevel, (double) furnace.tanks[0].getFill() / (double) furnace.tanks[0].getMaxFill(), 5, 2, 1, 0x800000); + GUIElements.drawSmoothGauge(guiLeft + 34, guiTop + 26, this.zLevel, (double) furnace.tanks[1].getFill() / (double) furnace.tanks[1].getMaxFill(), 5, 2, 1, 0x800000); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionBreeder.java b/src/main/java/com/hbm/inventory/gui/GUIFusionBreeder.java index ec88e3c0d..e3449e839 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionBreeder.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionBreeder.java @@ -1,8 +1,8 @@ package com.hbm.inventory.gui; import com.hbm.inventory.container.ContainerFusionBreeder; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.fusion.TileEntityFusionBreeder; import com.hbm.util.BobMathUtil; @@ -54,7 +54,7 @@ public class GUIFusionBreeder extends GuiInfoContainer { double gauge = 1D - Math.pow(Math.E, -breeder.neutronEnergy * 10 / breeder.capacity); // input flux - GaugeUtil.drawSmoothGauge(guiLeft + 88, guiTop + 32, this.zLevel, gauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 88, guiTop + 32, this.zLevel, gauge, 5, 2, 1, 0xA00000); breeder.tanks[0].renderTank(guiLeft + 26, guiTop + 70, this.zLevel, 16, 52); breeder.tanks[1].renderTank(guiLeft + 134, guiTop + 70, this.zLevel, 16, 52); diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java b/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java index 79a435020..9e42fa58b 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java @@ -4,10 +4,10 @@ import org.apache.commons.lang3.math.NumberUtils; import org.lwjgl.input.Keyboard; import com.hbm.inventory.container.ContainerFusionKlystron; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toserver.NBTControlPacket; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.fusion.TileEntityFusionKlystron; import com.hbm.tileentity.machine.fusion.TileEntityFusionTorus; import com.hbm.util.BobMathUtil; @@ -99,11 +99,11 @@ public class GUIFusionKlystron extends GuiInfoContainer { else if(klystron.output > 0) drawTexturedModalRect(guiLeft + 180, guiTop + 71, 210, 0, 8, 8); // output energy - GaugeUtil.drawSmoothGauge(guiLeft + 52, guiTop + 80, this.zLevel, outputGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 52, guiTop + 80, this.zLevel, outputGauge, 5, 2, 1, 0xA00000); // air cooling - GaugeUtil.drawSmoothGauge(guiLeft + 88, guiTop + 80, this.zLevel, airGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 88, guiTop + 80, this.zLevel, airGauge, 5, 2, 1, 0xA00000); // power consumption - GaugeUtil.drawSmoothGauge(guiLeft + 124, guiTop + 80, this.zLevel, powerGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 124, guiTop + 80, this.zLevel, powerGauge, 5, 2, 1, 0xA00000); this.field.drawTextBox(); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java index f682eb767..fe857246c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java @@ -1,11 +1,11 @@ package com.hbm.inventory.gui; import com.hbm.inventory.container.ContainerFusionTorus; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.FusionRecipe; import com.hbm.inventory.recipes.FusionRecipes; import com.hbm.items.machine.ItemBlueprints; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.fusion.TileEntityFusionTorus; import com.hbm.util.BobMathUtil; import com.hbm.util.i18n.I18nUtil; @@ -131,11 +131,11 @@ public class GUIFusionTorus extends GuiInfoContainer { double outputGauge = recipe == null ? 0 : Math.min(((double) torus.plasmaEnergy / (double) recipe.outputTemp), 1); // input energy - GaugeUtil.drawSmoothGauge(guiLeft + 52, guiTop + 124, this.zLevel, inputGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 52, guiTop + 124, this.zLevel, inputGauge, 5, 2, 1, 0xA00000); // output genergy - GaugeUtil.drawSmoothGauge(guiLeft + 88, guiTop + 124, this.zLevel, outputGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 88, guiTop + 124, this.zLevel, outputGauge, 5, 2, 1, 0xA00000); // fuel consumption - GaugeUtil.drawSmoothGauge(guiLeft + 124, guiTop + 124, this.zLevel, torus.fuelConsumption, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 124, guiTop + 124, this.zLevel, torus.fuelConsumption, 5, 2, 1, 0xA00000); // recipe selector this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 44, 81); diff --git a/src/main/java/com/hbm/inventory/gui/GUIICF.java b/src/main/java/com/hbm/inventory/gui/GUIICF.java index 0effa9b4d..8e019d93c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIICF.java +++ b/src/main/java/com/hbm/inventory/gui/GUIICF.java @@ -1,8 +1,8 @@ package com.hbm.inventory.gui; import com.hbm.inventory.container.ContainerICF; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.TileEntityICF; import com.hbm.util.BobMathUtil; @@ -54,7 +54,7 @@ public class GUIICF extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 8, guiTop + 88 - p, 212, 192 - p, 16, p); } - GaugeUtil.drawSmoothGauge(guiLeft + 196, guiTop + 98, this.zLevel, (double) icf.heat / (double) icf.maxHeat, 5, 2, 1, 0xFF00AF); + GUIElements.drawSmoothGauge(guiLeft + 196, guiTop + 98, this.zLevel, (double) icf.heat / (double) icf.maxHeat, 5, 2, 1, 0xFF00AF); icf.tanks[0].renderTank(guiLeft + 44, guiTop + 88, this.zLevel, 16, 70); icf.tanks[1].renderTank(guiLeft + 188, guiTop + 88, this.zLevel, 16, 70); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java index ac9ff747c..11f7db844 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineAssemblyFactory; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -48,7 +49,7 @@ public class GUIMachineAssemblyFactory extends GuiInfoContainer { for(int i = 0; i < 4; i++) if(guiLeft + 6 + (i % 2) * 109 <= mouseX && guiLeft + 6 + (i % 2) * 109 + 18 > mouseX && guiTop + 53 + (i / 2) * 56 < mouseY && guiTop + 53 + (i / 2) * 56 + 18 >= mouseY) { if(this.assembler.assemblerModule[i].recipe != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule[i].recipe)) { GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule[i].recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java index 5104850ca..0e5f8184c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineAssemblyMachine; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -43,7 +44,7 @@ public class GUIMachineAssemblyMachine extends GuiInfoContainer { if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { if(this.assembler.assemblerModule.recipe != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.recipe)) { GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java index c153a949f..885411e82 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineChemicalFactory; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -48,7 +49,7 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { for(int i = 0; i < 4; i++) if(guiLeft + 74 <= mouseX && guiLeft + 74 + 18 > mouseX && guiTop + 19 + i * 22 < mouseY && guiTop + 19 + i * 22 + 18 >= mouseY) { if(this.chemplant.chemplantModule[i].recipe != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule[i].recipe)) { GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule[i].recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java index 9efa78905..bc63a81b5 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineChemicalPlant; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -44,7 +45,7 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer { if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { if(this.chemplant.chemplantModule.recipe != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule.recipe)) { GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule.recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java b/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java index d106f3717..8f1fc9e02 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java @@ -3,11 +3,11 @@ package com.hbm.inventory.gui; import java.util.Arrays; import java.util.Locale; -import com.hbm.render.util.GaugeUtil; import org.lwjgl.opengl.GL11; import com.hbm.inventory.SlotPattern; import com.hbm.inventory.container.ContainerMachineCustom; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; import com.hbm.module.ModulePatternMatcher; @@ -79,7 +79,7 @@ public class GUIMachineCustom extends GuiInfoContainer { } if(custom.maxHeat > 0) { drawTexturedModalRect(guiLeft + 61, guiTop + 53, 236, 0, 18, 18); - GaugeUtil.drawSmoothGauge(guiLeft + 70, guiTop + 62, this.zLevel, (double) custom.heat / (double) custom.config.maxHeat, 5, 2, 1, 0x7F0000); + GUIElements.drawSmoothGauge(guiLeft + 70, guiTop + 62, this.zLevel, (double) custom.heat / (double) custom.config.maxHeat, 5, 2, 1, 0x7F0000); } int p = custom.progress * 90 / custom.maxProgress; drawTexturedModalRect(guiLeft + 78, guiTop + 119, 192, 0, Math.min(p, 44), 16); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java index 8d746cf11..2ae922c50 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachinePUREX; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.PUREXRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -45,7 +46,7 @@ public class GUIMachinePUREX extends GuiInfoContainer { if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { if(this.purex.purexModule.recipe != null && PUREXRecipes.INSTANCE.recipeNameMap.containsKey(this.purex.purexModule.recipe)) { GenericRecipe recipe = (GenericRecipe) PUREXRecipes.INSTANCE.recipeNameMap.get(this.purex.purexModule.recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java index 35a9ae26f..2516072f7 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java @@ -6,12 +6,12 @@ import java.util.List; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachinePlasmaForge; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.PlasmaForgeRecipe; import com.hbm.inventory.recipes.PlasmaForgeRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.fusion.TileEntityFusionPlasmaForge; import com.hbm.util.BobMathUtil; import com.hbm.util.i18n.I18nUtil; @@ -49,7 +49,7 @@ public class GUIMachinePlasmaForge extends GuiInfoContainer { if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 80 < mouseY && guiTop + 80 + 18 >= mouseY) { if(this.forge.plasmaModule.recipe != null && PlasmaForgeRecipes.INSTANCE.recipeNameMap.containsKey(this.forge.plasmaModule.recipe)) { GenericRecipe recipe = (GenericRecipe) PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(this.forge.plasmaModule.recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } @@ -147,9 +147,9 @@ public class GUIMachinePlasmaForge extends GuiInfoContainer { double boosterGauge = forge.maxBooster <= 0 ? 0 : (double) forge.booster / (double) forge.maxBooster; // input energy - GaugeUtil.drawSmoothGauge(guiLeft + 34, guiTop + 124, this.zLevel, inputGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 34, guiTop + 124, this.zLevel, inputGauge, 5, 2, 1, 0xA00000); // output genergy - GaugeUtil.drawSmoothGauge(guiLeft + 70, guiTop + 124, this.zLevel, boosterGauge, 5, 2, 1, 0xA00000); + GUIElements.drawSmoothGauge(guiLeft + 70, guiTop + 124, this.zLevel, boosterGauge, 5, 2, 1, 0xA00000); this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 8, 81); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java index 6cdbe0a2e..53d04d6f7 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachinePrecAss; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.PrecAssRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.machine.ItemBlueprints; @@ -43,7 +44,7 @@ public class GUIMachinePrecAss extends GuiInfoContainer { if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { if(this.assembler.assemblerModule.recipe != null && PrecAssRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.recipe)) { GenericRecipe recipe = (GenericRecipe) PrecAssRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe); - this.func_146283_a(recipe.print(), mouseX, mouseY); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePress.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePress.java index bf5f5e39f..a9c306d77 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePress.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePress.java @@ -3,8 +3,8 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachinePress; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.TileEntityMachinePress; import net.minecraft.client.Minecraft; @@ -55,6 +55,6 @@ public class GUIMachinePress extends GuiInfoContainer { this.drawTexturedModalRect(guiLeft + 79, guiTop + 35, 14, 202, 18, k); double i = (double) press.speed / (double) press.maxSpeed; - GaugeUtil.drawSmoothGauge(guiLeft + 34, guiTop + 25, this.zLevel, i, 5, 2, 1, 0x7f0000); + GUIElements.drawSmoothGauge(guiLeft + 34, guiTop + 25, this.zLevel, i, 5, 2, 1, 0x7f0000); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineTurbofan.java b/src/main/java/com/hbm/inventory/gui/GUIMachineTurbofan.java index 60b4fe459..018f2d88a 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineTurbofan.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineTurbofan.java @@ -3,9 +3,9 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineTurbofan; +import com.hbm.inventory.gui.element.GUIElements; +import com.hbm.inventory.gui.element.GUIElements.Gauge; import com.hbm.lib.RefStrings; -import com.hbm.render.util.GaugeUtil; -import com.hbm.render.util.GaugeUtil.Gauge; import com.hbm.tileentity.machine.TileEntityMachineTurbofan; import net.minecraft.client.Minecraft; @@ -57,7 +57,7 @@ public class GUIMachineTurbofan extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 98, guiTop + 44, 176, (a - 1) * 16, 16, 16); } - if(turbofan.showBlood) GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 97, guiTop + 16, this.zLevel, (double) turbofan.blood.getFill() / (double) turbofan.blood.getMaxFill()); + if(turbofan.showBlood) GUIElements.renderGauge(Gauge.ROUND_SMALL, guiLeft + 97, guiTop + 16, this.zLevel, (double) turbofan.blood.getFill() / (double) turbofan.blood.getMaxFill()); turbofan.tank.renderTank(guiLeft + 35, guiTop + 69, this.zLevel, 34, 52); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIPWR.java b/src/main/java/com/hbm/inventory/gui/GUIPWR.java index 3220d178b..8ac13d8dd 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPWR.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPWR.java @@ -7,11 +7,11 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerPWR; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.items.ModItems; import com.hbm.lib.RefStrings; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toserver.NBTControlPacket; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.machine.TileEntityPWRController; import net.minecraft.client.Minecraft; @@ -122,8 +122,8 @@ public class GUIPWR extends GuiInfoContainer { //GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 115, guiTop + 31, this.zLevel, (double) controller.coreHeat / (double) controller.coreHeatCapacity); //GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 151, guiTop + 31, this.zLevel, (double) controller.hullHeat / (double) controller.hullHeatCapacity); - GaugeUtil.drawSmoothGauge(guiLeft + 124, guiTop + 40, this.zLevel, (double) controller.coreHeat / (double) controller.coreHeatCapacity, 5, 2, 1, 0x7F0000); - GaugeUtil.drawSmoothGauge(guiLeft + 160, guiTop + 40, this.zLevel, (double) controller.hullHeat / (double) controller.hullHeatCapacityBase, 5, 2, 1, 0x7F0000); + GUIElements.drawSmoothGauge(guiLeft + 124, guiTop + 40, this.zLevel, (double) controller.coreHeat / (double) controller.coreHeatCapacity, 5, 2, 1, 0x7F0000); + GUIElements.drawSmoothGauge(guiLeft + 160, guiTop + 40, this.zLevel, (double) controller.hullHeat / (double) controller.hullHeatCapacityBase, 5, 2, 1, 0x7F0000); if(controller.typeLoaded != -1 && controller.amountLoaded > 0) { ItemStack display = new ItemStack(ModItems.pwr_fuel, 1, controller.typeLoaded); diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java index eba1e7c9a..aa9f968d3 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java @@ -5,11 +5,11 @@ import java.util.Arrays; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerPneumoTube; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.lib.RefStrings; import com.hbm.module.ModulePatternMatcher; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toserver.NBTControlPacket; -import com.hbm.render.util.GaugeUtil; import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube; import com.hbm.uninos.networkproviders.PneumaticNetwork; @@ -112,7 +112,7 @@ public class GUIPneumoTube extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 151, guiTop + 52, 215, 18 * tube.sendOrder, 18, 18); drawTexturedModalRect(guiLeft + 6 + 4 * (tube.compair.getPressure() - 1), guiTop + 36, 179, 18, 4, 8); - GaugeUtil.drawSmoothGauge(guiLeft + 16, guiTop + 25, this.zLevel, (double) tube.compair.getFill() / (double) tube.compair.getMaxFill(), 5, 2, 1, 0xCA6C43, 0xAB4223); + GUIElements.drawSmoothGauge(guiLeft + 16, guiTop + 25, this.zLevel, (double) tube.compair.getFill() / (double) tube.compair.getMaxFill(), 5, 2, 1, 0xCA6C43, 0xAB4223); } } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java b/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java index 986751e43..baee7e794 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java @@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.inventory.recipes.loader.GenericRecipes; import com.hbm.lib.RefStrings; @@ -136,7 +137,7 @@ public class GUIScreenRecipeSelector extends GuiScreen { if(guiLeft + ix <= mouseX && guiLeft + ix + 18 > mouseX && guiTop + iy < mouseY && guiTop + iy + 18 >= mouseY) { GenericRecipe recipe = recipes.get(i); - this.func_146283_a(recipe.print(), 0, 900); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } } } @@ -144,7 +145,7 @@ public class GUIScreenRecipeSelector extends GuiScreen { if(guiLeft + 151 <= mouseX && guiLeft + 151 + 18 > mouseX && guiTop + 71 < mouseY && guiTop + 71 + 18 >= mouseY) { if(this.selection != null && this.recipeSet.recipeNameMap.containsKey(selection)) { GenericRecipe recipe = (GenericRecipe) this.recipeSet.recipeNameMap.get(selection); - this.func_146283_a(recipe.print(), 0, 900); + GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIWatz.java b/src/main/java/com/hbm/inventory/gui/GUIWatz.java index cf190b93e..835c84f4d 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIWatz.java +++ b/src/main/java/com/hbm/inventory/gui/GUIWatz.java @@ -5,11 +5,11 @@ import java.util.Locale; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerWatz; +import com.hbm.inventory.gui.element.GUIElements; +import com.hbm.inventory.gui.element.GUIElements.Gauge; import com.hbm.lib.RefStrings; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toserver.NBTControlPacket; -import com.hbm.render.util.GaugeUtil; -import com.hbm.render.util.GaugeUtil.Gauge; import com.hbm.tileentity.machine.TileEntityWatz; import net.minecraft.client.Minecraft; @@ -86,7 +86,7 @@ public class GUIWatz extends GuiInfoContainer { if(watz.isOn) drawTexturedModalRect(guiLeft + 147, guiTop + 8, 176, 0, 8, 8); if(watz.isLocked) drawTexturedModalRect(guiLeft + 142, guiTop + 70, 210, 0, 18, 18); - GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 13, guiTop + 100, this.zLevel, 1 - col); + GUIElements.renderGauge(Gauge.ROUND_SMALL, guiLeft + 13, guiTop + 100, this.zLevel, 1 - col); watz.tanks[0].renderTank(guiLeft + 143, guiTop + 69, this.zLevel, 4, 43); watz.tanks[1].renderTank(guiLeft + 149, guiTop + 69, this.zLevel, 4, 43); diff --git a/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java b/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java index 7c57a4dab..c966dd9f4 100644 --- a/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java +++ b/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java @@ -7,6 +7,7 @@ import codechicken.nei.api.INEIGuiHandler; import codechicken.nei.api.TaggedInventoryArea; import com.hbm.inventory.SlotPattern; import com.hbm.inventory.container.ContainerBase; +import com.hbm.inventory.gui.element.GUIElements; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toserver.NBTControlPacket; @@ -61,6 +62,11 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa this.func_146283_a(Arrays.asList(text), x, y); } + @Override + protected void func_146283_a(List lines, int x, int y) { + GUIElements.drawHoveringText(lines, x, y, fontRendererObj, itemRender, width, height); + } + /** Automatically grabs upgrade info out of the tile entity if it's a IUpgradeInfoProvider and crams the available info into a list for display. Automation, yeah! */ public List getUpgradeInfo(TileEntity tile) { List lines = new ArrayList(); diff --git a/src/main/java/com/hbm/inventory/gui/element/GUIElements.java b/src/main/java/com/hbm/inventory/gui/element/GUIElements.java new file mode 100644 index 000000000..7c0b2e5d2 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/element/GUIElements.java @@ -0,0 +1,194 @@ +package com.hbm.inventory.gui.element; + +import java.util.Iterator; +import java.util.List; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import com.hbm.lib.RefStrings; +import com.hbm.util.Vec3NT; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +public class GUIElements { + + @Deprecated public static enum Gauge { + ROUND_SMALL("small_round", 18, 18, 13); + ResourceLocation texture; + int width, height, count; + private Gauge(String texture, int width, int height, int count) { + this.texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/" + texture + ".png"); + this.width = width; + this.height = height; + this.count = count; + } + } + + @Deprecated public static void renderGauge(Gauge gauge, double x, double y, double z, double progress) { + Minecraft.getMinecraft().renderEngine.bindTexture(gauge.texture); + int frameNum = (int) Math.round((gauge.count - 1) * progress); + double singleFrame = 1D / (double)gauge.count; + double frameOffset = singleFrame * frameNum; + Tessellator tess = Tessellator.instance; + tess.startDrawingQuads(); + tess.addVertexWithUV(x, y + gauge.height, z, 0, frameOffset + singleFrame); + tess.addVertexWithUV(x + gauge.width, y + gauge.height, z, 1, frameOffset + singleFrame); + tess.addVertexWithUV(x + gauge.width, y, z, 1, frameOffset); + tess.addVertexWithUV(x, y, z, 0, frameOffset); + tess.draw(); + } + + public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color) { + drawSmoothGauge(x, y, z, progress, tipLength, backLength, backSide, color, 0x000000); + } + + private static Vec3NT tip = new Vec3NT(); + private static Vec3NT left = new Vec3NT(); + private static Vec3NT right = new Vec3NT(); + + public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color, int colorOuter) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + + progress = MathHelper.clamp_double(progress, 0, 1); + + float angle = (float) Math.toRadians(-progress * 270 - 45); + tip.setComponents(0, tipLength, 0); + left.setComponents(backSide, -backLength, 0); + right.setComponents(-backSide, -backLength, 0); + + tip.rotateAroundZ(angle); + left.rotateAroundZ(angle); + right.rotateAroundZ(angle); + + Tessellator tess = Tessellator.instance; + tess.startDrawing(GL11.GL_TRIANGLES); + tess.setColorOpaque_I(colorOuter); + double mult = 1.5; + tess.addVertex(x + tip.xCoord * mult, y + tip.yCoord * mult, z); + tess.addVertex(x + left.xCoord * mult, y + left.yCoord * mult, z); + tess.addVertex(x + right.xCoord * mult, y + right.yCoord * mult, z); + tess.setColorOpaque_I(color); + tess.addVertex(x + tip.xCoord, y + tip.yCoord, z); + tess.addVertex(x + left.xCoord, y + left.yCoord, z); + tess.addVertex(x + right.xCoord, y + right.yCoord, z); + tess.draw(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static final int STANDARD_COLOR_BACKGROUND = -0xFEFFFF0; + public static final int STANDARD_COLOR_LINE0 = 0x505000FF; + public static final int STANDARD_COLOR_LINE1 = (STANDARD_COLOR_LINE0 & 0xFEFEFE) >> 1 | STANDARD_COLOR_LINE0 & -0xFEFEFE; + public static final int RECIPE_COLOR_LINE0 = 0xFFFF8000; + public static final int RECIPE_COLOR_LINE1 = 0xFFFFFF00; + public static final int STANDARD_HEADER_OFFSET = 2; + public static final int STANDARD_LINE_DIST = 10; + public static void drawHoveringText(List lines, int x, int y, FontRenderer font, RenderItem itemRender, int guiWidth, int guiHeight) { + drawHoveringText(lines, x, y, font, itemRender, guiWidth, guiHeight, STANDARD_HEADER_OFFSET, STANDARD_LINE_DIST, STANDARD_COLOR_BACKGROUND, STANDARD_COLOR_BACKGROUND, STANDARD_COLOR_LINE0, STANDARD_COLOR_LINE1); + } + public static void drawHoveringTextRecipe(List lines, int x, int y, FontRenderer font, RenderItem itemRender, int guiWidth, int guiHeight) { + drawHoveringText(lines, x, y, font, itemRender, guiWidth, guiHeight, 6, STANDARD_LINE_DIST, STANDARD_COLOR_BACKGROUND, STANDARD_COLOR_BACKGROUND, RECIPE_COLOR_LINE0, RECIPE_COLOR_LINE1); + } + + public static void drawHoveringText(List lines, int x, int y, FontRenderer font, RenderItem itemRender, int guiWidth, int guiHeight, int headerOffset, int lineDist, int colBG0, int colBG1, int colLine0, int colLine1) { + + if(!lines.isEmpty()) { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int width = 0; + Iterator iterator = lines.iterator(); + + while(iterator.hasNext()) { + String line = (String) iterator.next(); + int lineLength = font.getStringWidth(line); + + if(lineLength > width) { + width = lineLength; + } + } + + int boundX = x + 12; + int boundY = y - 12; + int height = 6 + headerOffset; + + if(lines.size() > 1) { + height += 2 + (lines.size() - 1) * lineDist; + } + + // if trying to leave bottom or right side, move inwards + if(boundX + width + 4 > guiWidth) boundX -= 28 + width; + if(boundY + height + 6 > guiHeight) boundY = guiHeight - height - 6; + + // afterwards, see if the tooltip exits the top or left and then fix that, this one's more important and for some fucking reason wasn't handled by vanilla t all + if(boundX < 4) boundX = 4; + if(boundY < 4) boundY = 4; + + itemRender.zLevel = 300.0F; + drawGradientRect(boundX - 3, boundY - 4, boundX + width + 3, boundY - 3, colBG0, colBG0); + drawGradientRect(boundX - 3, boundY + height + 3, boundX + width + 3, boundY + height + 4, colBG1, colBG1); + drawGradientRect(boundX - 3, boundY - 3, boundX + width + 3, boundY + height + 3, colBG0, colBG1); + drawGradientRect(boundX - 4, boundY - 3, boundX - 3, boundY + height + 3, colBG0, colBG1); + drawGradientRect(boundX + width + 3, boundY - 3, boundX + width + 4, boundY + height + 3, colBG0, colBG1); + + drawGradientRect(boundX - 3, boundY - 3 + 1, boundX - 3 + 1, boundY + height + 3 - 1, colLine0, colLine1); + drawGradientRect(boundX + width + 2, boundY - 3 + 1, boundX + width + 3, boundY + height + 3 - 1, colLine0, colLine1); + drawGradientRect(boundX - 3, boundY - 3, boundX + width + 3, boundY - 3 + 1, colLine0, colLine0); + drawGradientRect(boundX - 3, boundY + height + 2, boundX + width + 3, boundY + height + 3, colLine1, colLine1); + + for(int i = 0; i < lines.size(); ++i) { + String line = (String) lines.get(i); + font.drawStringWithShadow(line, boundX, boundY, -1); + + if(i == 0) boundY += headerOffset; + boundY += lineDist; + } + + itemRender.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } + + /** Colors don't use the RGBA, but rather ARGB (evil route) */ + protected static void drawGradientRect(int x0, int y0, int x1, int y1, int col0, int col1) { + float a0 = (float) (col0 >> 24 & 255) / 255F; + float r0 = (float) (col0 >> 16 & 255) / 255F; + float g0 = (float) (col0 >> 8 & 255) / 255F; + float b0 = (float) (col0 & 255) / 255F; + float a1 = (float) (col1 >> 24 & 255) / 255F; + float r1 = (float) (col1 >> 16 & 255) / 255F; + float g1 = (float) (col1 >> 8 & 255) / 255F; + float b1 = (float) (col1 & 255) / 255F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(r0, g0, b0, a0); + tessellator.addVertex(x1, y0, 300D); + tessellator.addVertex(x0, y0, 300D); + tessellator.setColorRGBA_F(r1, g1, b1, a1); + tessellator.addVertex(x0, y1, 300D); + tessellator.addVertex(x1, y1, 300D); + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/element/GuiFileList.java b/src/main/java/com/hbm/inventory/gui/element/GuiFileList.java index 63364f3d4..673110a04 100644 --- a/src/main/java/com/hbm/inventory/gui/element/GuiFileList.java +++ b/src/main/java/com/hbm/inventory/gui/element/GuiFileList.java @@ -85,15 +85,10 @@ public class GuiFileList extends GuiListExtended { if(hoverY < 0 || hoverY > height) return false; onSelect.accept(file); - return true; } @Override - public void mouseReleased(int id, int mouseX, int mouseY, int button, int hoverX, int hoverY) { - - } - + public void mouseReleased(int id, int mouseX, int mouseY, int button, int hoverX, int hoverY) { } } - } diff --git a/src/main/java/com/hbm/render/util/GaugeUtil.java b/src/main/java/com/hbm/render/util/GaugeUtil.java deleted file mode 100644 index 68e90a95b..000000000 --- a/src/main/java/com/hbm/render/util/GaugeUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.hbm.render.util; - -import org.lwjgl.opengl.GL11; - -import com.hbm.lib.RefStrings; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Vec3; - -public class GaugeUtil { - - public static enum Gauge { - - ROUND_SMALL(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/small_round.png"), 18, 18, 13), - ROUND_LARGE(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/large_round.png"), 36, 36, 13), - BOW_SMALL(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/small_bow.png"), 18, 18, 13), - BOW_LARGE(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/large_bow.png"), 36, 36, 13), - WIDE_SMALL(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/small_wide.png"), 18, 12, 7), - WIDE_LARGE(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/large_wide.png"), 36, 24, 11), - BAR_SMALL(new ResourceLocation(RefStrings.MODID + ":textures/gui/gauges/small_bar.png"), 36, 12, 16); - - ResourceLocation texture; - int width; - int height; - int count; - - private Gauge(ResourceLocation texture, int width, int height, int count) { - this.texture = texture; - this.width = width; - this.height = height; - this.count = count; - } - } - - /** - * - * @param gauge The gauge enum to use - * @param x The x coord in the GUI (left) - * @param y The y coord in the GUI (top) - * @param z The z-level (from GUI.zLevel) - * @param progress Double from 0-1 how far the gauge has progressed - */ - public static void renderGauge(Gauge gauge, double x, double y, double z, double progress) { - - Minecraft.getMinecraft().renderEngine.bindTexture(gauge.texture); - - int frameNum = (int) Math.round((gauge.count - 1) * progress); - double singleFrame = 1D / (double)gauge.count; - double frameOffset = singleFrame * frameNum; - - Tessellator tess = Tessellator.instance; - tess.startDrawingQuads(); - tess.addVertexWithUV(x, y + gauge.height, z, 0, frameOffset + singleFrame); - tess.addVertexWithUV(x + gauge.width, y + gauge.height, z, 1, frameOffset + singleFrame); - tess.addVertexWithUV(x + gauge.width, y, z, 1, frameOffset); - tess.addVertexWithUV(x, y, z, 0, frameOffset); - tess.draw(); - } - - public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color) { - drawSmoothGauge(x, y, z, progress, tipLength, backLength, backSide, color, 0x000000); - } - - public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color, int colorOuter) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - - progress = MathHelper.clamp_double(progress, 0, 1); - - float angle = (float) Math.toRadians(-progress * 270 - 45); - Vec3 tip = Vec3.createVectorHelper(0, tipLength, 0); - Vec3 left = Vec3.createVectorHelper(backSide, -backLength, 0); - Vec3 right = Vec3.createVectorHelper(-backSide, -backLength, 0); - - tip.rotateAroundZ(angle); - left.rotateAroundZ(angle); - right.rotateAroundZ(angle); - - Tessellator tess = Tessellator.instance; - tess.startDrawing(GL11.GL_TRIANGLES); - tess.setColorOpaque_I(colorOuter); - double mult = 1.5; - tess.addVertex(x + tip.xCoord * mult, y + tip.yCoord * mult, z); - tess.addVertex(x + left.xCoord * mult, y + left.yCoord * mult, z); - tess.addVertex(x + right.xCoord * mult, y + right.yCoord * mult, z); - tess.setColorOpaque_I(color); - tess.addVertex(x + tip.xCoord, y + tip.yCoord, z); - tess.addVertex(x + left.xCoord, y + left.yCoord, z); - tess.addVertex(x + right.xCoord, y + right.yCoord, z); - tess.draw(); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } -} diff --git a/src/main/java/com/hbm/util/Vec3NT.java b/src/main/java/com/hbm/util/Vec3NT.java index 240e08530..63577e2eb 100644 --- a/src/main/java/com/hbm/util/Vec3NT.java +++ b/src/main/java/com/hbm/util/Vec3NT.java @@ -6,17 +6,10 @@ import net.minecraft.util.Vec3; public class Vec3NT extends Vec3 { - public Vec3NT(double x, double y, double z) { - super(x, y, z); - } - - public Vec3NT(Vec3 vec) { - super(vec.xCoord, vec.yCoord, vec.zCoord); - } - - public Vec3NT(Entity e) { - super(e.posX, e.posY, e.posZ); - } + public Vec3NT() { super(0, 0, 0); } + public Vec3NT(double x, double y, double z) { super(x, y, z); } + public Vec3NT(Vec3 vec) { super(vec.xCoord, vec.yCoord, vec.zCoord); } + public Vec3NT(Entity e) { super(e.posX, e.posY, e.posZ); } public Vec3NT eyeHeight(Entity e) { return this.add(0, e.getEyeHeight(), 0); } public Vec3NT halfHeight(Entity e) { return this.add(0, e.height / 2D, 0); }