From 369a19b2396fa2346f8add98548f9d4b88ba73ff Mon Sep 17 00:00:00 2001 From: drcrazy Date: Tue, 3 Oct 2017 14:44:08 +0300 Subject: [PATCH] Updated alloy smelter GUI to use guiBase --- .../client/gui/GuiAlloySmelter.java | 70 ++++++------------- .../compat/jei/TechRebornJeiPlugin.java | 4 +- .../AlloySmelterRecipeCategory.java | 34 +++------ .../AlloySmelterRecipeWrapper.java | 27 ++++--- .../tiles/teir1/TileAlloySmelter.java | 19 ++--- 5 files changed, 54 insertions(+), 100 deletions(-) diff --git a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java index b82f87ece..6a6ca4cdd 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java +++ b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java @@ -24,66 +24,40 @@ 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.client.resources.I18n; import techreborn.tiles.teir1.TileAlloySmelter; -public class GuiAlloySmelter extends GuiContainer { +public class GuiAlloySmelter extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/electric_alloy_furnace.png"); + TileAlloySmelter tile; - TileAlloySmelter alloysmelter; + public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; - public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter alloySmelter) { - super(alloySmelter.createContainer(player)); - this.xSize = 176; - this.ySize = 167; - this.alloysmelter = alloySmelter; } @Override - public void initGui() { - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; + + this.drawSlot(8, 72, layer); + + this.drawSlot(34, 47, layer); + this.drawSlot(126, 47, layer); + this.drawOutputSlot(80, 47, layer); + + this.builder.drawJEIButton(this, 150, 4, layer); } @Override - protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { - this.drawDefaultBackground(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(GuiAlloySmelter.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 drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; - int j = 0; - - j = this.alloysmelter.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16); - } - - j = this.alloysmelter.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { - final String name = I18n.format("tile.techreborn:alloy_smelter.name"); - this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, - 4210752); - this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, TRBuilder.ProgressDirection.LEFT, layer); + this.builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index f0ad41dd1..568beca76 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -296,14 +296,14 @@ public class TechRebornJeiPlugin implements IModPlugin { registry.addRecipeClickArea(GuiDieselGenerator.class, 150, 4, 18, 18, EFluidGenerator.DIESEL.getRecipeID()); registry.addRecipeClickArea(GuiGasTurbine.class, 150, 4, 18, 18, EFluidGenerator.GAS.getRecipeID()); registry.addRecipeClickArea(GuiThermalGenerator.class, 150, 4, 18, 18, EFluidGenerator.THERMAL.getRecipeID()); + registry.addRecipeClickArea(GuiAlloySmelter.class, 150, 4, 18, 18, RecipeCategoryUids.ALLOY_SMELTER); + //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(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR); - registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE); registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING, VanillaRecipeCategoryUid.FUEL); diff --git a/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java b/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java index a8133d24f..7a431283b 100644 --- a/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java @@ -28,9 +28,8 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.*; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; -import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiAlloySmelter; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import techreborn.lib.ModInfo; @@ -39,19 +38,16 @@ import javax.annotation.Nonnull; @SuppressWarnings("deprecation") public class AlloySmelterRecipeCategory implements IRecipeCategory { + 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 }; private final IDrawable background; - private final IDrawableAnimated electricity; private final String title; public AlloySmelterRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createDrawable(GuiAlloySmelter.texture, 46, 16, 91, 54); - IDrawableStatic electricityDrawable = guiHelper.createDrawable(GuiAlloySmelter.texture, 176, 0, 14, 14); - electricity = guiHelper.createAnimatedDrawable(electricityDrawable, 300, IDrawableAnimated.StartDirection.TOP, - true); - title = I18n.translateToLocal("techreborn.jei.category.alloy.furnace"); + background = guiHelper.createDrawable(texture, 0, 172, 116, 52); + title = I18n.translateToLocal("tile.techreborn:alloy_smelter.name"); } @Override @@ -78,24 +74,12 @@ public class AlloySmelterRecipeCategory implements IRecipeCategory { - private final IDrawableAnimated arrow; + private final IDrawableAnimated progressright; + private final IDrawableAnimated progressleft; public AlloySmelterRecipeWrapper( @Nonnull @@ -45,22 +47,27 @@ public class AlloySmelterRecipeWrapper extends BaseRecipeWrapper info){ - // super.addWailaInfo(info); - // info.add("Power Stored " + energy.getEnergyStored() + "/" + - // energy.getCapacity() +" EU"); - // if(crafter.currentRecipe !=null){ - // info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t"); - // } - // } - // ISidedInventory @Override public int[] getSlotsForFace(final EnumFacing side) { @@ -174,18 +164,17 @@ public class TileAlloySmelter extends TilePowerAcceptor @Override public BuiltContainer createContainer(final EntityPlayer player) { - return new ContainerBuilder("alloysmelter").player(player.inventory).inventory(8, 84).hotbar(8, 142) + return new ContainerBuilder("alloysmelter").player(player.inventory).inventory().hotbar() .addInventory().tile(this) - .filterSlot(0, 47, 17, + .filterSlot(0, 34, 47, stack -> RecipeHandler.recipeList.stream() .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe && ItemUtils.isInputEqual(recipe.getInputs().get(0), stack, true, true, true))) - .filterSlot(1, 65, 17, + .filterSlot(1, 126, 47, stack -> RecipeHandler.recipeList.stream() .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe && ItemUtils.isInputEqual(recipe.getInputs().get(1), stack, true, true, true))) - .outputSlot(2, 116, 35).energySlot(3, 56, 53).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26) - .upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory() + .outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory() .create(this); } }