aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/tileentities
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2021-05-20 23:07:24 +0000
committerAlkalus <draknyte1@hotmail.com>2021-05-20 23:07:24 +0000
commit7881c840421c191e8c4249fc303e184fa1cbf9a8 (patch)
tree0e1f8d8d19ca14e14dfb16c1ed49750935612dfa /src/Java/gtPlusPlus/core/tileentities
parentde40c882cb16535deae1c29b22f1a535747db536 (diff)
parent5316a0ffcbc403e17a06d4c9e28d57e202f0aafe (diff)
downloadGT5-Unofficial-7881c840421c191e8c4249fc303e184fa1cbf9a8.tar.gz
GT5-Unofficial-7881c840421c191e8c4249fc303e184fa1cbf9a8.tar.bz2
GT5-Unofficial-7881c840421c191e8c4249fc303e184fa1cbf9a8.zip
Merged in MultiFixes (pull request #11)
MultiFixes
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities')
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java15
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java4
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java359
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java3
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java403
5 files changed, 773 insertions, 11 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
index 2d389d8bb2..62b545c5c8 100644
--- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
+++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
@@ -5,13 +5,7 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.general.BlockSuperLight.TileEntitySuperLight;
import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox;
import gtPlusPlus.core.lib.LoadedMods;
-import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer;
-import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest;
-import gtPlusPlus.core.tileentities.general.TileEntityFirepit;
-import gtPlusPlus.core.tileentities.general.TileEntityFishTrap;
-import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid;
-import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase;
-import gtPlusPlus.core.tileentities.general.TileEntityXpConverter;
+import gtPlusPlus.core.tileentities.general.*;
import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector;
import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable;
import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller;
@@ -47,7 +41,11 @@ public class ModTileEntities {
GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight");
GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller");
GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator");
-
+ GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox");
+
+ if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) {
+ GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter");
+ }
//Mod TEs
if (LoadedMods.Thaumcraft){
@@ -59,6 +57,7 @@ public class ModTileEntities {
private static void blacklistTilesFromAcceleration() {
Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityFishTrap");
Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest");
+ Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEggBox");
}
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
index c184b47d25..db93e9c4fc 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
@@ -90,14 +90,14 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
boolean a1, a2;
int u = 0;
- a1 = b.getIsActive(world, iStack);
+ a1 = b.isTicking(world, iStack);
a2 = false;
int SECONDS_TO_PROCESS = 1;
while (u < (20 * SECONDS_TO_PROCESS)) {
if (!a1) {
break;
}
- a1 = b.getIsActive(world, iStack);
+ a1 = b.isTicking(world, iStack);
a2 = b.tickItemTag(world, iStack);
u++;
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java
new file mode 100644
index 0000000000..0c428537cb
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java
@@ -0,0 +1,359 @@
+package gtPlusPlus.core.tileentities.general;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.inventories.Inventory_EggBox;
+import gtPlusPlus.core.item.general.ItemGiantEgg;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class TileEntityEggBox extends TileEntity implements ISidedInventory {
+
+ private final Inventory_EggBox inventoryContents;
+
+ /** Determines if the check for adjacent chests has taken place. */
+ public boolean adjacentChestChecked;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityEggBox adjacentChestZNeg;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityEggBox adjacentChestXPos;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityEggBox adjacentChestXNeg;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityEggBox adjacentChestZPos;
+ /** The current angle of the lid (between 0 and 1) */
+ public float lidAngle;
+ /** The angle of the lid last tick */
+ public float prevLidAngle;
+ /** The number of players currently using this chest */
+ public int numPlayersUsing;
+
+ private String customName;
+
+ private int cachedChestType;
+ private int tickCount = 0;
+
+ public TileEntityEggBox() {
+ this.inventoryContents = new Inventory_EggBox();
+ }
+
+ public Inventory_EggBox getInventory() {
+ return this.inventoryContents;
+ }
+
+ @Override
+ public void updateEntity() {
+
+ // Try do chesty stuff
+ try {
+ this.updateEntityChest();
+ } catch (Throwable t) {
+
+ }
+
+ try {
+ if (!this.worldObj.isRemote) {
+ this.tickCount++;
+ if ((this.tickCount % 10) == 0) {
+ cachedChestType = 1;
+ }
+
+ if ((this.tickCount % 20) == 0) {
+ for (ItemStack inv : this.getInventory().getInventory()) {
+ if (inv == null) {
+ continue;
+ }
+ if (inv.getItem() instanceof ItemGiantEgg) {
+ ItemGiantEgg D = (ItemGiantEgg) inv.getItem();
+ tryUpdateDecayable(D, inv, this.worldObj);
+ }
+ }
+
+ }
+ updateSlots();
+ }
+ } catch (final Throwable t) {
+ }
+ }
+
+ public void tryUpdateDecayable(final ItemGiantEgg d, ItemStack iStack, final World world) {
+ if (world == null || iStack == null) {
+ return;
+ }
+ if (world.isRemote) {
+ return;
+ }
+
+ boolean a1, a2;
+ int u = 0;
+ a1 = d.isTicking(world, iStack);
+ a2 = false;
+ int SECONDS_TO_PROCESS = 1;
+ while (u < (20 * SECONDS_TO_PROCESS)) {
+ if (!a1) {
+ break;
+ }
+ a1 = d.isTicking(world, iStack);
+ a2 = d.tickItemTag(world, iStack);
+ u++;
+ }
+ Logger.MACHINE_INFO("| "+d.getUnlocalizedName()+" | "+a1+"/"+a2);
+
+ if (!a1 && !a2) {
+ ItemStack replacement = ItemUtils.getSimpleStack(d.getHatchResult(), 1);
+ replacement.stackSize = 1;
+ //iStack = replacement.copy();
+ for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) {
+ if (this.inventoryContents.getStackInSlot(fff) == iStack) {
+ this.inventoryContents.setInventorySlotContents(fff, replacement.copy());
+ }
+ }
+
+ updateSlots();
+ this.inventoryContents.
+ markDirty();
+ }
+ }
+
+ public boolean anyPlayerInRange() {
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null;
+ }
+
+ public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) {
+ if (!nbt.hasKey(tag)) {
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public void writeToNBT(final NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ // Utils.LOG_WARNING("Trying to write NBT data to TE.");
+ final NBTTagCompound chestData = new NBTTagCompound();
+ this.inventoryContents.writeToNBT(chestData);
+ nbt.setTag("ContentsChest", chestData);
+ if (this.hasCustomInventoryName()) {
+ nbt.setString("CustomName", this.getCustomName());
+ }
+ }
+
+ @Override
+ public void readFromNBT(final NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ // Utils.LOG_WARNING("Trying to read NBT data from TE.");
+ this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest"));
+ if (nbt.hasKey("CustomName", 8)) {
+ this.setCustomName(nbt.getString("CustomName"));
+ }
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return this.getInventory().getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot) {
+ return this.getInventory().getStackInSlot(slot);
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int count) {
+ return this.getInventory().decrStackSize(slot, count);
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ return this.getInventory().getStackInSlotOnClosing(slot);
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ this.getInventory().setInventorySlotContents(slot, stack);
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return this.getInventory().getInventoryStackLimit();
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
+ return this.getInventory().isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public void openInventory() {
+ if (this.numPlayersUsing < 0) {
+ this.numPlayersUsing = 0;
+ }
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing++;
+ cachedChestType = 1;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().openInventory();
+ }
+
+ @Override
+ public void closeInventory() {
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing--;
+ cachedChestType = 1;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().closeInventory();
+ }
+
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
+ return this.getInventory().isItemValidForSlot(slot, itemstack);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
+ final int[] accessibleSides = new int[this.getSizeInventory()];
+ for (int r = 0; r < this.getInventory().getSizeInventory(); r++) {
+ accessibleSides[r] = r;
+ }
+ return accessibleSides;
+
+ }
+
+ @Override
+ public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
+ return this.getInventory().isItemValidForSlot(0, p_102007_2_);
+ }
+
+ @Override
+ public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
+ return this.getInventory().isItemValidForSlot(0, p_102008_2_);
+ }
+
+ public String getCustomName() {
+ return this.customName;
+ }
+
+ public void setCustomName(final String customName) {
+ this.customName = customName;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return this.hasCustomInventoryName() ? this.customName : "container.EggBox";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return (this.customName != null) && !this.customName.equals("");
+ }
+
+ /**
+ * Causes the TileEntity to reset all it's cached values for it's container
+ * Block, metadata and in the case of chests, the adjacent chest check
+ */
+ public void updateContainingBlockInfo() {
+ super.updateContainingBlockInfo();
+ this.adjacentChestChecked = false;
+ }
+
+ /**
+ * Performs the check for adjacent chests to determine if this chest is double
+ * or not.
+ */
+ public void checkForAdjacentChests() {
+ if (!this.adjacentChestChecked) {
+ this.adjacentChestChecked = true;
+ this.adjacentChestZNeg = null;
+ this.adjacentChestXPos = null;
+ this.adjacentChestXNeg = null;
+ this.adjacentChestZPos = null;
+ }
+ }
+
+ public void updateEntityChest() {
+ float f;
+ this.prevLidAngle = this.lidAngle;
+ f = 0.04F;
+ double d2;
+ if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null
+ && this.adjacentChestXNeg == null) {
+ double d1 = (double) this.xCoord + 0.5D;
+ d2 = (double) this.zCoord + 0.5D;
+ this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F,
+ this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
+ }
+
+ if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
+ float f1 = this.lidAngle;
+ if (this.numPlayersUsing > 0) {
+ //this.lidAngle += f;
+ this.lidAngle += (float) (f * (1 + 0.10 * 0.01));
+ } else {
+ //this.lidAngle -= f;
+ this.lidAngle -= (float) (f * (1 + 0.10 * 0.01));
+ }
+ if (this.lidAngle > 1.0F) {
+ this.lidAngle = 1.0F;
+ }
+ float f2 = 0.5F;
+ if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
+ d2 = (double) this.xCoord + 0.5D;
+ double d0 = (double) this.zCoord + 0.5D;
+ this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F,
+ this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
+ }
+
+ if (this.lidAngle < 0.0F) {
+ this.lidAngle = 0.0F;
+ }
+ }
+ }
+
+ /**
+ * Called when a client event is received with the event number and argument,
+ * see World.sendClientEvent
+ */
+ public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) {
+ if (p_145842_1_ == 1)
+ {
+ this.numPlayersUsing = p_145842_2_;
+ return true;
+ }
+ else
+ {
+ return super.receiveClientEvent(p_145842_1_, p_145842_2_);
+ }
+ }
+
+ /**
+ * invalidates a tile entity
+ */
+ public final void invalidate() {
+ super.invalidate();
+ cachedChestType = 1;
+ this.updateContainingBlockInfo();
+ this.checkForAdjacentChests();
+ }
+
+ private final int updateSlots() {
+ //Have slots changed?
+ if (cachedChestType == 0) {
+ return 0;
+ }
+ ItemUtils.organiseInventory(getInventory());
+ cachedChestType = 0;
+ return cachedChestType;
+
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
index e7c37f7994..beff269428 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
@@ -79,7 +79,8 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
}
}
if ((waterCount >= 2) && (trapCount <= 4)) {
- this.waterSides = waterCount;
+ int aCheck = trapCount + waterCount;
+ this.waterSides = MathUtils.balance(aCheck, 0, 6);
Logger.MACHINE_INFO("Valid Trap. "+waterCount+" | "+(this.tickCount/20)+"/"+(this.baseTickRate/20));
return true;
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java
new file mode 100644
index 0000000000..5b837397b1
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java
@@ -0,0 +1,403 @@
+package gtPlusPlus.core.tileentities.general;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.container.Container_VolumetricFlaskSetter;
+import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.fluids.FluidStack;
+
+public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISidedInventory {
+
+ private int tickCount = 0;
+ private final Inventory_VolumetricFlaskSetter inventoryContents;
+ private String customName;
+ public int locationX;
+ public int locationY;
+ public int locationZ;
+ private int aCurrentMode = 0;
+ private short aCustomValue = 1000;
+
+ public TileEntityVolumetricFlaskSetter() {
+ this.inventoryContents = new Inventory_VolumetricFlaskSetter();
+ this.setTileLocation();
+ }
+
+ public short getCustomValue() {
+ //Logger.INFO("Value: "+this.aCustomValue);
+ return this.aCustomValue;
+ }
+
+ public void setCustomValue(int aVal) {
+ Logger.INFO("Old Value: "+this.aCustomValue);
+ this.aCustomValue = (short) MathUtils.balance(aVal, 0, Short.MAX_VALUE);
+ Logger.INFO("New Value: "+this.aCustomValue);
+ markDirty();
+ }
+
+ public boolean setTileLocation() {
+ if (this.hasWorldObj()) {
+ if (!this.getWorldObj().isRemote) {
+ this.locationX = this.xCoord;
+ this.locationY = this.yCoord;
+ this.locationZ = this.zCoord;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //Rename to hasCircuitToConfigure
+ public final boolean hasFlask() {
+ for (int i=0;i<this.getInventory().getInventory().length-1;i++) {
+ if (i == Container_VolumetricFlaskSetter.SLOT_OUTPUT) {
+ continue;
+ }
+ if (this.getInventory().getInventory()[i] != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Inventory_VolumetricFlaskSetter getInventory() {
+ return this.inventoryContents;
+ }
+
+ private int getFlaskType(ItemStack aStack) {
+ if (VolumetricFlaskHelper.isNormalVolumetricFlask(aStack)) {
+ return 1;
+ }
+ else if (VolumetricFlaskHelper.isLargeVolumetricFlask(aStack)) {
+ return 2;
+ }
+ else if (VolumetricFlaskHelper.isGiganticVolumetricFlask(aStack)) {
+ return 3;
+ }
+ return 0;
+ }
+
+ private int getCapacityForSlot(int aSlot) {
+ switch (aSlot) {
+ case 0: //16
+ return 16;
+ case 1: //36
+ return 36;
+ case 2: //144
+ return 144;
+ case 3: //432
+ return 432;
+ case 4: //576
+ return 576;
+ case 5: //720
+ return 720;
+ case 6: //864
+ return 864;
+ case 7: //Custom
+ return getCustomValue();
+ }
+ return 1000;
+ }
+
+ public boolean addOutput() {
+
+ // Don't do anything unless we have items
+ if (!hasFlask()) {
+ Logger.INFO("No Flasks.");
+ return false;
+ }
+
+
+ ItemStack[] aInputs = this.getInventory().getInventory().clone();
+
+
+ //Check if there is output in slot.
+ Boolean hasOutput = false;
+ if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT] != null) {
+ hasOutput = true;
+ if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT].stackSize >= 16) {
+ return false;
+ }
+ }
+ AutoMap<Integer> aValidSlots = new AutoMap<Integer>();
+ int aSlotCount = 0;
+ for (ItemStack i : aInputs) {
+ if (i != null) {
+ aValidSlots.put(aSlotCount);
+ }
+ aSlotCount++;
+ }
+ for (int e : aValidSlots) {
+
+ // Skip slot 7 (Custom) unless it has a value > 0
+ if (e == 7 && getCustomValue() <= 0) {
+ Logger.INFO("Skipping Custom slot as value <= 0");
+ continue;
+ }
+ if (e == Container_VolumetricFlaskSetter.SLOT_OUTPUT) {
+ continue;
+ }
+
+ boolean doAdd = false;
+ ItemStack g = this.getStackInSlot(e);
+ FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g);
+ int aSize = 0;
+ ItemStack aInputStack = null;
+ int aTypeInSlot = getFlaskType(g);
+ if (aTypeInSlot > 0 && g != null) {
+ // No Existing Output
+ if (!hasOutput) {
+ aSize = g.stackSize;
+ doAdd = true;
+ }
+ // Existing Output
+ else {
+ ItemStack f = aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT];
+ FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f);
+ int aTypeInCheckedSlot = getFlaskType(f);
+ // Check that the Circuit in the Output slot is not null and the same type as the circuit input.
+ if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) {
+ if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) && ((aInputFluidStack == null && aFluidInCheckedSlot == null) || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) {
+ Logger.INFO("Input Slot Flask Contains: "+(aInputFluidStack != null ? aInputFluidStack.getLocalizedName() : "Empty"));
+ Logger.INFO("Output Slot Flask Contains: "+(aFluidInCheckedSlot != null ? aFluidInCheckedSlot.getLocalizedName() : "Empty"));
+ aSize = f.stackSize + g.stackSize;
+ if (aSize > 16) {
+ aInputStack = g.copy();
+ aInputStack.stackSize = (aSize-16);
+ }
+ doAdd = true;
+ }
+ }
+ }
+ if (doAdd) {
+ // Check Circuit Type
+ ItemStack aOutput;
+ FluidStack aOutputFluid = null;
+ if (!VolumetricFlaskHelper.isFlaskEmpty(g)) {
+ aOutputFluid = aInputFluidStack.copy();
+ }
+ if (aTypeInSlot == 1) {
+ aOutput = VolumetricFlaskHelper.getVolumetricFlask(1);
+ }
+ else if (aTypeInSlot == 2) {
+ aOutput = VolumetricFlaskHelper.getLargeVolumetricFlask(1);
+ }
+ else if (aTypeInSlot == 3) {
+ aOutput = VolumetricFlaskHelper.getGiganticVolumetricFlask(1);
+ }
+ else {
+ aOutput = null;
+ }
+ if (aOutput != null) {
+ aOutput.stackSize = aSize;
+ int aCapacity = getCapacityForSlot(e);
+ VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, aCapacity);
+ if (aOutputFluid != null) {
+ if (aOutputFluid.amount > aCapacity) {
+ aOutputFluid.amount = aCapacity;
+ }
+ VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid);
+ }
+ this.setInventorySlotContents(e, aInputStack);
+ this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput);
+ return true;
+ }
+ }
+ }
+ continue;
+ }
+ return false;
+ }
+
+ @Override
+ public void updateEntity() {
+ try{
+ if (!this.worldObj.isRemote) {
+ if (tickCount % 10 == 0) {
+ if (hasFlask()) {
+ this.addOutput();
+ this.markDirty();
+ }
+ }
+ this.tickCount++;
+ }
+ }
+ catch (final Throwable t){}
+ }
+
+ public boolean anyPlayerInRange() {
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null;
+ }
+
+ public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) {
+ if (!nbt.hasKey(tag)) {
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public void writeToNBT(final NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ // Utils.LOG_WARNING("Trying to write NBT data to TE.");
+ final NBTTagCompound chestData = new NBTTagCompound();
+ this.inventoryContents.writeToNBT(chestData);
+ nbt.setTag("ContentsChest", chestData);
+ nbt.setShort("aCustomValue", aCustomValue);
+ if (this.hasCustomInventoryName()) {
+ nbt.setString("CustomName", this.getCustomName());
+ }
+ nbt.setInteger("aCurrentMode", aCurrentMode);
+ }
+
+ @Override
+ public void readFromNBT(final NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ // Utils.LOG_WARNING("Trying to read NBT data from TE.");
+ this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest"));
+ this.aCustomValue = nbt.getShort("aCustomValue");
+ if (nbt.hasKey("CustomName", 8)) {
+ this.setCustomName(nbt.getString("CustomName"));
+ }
+ aCurrentMode = nbt.getInteger("aCurrentMode");
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return this.getInventory().getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot) {
+ return this.getInventory().getStackInSlot(slot);
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int count) {
+ return this.getInventory().decrStackSize(slot, count);
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ return this.getInventory().getStackInSlotOnClosing(slot);
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ this.getInventory().setInventorySlotContents(slot, stack);
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return this.getInventory().getInventoryStackLimit();
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
+ return this.getInventory().isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public void openInventory() {
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().openInventory();
+ }
+
+ @Override
+ public void closeInventory() {
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().closeInventory();
+ }
+
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
+ return this.getInventory().isItemValidForSlot(slot, itemstack);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
+ final int[] accessibleSides = new int[this.getSizeInventory()];
+ for (int r=0; r<this.getInventory().getSizeInventory(); r++){
+ accessibleSides[r]=r;
+ }
+ return accessibleSides;
+
+ }
+
+ @Override
+ public boolean canInsertItem(final int aSlot, final ItemStack p_102007_2_, final int p_102007_3_) {
+ return aSlot == aCurrentMode;
+ }
+
+ @Override
+ public boolean canExtractItem(final int aSlot, final ItemStack p_102008_2_, final int p_102008_3_) {
+ return aSlot == Container_VolumetricFlaskSetter.SLOT_OUTPUT;
+ }
+
+ public String getCustomName() {
+ return this.customName;
+ }
+
+ public void setCustomName(final String customName) {
+ this.customName = customName;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return this.hasCustomInventoryName() ? this.customName : "container.VolumetricFlaskSetter";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return (this.customName != null) && !this.customName.equals("");
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ final NBTTagCompound tag = new NBTTagCompound();
+ this.writeToNBT(tag);
+ return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag);
+ }
+
+ @Override
+ public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) {
+ final NBTTagCompound tag = pkt.func_148857_g();
+ this.readFromNBT(tag);
+ }
+
+ public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) {
+
+ if (player.isSneaking()) {
+ PlayerUtils.messagePlayer(player, "Value: "+this.getCustomValue());
+ }
+
+ try {
+ if (aCurrentMode == 7) {
+ aCurrentMode = 0;
+ }
+ else {
+ aCurrentMode++;
+ }
+ PlayerUtils.messagePlayer(player, "Slot "+aCurrentMode+" is now default.");
+ return true;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ }
+
+}