2015-05-09 21:19:40 +02:00
|
|
|
package techreborn.client.container;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-24 00:31:40 +01:00
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
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;
|
2016-03-24 00:31:40 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-11-23 20:19:18 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
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;
|
2016-03-24 00:31:40 +01:00
|
|
|
|
|
|
|
private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
|
|
|
|
|
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
|
|
|
|
2016-03-24 00:31:40 +01:00
|
|
|
public ContainerAesu(TileAesu tileaesu, EntityPlayer player) {
|
2015-08-09 12:05:32 +02:00
|
|
|
tile = tileaesu;
|
|
|
|
this.player = player;
|
2015-05-09 21:19:40 +02:00
|
|
|
|
2016-03-24 00:31:40 +01:00
|
|
|
// charge
|
|
|
|
this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 152, 42));
|
|
|
|
this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 152, 58));
|
|
|
|
this.addSlotToContainer(new Slot(tileaesu.inventory, 2, 152, 78));
|
|
|
|
|
|
|
|
//Battery
|
|
|
|
this.addSlotToContainer(new Slot(tileaesu.inventory, 3, 143, 5));
|
|
|
|
|
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
|
2016-03-15 19:03:26 +01:00
|
|
|
+ 9, 8 + j * 18, 115 + 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,
|
2016-03-15 19:03:26 +01:00
|
|
|
173));
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2016-03-24 00:31:40 +01:00
|
|
|
|
|
|
|
for (int k = 0; k < 4; k++)
|
|
|
|
{
|
|
|
|
final EntityEquipmentSlot slot = equipmentSlots[k];
|
|
|
|
addSlotToContainer(new Slot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 134, 42 + k * 18)
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public int getSlotStackLimit() { return 1; }
|
|
|
|
@Override
|
|
|
|
public boolean isItemValid(ItemStack stack)
|
|
|
|
{
|
|
|
|
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
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-05-09 21:19:40 +02:00
|
|
|
}
|