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

100 lines
3.2 KiB
Java
Raw Normal View History

2015-06-14 17:42:03 +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-06-14 17:42:03 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
2015-11-08 13:15:45 +01:00
import reborncore.common.container.RebornContainer;
import techreborn.config.ConfigTechReborn;
2015-06-14 17:42:03 +02:00
import techreborn.tiles.lesu.TileLesu;
2015-11-08 13:15:45 +01:00
public class ContainerLesu extends RebornContainer {
2015-06-14 17:42:03 +02:00
EntityPlayer player;
TileLesu tile;
@Override
public boolean canInteractWith(EntityPlayer player) {
2015-06-14 17:42:03 +02:00
return true;
}
public int euOut;
public int storedEu;
public int euChange;
public int connectedBlocks;
public double euStorage;
public ContainerLesu(TileLesu tileaesu,
EntityPlayer player) {
2015-06-14 17:42:03 +02:00
tile = tileaesu;
this.player = player;
// input
this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 116, 23));
this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
2015-06-14 17:42:03 +02:00
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
2015-10-09 23:23:21 +02:00
+ 9, 8 + j * 18, 84 + i * 18));
2015-06-14 17:42:03 +02:00
}
}
for (i = 0; i < 9; ++i) {
2015-10-09 23:23:21 +02:00
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
2015-06-14 17:42:03 +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());
2015-06-14 17:42:03 +02:00
}
if (this.storedEu != tile.getEnergy()) {
icrafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
2015-06-14 17:42:03 +02:00
}
if (this.euChange != tile.getEuChange() && tile.getEuChange() != -1) {
2015-06-14 17:42:03 +02:00
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
}
if (this.connectedBlocks != tile.connectedBlocks) {
2015-06-14 17:42:03 +02:00
icrafting.sendProgressBarUpdate(this, 3, tile.connectedBlocks);
}
}
}
@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());
crafting.sendProgressBarUpdate(this, 3, tile.connectedBlocks);
2015-06-14 17:42:03 +02:00
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 0) {
2015-06-14 17:42:03 +02:00
this.euOut = value;
} else if (id == 1) {
2015-06-14 17:42:03 +02:00
this.storedEu = value;
} else if (id == 2) {
2015-06-14 17:42:03 +02:00
this.euChange = value;
} else if (id == 3) {
2015-06-14 17:42:03 +02:00
this.connectedBlocks = value;
} else if (id == 4) {
2015-06-14 17:42:03 +02:00
this.euStorage = value;
}
this.euStorage = ((connectedBlocks + 1) * ConfigTechReborn.lesuStoragePerBlock);
2015-06-14 17:42:03 +02:00
}
}