From 2a781969394e5e86c4a87dbe3a475817a770606d Mon Sep 17 00:00:00 2001 From: ProfessorProspector Date: Sun, 8 Jan 2017 12:29:14 -0800 Subject: [PATCH] Revamp centrifuge jei support --- .../java/techreborn/client/gui/GuiBase.java | 6 +-- .../techreborn/client/gui/GuiCentrifuge.java | 20 +++------- .../java/techreborn/client/gui/TRBuilder.java | 29 ++++++++------- .../centrifuge/CentrifugeRecipeCategory.java | 16 ++++---- .../centrifuge/CentrifugeRecipeWrapper.java | 35 +++++------------- .../java/techreborn/tiles/TileCentrifuge.java | 13 +++---- .../techreborn/textures/gui/centrifuge.png | Bin 1569 -> 0 bytes .../assets/techreborn/textures/gui/jei.png | Bin 0 -> 1911 bytes 8 files changed, 48 insertions(+), 71 deletions(-) delete mode 100644 src/main/resources/assets/techreborn/textures/gui/centrifuge.png create mode 100644 src/main/resources/assets/techreborn/textures/gui/jei.png diff --git a/src/main/java/techreborn/client/gui/GuiBase.java b/src/main/java/techreborn/client/gui/GuiBase.java index e8d755abf..50dbc4a0d 100644 --- a/src/main/java/techreborn/client/gui/GuiBase.java +++ b/src/main/java/techreborn/client/gui/GuiBase.java @@ -3,11 +3,11 @@ package techreborn.client.gui; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import techreborn.client.container.builder.BuiltContainer; import techreborn.client.gui.widget.GuiButtonPowerBar; /** @@ -19,9 +19,9 @@ public class GuiBase extends GuiContainer { public int ySize = 176; public TRBuilder builder = new TRBuilder(); public TileEntity tile; - public Container container; + public BuiltContainer container; - public GuiBase(EntityPlayer player, TileEntity tile, Container container) { + public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) { super(container); this.tile = tile; this.container = container; diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java index a4623c5ae..64c14fe5b 100644 --- a/src/main/java/techreborn/client/gui/GuiCentrifuge.java +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -1,23 +1,15 @@ package techreborn.client.gui; import net.minecraft.entity.player.EntityPlayer; - import techreborn.tiles.TileCentrifuge; public class GuiCentrifuge extends GuiBase { - TileCentrifuge centrifuge; + TileCentrifuge tile; - public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge centrifuge) { - super(player, centrifuge, centrifuge.createContainer(player)); - this.centrifuge = centrifuge; - } - - @Override - public void initGui() { - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - super.initGui(); + public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override @@ -43,7 +35,7 @@ public class GuiCentrifuge extends GuiBase { super.drawGuiContainerForegroundLayer(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; - this.builder.drawProgressBar(this, this.centrifuge.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); - this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.centrifuge.getEnergy(), (int) this.centrifuge.getMaxPower(), mouseX, mouseY, 0, layer); + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/TRBuilder.java b/src/main/java/techreborn/client/gui/TRBuilder.java index df6dd0c69..e933cdd53 100644 --- a/src/main/java/techreborn/client/gui/TRBuilder.java +++ b/src/main/java/techreborn/client/gui/TRBuilder.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.client.config.GuiUtils; +import net.minecraftforge.fml.common.Loader; import reborncore.client.guibuilder.GuiBuilder; import reborncore.common.powerSystem.PowerSystem; import techreborn.lib.ModInfo; @@ -91,19 +92,21 @@ public class TRBuilder extends GuiBuilder { } public void drawJEIButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) { - if (layer == GuiBase.Layer.BACKGROUND) { - x += gui.getGuiLeft(); - y += gui.getGuiTop(); - } - if (layer == GuiBase.Layer.FOREGROUND) { - mouseX -= gui.getGuiLeft(); - mouseY -= gui.getGuiTop(); - } - gui.mc.getTextureManager().bindTexture(GUI_SHEET); - if (isInRect(x, y, 20, 12, mouseX, mouseY)) { - gui.drawTexturedModalRect(x, y, 184, 82, 20, 12); - } else { - gui.drawTexturedModalRect(x, y, 184, 70, 20, 12); + if (Loader.isModLoaded("jei")) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + if (isInRect(x, y, 20, 12, mouseX, mouseY)) { + gui.drawTexturedModalRect(x, y, 184, 82, 20, 12); + } else { + gui.drawTexturedModalRect(x, y, 184, 70, 20, 12); + } } } diff --git a/src/main/java/techreborn/compat/jei/centrifuge/CentrifugeRecipeCategory.java b/src/main/java/techreborn/compat/jei/centrifuge/CentrifugeRecipeCategory.java index fd57190c9..ee7751099 100644 --- a/src/main/java/techreborn/compat/jei/centrifuge/CentrifugeRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/centrifuge/CentrifugeRecipeCategory.java @@ -14,14 +14,14 @@ import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class CentrifugeRecipeCategory extends BlankRecipeCategory { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png"); + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] OUTPUT_SLOTS = { 2, 3, 4, 5 }; private final IDrawable background; private final String title; public CentrifugeRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createDrawable(texture, 49, 4, 78, 78); + background = guiHelper.createDrawable(texture, 0, 0, 104, 62); title = I18n.translateToLocal("tile.techreborn.centrifuge.name"); } @@ -52,13 +52,13 @@ public class CentrifugeRecipeCategory extends BlankRecipeCategory { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png"); - private final IDrawableAnimated progressUp; - private final IDrawableAnimated progressLeft; - private final IDrawableAnimated progressDown; private final IDrawableAnimated progressRight; public CentrifugeRecipeWrapper( @@ -25,37 +21,26 @@ public class CentrifugeRecipeWrapper extends BaseRecipeWrapper CentrifugeRecipe baseRecipe) { super(baseRecipe); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressUpStatic = guiHelper.createDrawable(texture, 176, 14, 12, 12); - IDrawableStatic progressLeftStatic = guiHelper.createDrawable(texture, 176, 26, 12, 12); - IDrawableStatic progressDownStatic = guiHelper.createDrawable(texture, 176, 38, 12, 12); - IDrawableStatic progressRightStatic = guiHelper.createDrawable(texture, 176, 50, 12, 12); + IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10); int ticksPerCycle = baseRecipe.tickTime() / 4; // speed up the animation - // a bit - this.progressUp = guiHelper.createAnimatedDrawable(progressUpStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.BOTTOM, false); - this.progressLeft = guiHelper.createAnimatedDrawable(progressLeftStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.RIGHT, false); - this.progressDown = guiHelper.createAnimatedDrawable(progressDownStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.TOP, false); - this.progressRight = guiHelper.createAnimatedDrawable(progressRightStatic, ticksPerCycle, + + this.progressRight = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false); } @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progressUp.draw(minecraft, 33, 18); - progressLeft.draw(minecraft, 18, 33); - progressDown.draw(minecraft, 33, 48); - progressRight.draw(minecraft, 48, 33); + progressRight.draw(minecraft, 25, 26); - int x = -45; - int y = 60; + int x = -10; + int y1 = 3; + int y2 = 52; int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; - minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", x, y, 0x444444); - minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); + minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth("Time: " + baseRecipe.tickTime / 20 + " secs") / 2) - 40, y1, 0x444444); + minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth("EU: " + baseRecipe.euPerTick + " EU/t") / 2) - 40, y2, 0x444444); } } diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index 1d642c24c..84eb7fd0d 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; - import reborncore.api.IListInfoProvider; import reborncore.api.power.EnumPowerTier; import reborncore.api.power.IEnergyItemInfo; @@ -15,7 +14,6 @@ import reborncore.common.powerSystem.PoweredItem; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; - import techreborn.api.Reference; import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; @@ -28,7 +26,7 @@ import techreborn.utils.upgrade.UpgradeHandler; import java.util.List; public class TileCentrifuge extends TilePowerAcceptor -implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider { + implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this); @@ -185,11 +183,10 @@ implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterPro @Override public BuiltContainer createContainer(final EntityPlayer player) { - return new ContainerBuilder("centrifuge").player(player.inventory).inventory(8, 84).hotbar(8, 142) - .addInventory().tile(this).slot(0, 80, 35).slot(1, 50, 5).outputSlot(2, 80, 5).outputSlot(3, 110, 35) - .outputSlot(4, 80, 65).outputSlot(5, 50, 35).energySlot(6, 8, 51).upgradeSlot(7, 152, 8) - .upgradeSlot(8, 152, 26).upgradeSlot(9, 152, 44).upgradeSlot(10, 152, 62).syncEnergyValue() - .syncCrafterValue().addInventory().create(); + return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar() + .addInventory().tile(this).slot(0, 40, 34).slot(1, 40, 54).outputSlot(2, 82, 44).outputSlot(3, 101, 25) + .outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue() + .syncCrafterValue().addInventory().create(); } } diff --git a/src/main/resources/assets/techreborn/textures/gui/centrifuge.png b/src/main/resources/assets/techreborn/textures/gui/centrifuge.png deleted file mode 100644 index a1f11c51291bf990be40fa4180eefa95593ba459..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1569 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5C#Tjh5(-s*V58bpoqD-d1z>8 zSy@?4P0cxZu?uoySLH;m%8A~T6}~MiazRP*hLYrMWvN?gvgh^G4jJnlwKG3vZ*juf z!+_th%luX?+UDTl$@{PvV3H-_3I@UW{v=?=K2>c*}6RyupYe_$$Ni z?+1h!HtV;f&0|($n9E#Z&k{9*#d|$-6obYtk$IJhC1+lK*qDC&?0r7@>dib14tp6s z-q$yrXYEkKqmah5q9oYFj!(cimN7K1`+eU3f1lpue{YLyb7*B({%Fupv90((C!>~) zjO|N-8|zxD=d!%lZ}hv*X3h}2oqOTRmzN)Yj^$vquyvTc{P6L4vf+lDVH;GZRoTnT zEmt%#b~qsmjJH`_0Js`4)r5cf*}w3|+dd+3Xts?mm3Q=v5yf z1yqXy0%RRNzUR9wq|LHn|J2ai%1ar)9m~t@M^OXf6fwWaPrdrBLsrolLoUJnMBfBO z4B-vRB`gj9RahAs^80RyZsS8&@P_NQ=r(l@28Y=7`xzW0-qqzBi!yLHKVScUxq~&U f=Oh*UsPs0!@s)X5jDNq|f=u>w^>bP0l+XkKiA+~{ diff --git a/src/main/resources/assets/techreborn/textures/gui/jei.png b/src/main/resources/assets/techreborn/textures/gui/jei.png new file mode 100644 index 0000000000000000000000000000000000000000..cc2b9bfcfb08db83c2907d1da95a5c98175b8556 GIT binary patch literal 1911 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&di49pAxJ|V6^adUI??(Xhm$BzB~{~yR51*0J_azY?oGI=v7*OUbL1q0Ln zNCphS-`Q1xG0$1x5n0T@AXEgxjB%;akAZ^hC7!;n><_pE`2~#IPOk-(F_I;&5hcO- zX(i=}MX3x0iJ5sNdU>fO3MP66dWHsTxwsB6Ffi@$ba4!+hzTt9L zxmcJ%z7^Mje{stg=2QnTpm0CPvpwK`c5H6`OkY01hPC|f<|IyL`fzRmgU*_SdnF*g>{laBFZu35xjW1zvnU0?8kq5to{?9U*} ziW$oe?0I=ZwjqDHbbYOBY~sC=H~a^zo2~VYfu7y)W-UWbZ9v28dGd=G_80>-gWNrx zq5ofP@nmI|8?KBN-(h}i_`BB!m3v0;pZA++kpCP0)>;C6W4>l7LxeZuhG|R*x~vDH vxEi*KFl1{oTnl0tmB0)VSGfl@|5)#oS{r)peDeyJ*cm)s{an^LB{Ts5_pMH@ literal 0 HcmV?d00001