TechReborn/src/main/java/techreborn/client/container/ContainerAlloyFurnace.java

95 lines
3 KiB
Java
Raw Normal View History

2015-05-10 20:00:58 +02:00
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
2015-08-10 20:28:52 +02:00
import net.minecraft.inventory.ICrafting;
2015-05-10 20:00:58 +02:00
import net.minecraft.inventory.Slot;
2015-11-08 13:15:45 +01:00
import reborncore.client.gui.SlotOutput;
import reborncore.common.container.RebornContainer;
2015-05-10 20:00:58 +02:00
import techreborn.tiles.TileAlloyFurnace;
2015-11-08 13:15:45 +01:00
public class ContainerAlloyFurnace extends RebornContainer {
2015-05-10 20:00:58 +02:00
EntityPlayer player;
TileAlloyFurnace tile;
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public int tickTime;
public ContainerAlloyFurnace(TileAlloyFurnace tileAlloyfurnace,
EntityPlayer player) {
tile = tileAlloyfurnace;
this.player = player;
// input
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 0, 47, 17));
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 1, 65, 17));
// outputs
this.addSlotToContainer(new SlotOutput(tileAlloyfurnace.inventory, 2, 116, 35));
// Fuel
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 3, 56, 53));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
2015-05-10 20:00:58 +02:00
2015-08-10 20:28:52 +02:00
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);
}
2015-11-08 13:15:45 +01:00
if (this.cookTime != tile.cookTime) {
2015-08-10 20:28:52 +02:00
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
}
}
super.detectAndSendChanges();
}
@Override
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
2015-11-08 13:15:45 +01:00
if (id == 0) {
2015-08-10 20:28:52 +02:00
this.currentItemBurnTime = value;
2015-11-08 13:15:45 +01:00
} else if (id == 1) {
2015-08-10 20:28:52 +02:00
this.burnTime = value;
2015-11-08 13:15:45 +01:00
} else if (id == 2) {
2015-08-10 20:28:52 +02:00
this.cookTime = value;
}
this.tile.currentItemBurnTime = this.currentItemBurnTime;
this.tile.burnTime = this.burnTime;
this.tile.cookTime = this.cookTime;
}
2015-05-10 20:00:58 +02:00
}