2015-05-09 21:19:40 +02:00
|
|
|
package techreborn.client.container;
|
|
|
|
|
2015-11-23 15:40:30 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-05-09 21:19:40 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-06-10 17:12:16 +02:00
|
|
|
import net.minecraft.inventory.ICrafting;
|
2015-05-09 21:19:40 +02:00
|
|
|
import net.minecraft.inventory.Slot;
|
2015-11-08 13:15:45 +01:00
|
|
|
import reborncore.common.container.RebornContainer;
|
2015-05-09 21:19:40 +02:00
|
|
|
import techreborn.tiles.TileAesu;
|
|
|
|
|
2015-11-08 13:15:45 +01:00
|
|
|
public class ContainerAesu extends RebornContainer {
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
EntityPlayer player;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
TileAesu tile;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public boolean canInteractWith(EntityPlayer player) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public int euOut;
|
|
|
|
public int storedEu;
|
2015-06-14 12:58:56 +02:00
|
|
|
public int euChange;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public ContainerAesu(TileAesu tileaesu,
|
|
|
|
EntityPlayer player) {
|
|
|
|
tile = tileaesu;
|
|
|
|
this.player = player;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
// input
|
2015-09-05 22:09:37 +02:00
|
|
|
//this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 116, 23));
|
2015-11-08 13:15:45 +01:00
|
|
|
// this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
int i;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +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-08-09 12:05:32 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +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-08-09 12:05:32 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2015-08-09 12:05:32 +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) {
|
2015-06-14 12:58:56 +02:00
|
|
|
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-10 17:12:16 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
2015-11-23 19:41:29 +01:00
|
|
|
public void onCraftGuiOpened(ICrafting crafting) {
|
|
|
|
super.onCraftGuiOpened(crafting);
|
2015-08-09 12:05:32 +02:00
|
|
|
crafting.sendProgressBarUpdate(this, 0, (int) tile.getMaxOutput());
|
|
|
|
crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
|
|
|
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
|
|
|
}
|
2015-06-10 17:12:16 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@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) {
|
2015-06-14 12:58:56 +02:00
|
|
|
this.euChange = value;
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2015-06-10 17:12:16 +02:00
|
|
|
|
2015-05-09 21:19:40 +02:00
|
|
|
}
|