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

87 lines
2.6 KiB
Java
Raw Normal View History

2015-05-09 21:19:40 +02:00
package techreborn.client.container;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2015-05-09 21:19:40 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
2015-05-09 21:19:40 +02:00
import net.minecraft.inventory.Slot;
import techreborn.tiles.TileAesu;
public class ContainerAesu extends TechRebornContainer {
EntityPlayer player;
2015-05-09 21:19:40 +02:00
TileAesu tile;
2015-05-09 21:19:40 +02:00
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
2015-05-09 21:19:40 +02:00
public int euOut;
public int storedEu;
public int euChange;
2015-05-09 21:19:40 +02:00
public ContainerAesu(TileAesu tileaesu,
EntityPlayer player) {
tile = tileaesu;
this.player = player;
2015-05-09 21:19:40 +02:00
// input
2015-09-05 22:09:37 +02:00
//this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 116, 23));
// this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
2015-05-09 21:19:40 +02:00
int i;
2015-05-09 21:19:40 +02:00
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
2015-09-05 22:09:37 +02:00
+ 9, 8 + j * 18, 84 + i * 18));
}
}
2015-05-09 21:19:40 +02:00
for (i = 0; i < 9; ++i) {
2015-09-05 22:09:37 +02:00
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
2015-05-09 21:19:40 +02:00
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); i++) {
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.euOut != tile.getMaxOutput()) {
icrafting.sendProgressBarUpdate(this, 0, (int) tile.getMaxOutput());
}
if (this.storedEu != tile.getEnergy()) {
icrafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
}
if (this.euChange != tile.getEuChange() && tile.getEuChange() != -1) {
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
}
}
}
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, (int) tile.getMaxOutput());
crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 0) {
this.euOut = value;
} else if (id == 1) {
this.storedEu = value;
} else if (id == 2) {
this.euChange = value;
}
}
2015-05-09 21:19:40 +02:00
}