Charge bench GUI

This commit is contained in:
ProfessorProspector 2017-01-08 14:27:45 -08:00
parent eea9b83a9c
commit 8b56947c28
2 changed files with 22 additions and 42 deletions

View file

@ -1,55 +1,35 @@
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.TileChargeBench;
public class GuiChargeBench extends GuiContainer {
public class GuiChargeBench extends GuiBase {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/chargebench.png");
TileChargeBench tile;
TileChargeBench chargebench;
public GuiChargeBench(final EntityPlayer player, final TileChargeBench chargeBench) {
super(chargeBench.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.chargebench = chargeBench;
public GuiChargeBench(final EntityPlayer player, final TileChargeBench tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@Override
public void initGui() {
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
super.initGui();
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final Layer layer = Layer.BACKGROUND;
this.drawSlot(62, 25, layer);
this.drawSlot(98, 25, layer);
this.drawSlot(62, 45, layer);
this.drawSlot(98, 45, layer);
this.drawSlot(62, 65, layer);
this.drawSlot(98, 65, layer);
}
@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(GuiChargeBench.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 Layer layer = Layer.FOREGROUND;
int j = 0;
j = this.chargebench.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 10, l + 32 + 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.translateToLocal("tile.techreborn.chargebench.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);
this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
}

View file

@ -136,8 +136,8 @@ implements IWrenchable, IInventoryProvider, ISidedInventory, IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("chargebench").player(player.inventory).inventory().hotbar(8, 142).addInventory()
.tile(this).energySlot(0, 62, 21).energySlot(1, 80, 21).energySlot(2, 98, 21).energySlot(3, 62, 39)
.energySlot(4, 80, 39).energySlot(5, 98, 39).syncEnergyValue().addInventory().create();
return new ContainerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
.tile(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create();
}
}