Convert VacuumFreezer and ImplosionCompressor

This commit is contained in:
Ourten 2017-01-08 16:01:24 +01:00
parent ea98e4a8a0
commit b5881e2102
6 changed files with 57 additions and 161 deletions

View file

@ -5,59 +5,61 @@ 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.client.container.ContainerImplosionCompressor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileImplosionCompressor;
public class GuiImplosionCompressor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/implosion_compressor.png");
"textures/gui/implosion_compressor.png");
TileImplosionCompressor compresser;
ContainerImplosionCompressor containerImplosionCompressor;
public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) {
super(new ContainerImplosionCompressor(tilecompresser, player));
containerImplosionCompressor = (ContainerImplosionCompressor) this.inventorySlots;
public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor tilecompressor) {
super(new ContainerBuilder("implosioncompressor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tilecompressor).slot(0, 37, 26).slot(1, 37, 44).outputSlot(2, 93, 35)
.outputSlot(3, 111, 35).syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
compresser = tilecompresser;
this.compresser = tilecompressor;
}
@Override
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
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(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.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);
if (containerImplosionCompressor.multIBlockState == 0) {
if (!this.compresser.getMutliBlock()) {
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
this.mc.getTextureManager().bindTexture(texture);
int j = compresser.getProgressScaled(24);
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture);
int j = this.compresser.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
}
j = compresser.getEnergyScaled(12);
j = this.compresser.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.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);
}

View file

@ -5,7 +5,8 @@ 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.client.container.ContainerVacuumFreezer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileVacuumFreezer;
public class GuiVacuumFreezer extends GuiContainer {
@ -14,43 +15,46 @@ public class GuiVacuumFreezer extends GuiContainer {
TileVacuumFreezer crafter;
public GuiVacuumFreezer(EntityPlayer player, TileVacuumFreezer freezer) {
super(new ContainerVacuumFreezer(freezer, player));
public GuiVacuumFreezer(final EntityPlayer player, final TileVacuumFreezer freezer) {
super(new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(freezer).slot(0, 56, 34).outputSlot(1, 116, 35).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
crafter = freezer;
this.crafter = freezer;
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.mc.getTextureManager().bindTexture(GuiVacuumFreezer.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);
int j = crafter.getProgressScaled(24);
int j = this.crafter.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 80, l + 37, 176, 14, j + 1, 16);
}
j = (int) (crafter.getEnergy() * 12f / crafter.getMaxPower());
j = (int) (this.crafter.getEnergy() * 12f / this.crafter.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
if (!crafter.getMultiBlock()) {
if (!this.crafter.getMultiBlock()) {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
j = crafter.getEnergyScaled(12);
j = this.crafter.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
@Override
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
final String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}