Update IndustrialElectrolyzer GUI to GuiBase. Closes #1272.

Also started JEI refactoring
This commit is contained in:
drcrazy 2017-09-13 03:40:38 +03:00
parent 7cc8a4985f
commit 5d441defa7
7 changed files with 146 additions and 112 deletions

View file

@ -24,60 +24,41 @@
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.TileIndustrialElectrolyzer;
public class GuiIndustrialElectrolyzer extends GuiContainer {
public class GuiIndustrialElectrolyzer extends GuiBase {
TileIndustrialElectrolyzer tile;
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_electrolyzer.png");
TileIndustrialElectrolyzer eletrolyzer;
public GuiIndustrialElectrolyzer(final EntityPlayer player, final TileIndustrialElectrolyzer tileeletrolyzer) {
super(tileeletrolyzer.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.eletrolyzer = tileeletrolyzer;
public GuiIndustrialElectrolyzer(final EntityPlayer player, final TileIndustrialElectrolyzer tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@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;
//Battery slot
this.drawSlot(8, 72, layer);
//Input slots
this.drawSlot(47, 72, layer);
this.drawSlot(81, 72, layer);
//Output slots
this.drawOutputSlotBar(50, 23, 4, 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(GuiIndustrialElectrolyzer.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.eletrolyzer.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16);
}
j = this.eletrolyzer.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 134, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 84, 52, mouseX, mouseY, TRBuilder.ProgressDirection.UP, layer);
this.builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.format("tile.techreborn:industrial_electrolyzer.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);
}
}
}

View file

@ -111,6 +111,14 @@ public class TRBuilder extends GuiBuilder {
j = 0;
gui.drawTexturedModalRect(x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
}
if (direction.equals(ProgressDirection.UP)) {
int j = (int) ((double) progress / (double) maxProgress * 16);
if (j < 0)
j = 0;
gui.drawTexturedModalRect(x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
}
if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) {
int percentage = percentage(maxProgress, progress);
@ -379,7 +387,7 @@ public class TRBuilder extends GuiBuilder {
}
public enum ProgressDirection {
RIGHT(84, 151, 100, 151, 16, 10), LEFT(100, 161, 84, 161, 16, 10)/*, DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16)*/;
RIGHT(84, 151, 100, 151, 16, 10), LEFT(100, 161, 84, 161, 16, 10), DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16);
public int x;
public int y;
public int xActive;