Added gui elements to rolling machine. Fixes #95
This commit is contained in:
parent
364d2d68db
commit
5b2bc53cfc
2 changed files with 63 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package techreborn.client.container;
|
package techreborn.client.container;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -62,4 +63,56 @@ public class ContainerRollingMachine extends TechRebornContainer {
|
||||||
tile.inventory.setInventorySlotContents(1, output);
|
tile.inventory.setInventorySlotContents(1, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int currentItemBurnTime;
|
||||||
|
int burnTime;
|
||||||
|
int energy;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCraftingToCrafters(ICrafting crafting) {
|
||||||
|
super.addCraftingToCrafters(crafting);
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, tile.runTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, tile.tickTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges() {
|
||||||
|
for (int i = 0; i < this.crafters.size(); i++) {
|
||||||
|
ICrafting crafting = (ICrafting) this.crafters.get(i);
|
||||||
|
if (this.currentItemBurnTime != tile.runTime) {
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, tile.runTime);
|
||||||
|
}
|
||||||
|
if (this.burnTime != tile.tickTime) {
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, tile.tickTime);
|
||||||
|
}
|
||||||
|
if (this.energy != (int) tile.getEnergy()) {
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateProgressBar(int id, int value) {
|
||||||
|
super.updateProgressBar(id, value);
|
||||||
|
if(id == 0){
|
||||||
|
this.currentItemBurnTime = value;
|
||||||
|
} else if(id ==1){
|
||||||
|
this.burnTime = value;
|
||||||
|
} else if(id == 2){
|
||||||
|
this.energy = value;
|
||||||
|
}
|
||||||
|
this.tile.runTime = this.currentItemBurnTime;
|
||||||
|
this.tile.tickTime = this.burnTime;
|
||||||
|
this.tile.setEnergy(this.energy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBurnTimeRemainingScaled(int scale)
|
||||||
|
{
|
||||||
|
if(burnTime == 0 || this.currentItemBurnTime == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this.burnTime * scale / this.currentItemBurnTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,14 @@ public class GuiRollingMachine extends GuiContainer {
|
||||||
private static final ResourceLocation texture = new ResourceLocation(
|
private static final ResourceLocation texture = new ResourceLocation(
|
||||||
"techreborn", "textures/gui/rolling_machine.png");
|
"techreborn", "textures/gui/rolling_machine.png");
|
||||||
TileRollingMachine rollingMachine;
|
TileRollingMachine rollingMachine;
|
||||||
|
ContainerRollingMachine containerRollingMachine;
|
||||||
|
|
||||||
public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) {
|
public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) {
|
||||||
super(new ContainerRollingMachine(tileRollingmachine, player));
|
super(new ContainerRollingMachine(tileRollingmachine, player));
|
||||||
this.xSize = 176;
|
this.xSize = 176;
|
||||||
this.ySize = 167;
|
this.ySize = 167;
|
||||||
rollingMachine = tileRollingmachine;
|
rollingMachine = tileRollingmachine;
|
||||||
|
containerRollingMachine = (ContainerRollingMachine) this.inventorySlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +30,14 @@ public class GuiRollingMachine extends GuiContainer {
|
||||||
int k = (this.width - this.xSize) / 2;
|
int k = (this.width - this.xSize) / 2;
|
||||||
int l = (this.height - this.ySize) / 2;
|
int l = (this.height - this.ySize) / 2;
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||||
|
|
||||||
|
int j = this.containerRollingMachine.getBurnTimeRemainingScaled(24);
|
||||||
|
this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19);
|
||||||
|
|
||||||
|
j = this.rollingMachine.getEnergyScaled(12);
|
||||||
|
if (j > 0) {
|
||||||
|
this.drawTexturedModalRect(k + 7, l + 33 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
|
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
|
||||||
|
|
Loading…
Reference in a new issue