Added logic to alloy furnace

This commit is contained in:
modmuss50 2015-08-10 19:28:52 +01:00
parent 7f86d116cb
commit 2ff03573d9
3 changed files with 277 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileAlloyFurnace;
@ -46,4 +47,47 @@ public class ContainerAlloyFurnace extends TechRebornContainer {
}
}
int currentItemBurnTime;
int burnTime;
int cookTime;
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime);
crafting.sendProgressBarUpdate(this, 1, tile.burnTime);
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
}
@Override
public void detectAndSendChanges() {
for (int i = 0; i < this.crafters.size(); i++) {
ICrafting crafting = (ICrafting) this.crafters.get(i);
if (this.currentItemBurnTime != tile.currentItemBurnTime) {
crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime);
}
if (this.burnTime != tile.burnTime) {
crafting.sendProgressBarUpdate(this, 1, tile.burnTime);
}
if (this.cookTime != tile.cookTime) {
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
}
}
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.cookTime = value;
}
this.tile.currentItemBurnTime = this.currentItemBurnTime;
this.tile.burnTime = this.burnTime;
this.tile.cookTime = this.cookTime;
}
}

View file

@ -15,11 +15,15 @@ public class GuiAlloyFurnace extends GuiContainer {
TileAlloyFurnace alloyfurnace;
ContainerAlloyFurnace containerAlloyFurnace;
public GuiAlloyFurnace(EntityPlayer player,
TileAlloyFurnace tileAlloyFurnace) {
super(new ContainerAlloyFurnace(tileAlloyFurnace, player));
this.xSize = 176;
this.ySize = 167;
this.alloyfurnace = tileAlloyFurnace;
this.containerAlloyFurnace = (ContainerAlloyFurnace) this.inventorySlots;
}
@Override
@ -36,8 +40,18 @@ public class GuiAlloyFurnace extends GuiContainer {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.alloyfurnace.isBurning())
{
int i1 = this.alloyfurnace.getBurnTimeRemainingScaled(13);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
i1 = this.alloyfurnace.getCookProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_) {
String name = StatCollector.translateToLocal("tile.techreborn.alloyfurnace.name");