From 0c4895efa489f0557c05c54a1bd0cf7322d04373 Mon Sep 17 00:00:00 2001 From: ProfessorProspector Date: Sun, 8 Jan 2017 14:46:13 -0800 Subject: [PATCH] Electric Furnace gui! --- .../java/techreborn/client/gui/GuiBase.java | 2 +- .../client/gui/GuiElectricFurnace.java | 53 +++++++------------ .../java/techreborn/client/gui/TRBuilder.java | 11 ++++ .../compat/jei/TechRebornJeiPlugin.java | 9 ++-- .../tiles/teir1/TileElectricFurnace.java | 17 +++--- 5 files changed, 43 insertions(+), 49 deletions(-) diff --git a/src/main/java/techreborn/client/gui/GuiBase.java b/src/main/java/techreborn/client/gui/GuiBase.java index 50dbc4a0d..49f2c27ff 100644 --- a/src/main/java/techreborn/client/gui/GuiBase.java +++ b/src/main/java/techreborn/client/gui/GuiBase.java @@ -51,7 +51,7 @@ public class GuiBase extends GuiContainer { x += guiLeft; y += guiTop; } - builder.drawOutputSlot(this, x - 1, y - 1); + builder.drawOutputSlot(this, x - 5, y - 5); } protected void drawSelectedStack(int x, int y, Layer layer) { diff --git a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java index 84456ec6d..2400e5efe 100644 --- a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java @@ -1,53 +1,36 @@ 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.util.ResourceLocation; -import net.minecraft.util.text.translation.I18n; - import techreborn.tiles.teir1.TileElectricFurnace; -public class GuiElectricFurnace extends GuiContainer { +public class GuiElectricFurnace extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png"); + TileElectricFurnace tile; - TileElectricFurnace furnace; - - public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace furnace) { - super(furnace.createContainer(player)); - this.xSize = 176; - this.ySize = 167; - this.furnace = furnace; + public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(GuiElectricFurnace.texture); - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = this.furnace.gaugeProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - j = this.furnace.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, mouseX, mouseY, layer); } @Override - protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { - final String name = I18n.translateToLocal("tile.techreborn.electricfurnace.name"); - this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, - 4210752); - this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.gaugeProgressScaled(100), 100, 76, 48, 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 535c88f59..c9b5e79b0 100644 --- a/src/main/java/techreborn/client/gui/TRBuilder.java +++ b/src/main/java/techreborn/client/gui/TRBuilder.java @@ -1,6 +1,7 @@ package techreborn.client.gui; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextFormatting; @@ -182,6 +183,16 @@ public class TRBuilder extends GuiBuilder { } } + public void drawSlot(GuiScreen gui, int posX, int posY) { + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(posX, posY, 150, 0, 18, 18); + } + + public void drawOutputSlot(GuiScreen gui, int posX, int posY) { + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(posX, posY, 150, 18, 26, 26); + } + public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) { return (int) (((float) burnTime / (float) totalBurnTime) * scale); } diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index e313d597b..787337c90 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -202,13 +202,17 @@ public class TechRebornJeiPlugin extends BlankModPlugin { I18n.translateToLocal("techreborn.desc.scrapBox")); } + //NEW ONES + registry.addRecipeClickArea(GuiCentrifuge.class, 150, 4, 20, 12, RecipeCategoryUids.CENTRIFUGE); + registry.addRecipeClickArea(GuiElectricFurnace.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.SMELTING); + registry.addRecipeClickArea(GuiGenerator.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.FUEL); + + //OLD ONES registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, VanillaRecipeCategoryUid.FUEL); registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE); registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE); - registry.addRecipeClickArea(GuiCentrifuge.class, 150, 4, 20, 12, RecipeCategoryUids.CENTRIFUGE); - registry.addRecipeClickArea(GuiGenerator.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.FUEL); registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR); registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR); registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER); @@ -223,7 +227,6 @@ public class TechRebornJeiPlugin extends BlankModPlugin { registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR); registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING, VanillaRecipeCategoryUid.FUEL); - registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING); registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18, EFluidGenerator.SEMIFLUID.getRecipeID()); diff --git a/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java b/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java index 504e71d52..53bb7e844 100644 --- a/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java +++ b/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java @@ -5,22 +5,23 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.EnumFacing; - import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; - import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; public class TileElectricFurnace extends TilePowerAcceptor - implements IWrenchable, IInventoryProvider, IContainerProvider { + implements IWrenchable, IInventoryProvider, IContainerProvider { + private static final int[] SLOTS_TOP = new int[] { 0 }; + private static final int[] SLOTS_BOTTOM = new int[] { 1 }; + private static final int[] SLOTS_SIDES = new int[] { 1 }; public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this); public int capacity = 1000; public int progress; @@ -28,9 +29,6 @@ public class TileElectricFurnace extends TilePowerAcceptor public int cost = 8; int input1 = 0; int output = 1; - private static final int[] SLOTS_TOP = new int[] { 0 }; - private static final int[] SLOTS_BOTTOM = new int[] { 1 }; - private static final int[] SLOTS_SIDES = new int[] { 1 }; public TileElectricFurnace() { super(1); @@ -215,9 +213,8 @@ public class TileElectricFurnace extends TilePowerAcceptor @Override public BuiltContainer createContainer(final EntityPlayer player) { - return new ContainerBuilder("electricfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) - .addInventory().tile(this).slot(0, 56, 34).outputSlot(1, 116, 34).upgradeSlot(2, 152, 8) - .upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue() - .syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(); + return new ContainerBuilder("electricfurnace").player(player.inventory).inventory().hotbar() + .addInventory().tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue() + .syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(); } }