Convert IndustrialElectrolyzer, IndustrialGrinder and IndustrialSawmill

This commit is contained in:
Ourten 2017-01-08 16:20:13 +01:00
parent b5881e2102
commit bd16289c60
8 changed files with 109 additions and 228 deletions

View file

@ -5,59 +5,62 @@ 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.ContainerIndustrialElectrolyzer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileIndustrialElectrolyzer;
public class GuiIndustrialElectrolyzer extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_electrolyzer.png");
"textures/gui/industrial_electrolyzer.png");
TileIndustrialElectrolyzer eletrolyzer;
ContainerIndustrialElectrolyzer containerIndustrialElectrolyzer;
public GuiIndustrialElectrolyzer(EntityPlayer player, TileIndustrialElectrolyzer tileeletrolyzer) {
super(new ContainerIndustrialElectrolyzer(tileeletrolyzer, player));
public GuiIndustrialElectrolyzer(final EntityPlayer player, final TileIndustrialElectrolyzer tileeletrolyzer) {
super(new ContainerBuilder("industrialelectrolyzer").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tileeletrolyzer).slot(0, 80, 51).slot(1, 50, 51).outputSlot(2, 50, 19)
.outputSlot(3, 70, 19).outputSlot(4, 90, 19).outputSlot(5, 110, 19).energySlot(6, 18, 51)
.syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
eletrolyzer = tileeletrolyzer;
containerIndustrialElectrolyzer = (ContainerIndustrialElectrolyzer) this.inventorySlots;
this.eletrolyzer = tileeletrolyzer;
}
@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(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);
int j = 0;
j = eletrolyzer.getProgressScaled(24);
j = this.eletrolyzer.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16);
}
j = eletrolyzer.getEnergyScaled(12);
j = this.eletrolyzer.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 134, 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.industrialelectrolyzer.name");
this.fontRendererObj.drawString(name, (this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2), 6,
4210752);
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.industrialelectrolyzer.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.ySize - 96 + 2, 4210752);
}
}

View file

@ -8,76 +8,78 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fluids.FluidStack;
import techreborn.client.container.ContainerIndustrialGrinder;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileIndustrialGrinder;
public class GuiIndustrialGrinder extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_grinder.png");
"textures/gui/industrial_grinder.png");
TileIndustrialGrinder grinder;
ContainerIndustrialGrinder containerGrinder;
public GuiIndustrialGrinder(EntityPlayer player, TileIndustrialGrinder tilegrinder) {
super(new ContainerIndustrialGrinder(tilegrinder, player));
public GuiIndustrialGrinder(final EntityPlayer player, final TileIndustrialGrinder tilegrinder) {
super(new ContainerBuilder("industrialgrinder").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tilegrinder).slot(0, 32, 26).slot(1, 32, 44).outputSlot(2, 77, 35)
.outputSlot(3, 95, 35).outputSlot(4, 113, 35).outputSlot(5, 131, 35).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
grinder = tilegrinder;
containerGrinder = (ContainerIndustrialGrinder) this.inventorySlots;
this.grinder = tilegrinder;
}
@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(GuiIndustrialGrinder.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 progress = grinder.getProgressScaled(24);
final int progress = this.grinder.getProgressScaled(24);
if (progress > 0) {
this.drawTexturedModalRect(k + 50, l + 35, 176, 14, progress + 1, 16);
}
int energy = (int) (grinder.getEnergy() * 12f / grinder.getMaxPower());
final int energy = (int) (this.grinder.getEnergy() * 12f / this.grinder.getMaxPower());
if (energy > 0) {
this.drawTexturedModalRect(k + 132, l + 63 + 12 - energy, 176, 12 - energy, 14, energy + 2);
}
if (!grinder.tank.isEmpty()) {
drawFluid(grinder.tank.getFluid(), k + 11, l + 66, 12, 47, grinder.tank.getCapacity());
if (!this.grinder.tank.isEmpty()) {
this.drawFluid(this.grinder.tank.getFluid(), k + 11, l + 66, 12, 47, this.grinder.tank.getCapacity());
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37);
this.mc.renderEngine.bindTexture(GuiIndustrialGrinder.texture);
this.drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37);
}
if (!grinder.getMutliBlock()) {
if (!this.grinder.getMutliBlock()) {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
}
public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
ResourceLocation still = fluid.getFluid().getStill(fluid);
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString());
public void drawFluid(final FluidStack fluid, final int x, final int y, final int width, final int height, final int maxCapacity) {
this.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final ResourceLocation still = fluid.getFluid().getStill(fluid);
final TextureAtlasSprite sprite = this.mc.getTextureMapBlocks().getAtlasSprite(still.toString());
int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height);
int iconHeight = sprite.getIconHeight();
final int drawHeight = (int) (fluid.amount / (maxCapacity * 1F) * height);
final int iconHeight = sprite.getIconHeight();
int offsetHeight = drawHeight;
int iteration = 0;
while (offsetHeight != 0) {
int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
this.drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
offsetHeight -= curHeight;
iteration++;
if (iteration > 50)
@ -86,12 +88,13 @@ public class GuiIndustrialGrinder extends GuiContainer {
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.industrialgrinder.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.industrialgrinder.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -8,18 +8,22 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fluids.FluidStack;
import techreborn.client.container.ContainerIndustrialSawmill;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileIndustrialSawmill;
public class GuiIndustrialSawmill extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_sawmill.png");
"textures/gui/industrial_sawmill.png");
TileIndustrialSawmill sawmill;
public GuiIndustrialSawmill(EntityPlayer player, TileIndustrialSawmill tilesawmill) {
super(new ContainerIndustrialSawmill(tilesawmill, player));
public GuiIndustrialSawmill(final EntityPlayer player, final TileIndustrialSawmill tilesawmill) {
super(new ContainerBuilder("chemicalreactor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tilesawmill).slot(0, 70, 21).slot(1, 90, 21).outputSlot(2, 80, 51)
.energySlot(3, 8, 51).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44)
.upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.sawmill = tilesawmill;
@ -27,55 +31,55 @@ public class GuiIndustrialSawmill extends GuiContainer {
@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(GuiIndustrialSawmill.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 progress = sawmill.getProgressScaled(24);
final int progress = this.sawmill.getProgressScaled(24);
this.drawTexturedModalRect(k + 56, l + 38, 176, 14, progress - 1, 11);
int energy = 13 - (int) (sawmill.getEnergy() / sawmill.getMaxPower() * 13F);
drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy);
final int energy = 13 - (int) (this.sawmill.getEnergy() / this.sawmill.getMaxPower() * 13F);
this.drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy);
if (!sawmill.tank.isEmpty()) {
drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity());
if (!this.sawmill.tank.isEmpty()) {
this.drawFluid(this.sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, this.sawmill.tank.getCapacity());
int j = sawmill.getEnergyScaled(12);
final int j = this.sawmill.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 33, l + 65 + 12 - j, 176, 12 - j, 14, j + 2);
}
if (!sawmill.getMutliBlock()) {
if (!this.sawmill.getMutliBlock()) {
//GuiUtil.drawTooltipBox(k + 30, l + 50 + 12, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
l + 52 + 12, -1);
l + 52 + 12, -1);
}
}
}
public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
ResourceLocation still = fluid.getFluid().getStill(fluid);
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString());
public void drawFluid(final FluidStack fluid, final int x, final int y, final int width, final int height, final int maxCapacity) {
this.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final ResourceLocation still = fluid.getFluid().getStill(fluid);
final TextureAtlasSprite sprite = this.mc.getTextureMapBlocks().getAtlasSprite(still.toString());
int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height);
int iconHeight = sprite.getIconHeight();
final int drawHeight = (int) (fluid.amount / (maxCapacity * 1F) * height);
final int iconHeight = sprite.getIconHeight();
int offsetHeight = drawHeight;
int iteration = 0;
while (offsetHeight != 0) {
int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
this.drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
offsetHeight -= curHeight;
iteration++;
if (iteration > 50)
@ -84,8 +88,9 @@ public class GuiIndustrialSawmill extends GuiContainer {
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 58, this.ySize - 96 + 2, 4210752);
}