aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/tileentities/machines
diff options
context:
space:
mode:
authordraknyte1 <draknyte1@hotmail.com>2016-11-04 15:23:26 +1000
committerdraknyte1 <draknyte1@hotmail.com>2016-11-04 15:23:26 +1000
commit0669f5eb9d5029a8b94ec552171b0837605f7747 (patch)
tree6b40e64c04d51b7a33cf2f0b35f7232cf37c4247 /src/Java/gtPlusPlus/core/tileentities/machines
parent3654052fb63a571c5eaca7f20714b87c17f7e966 (diff)
downloadGT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.gz
GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.bz2
GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.zip
$ Cleaned up the entire project.
> Much neat, very nices.
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities/machines')
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java215
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java715
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java189
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbenchAdvanced.java288
4 files changed, 687 insertions, 720 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java
index 9ec6aa3b24..cc260527c4 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java
@@ -9,178 +9,165 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
-public class TileEntityCharger extends TileEntity implements IInventory
-{
- private ItemStack[] items = new ItemStack[1]; //18
- private int progress_Current = 1;
- private int progress_Max = 1000;
- public float charge_Current;
- public float charge_Max = 10000;
- private float tempItemChargeValue;
-
- public float getCharge(){
- return charge_Current;
- }
-
- public int getProgress(){
- return progress_Current;
- }
+public class TileEntityCharger extends TileEntity implements IInventory {
+ private ItemStack[] items = new ItemStack[1]; // 18
+ private int progress_Current = 1;
+ private final int progress_Max = 1000;
+ public float charge_Current;
+ public float charge_Max = 10000;
+ private float tempItemChargeValue;
@Override
- public int getSizeInventory()
- {
- return items.length;
+ public void closeInventory() {
}
@Override
- public ItemStack getStackInSlot(int slot)
- {
- return items[slot];
- }
-
- @Override
- public ItemStack decrStackSize(int slot, int amount)
- {
- if (items[slot] != null)
- {
+ public ItemStack decrStackSize(final int slot, final int amount) {
+ if (this.items[slot] != null) {
ItemStack itemstack;
- if (items[slot].stackSize == amount)
- {
- itemstack = items[slot];
- items[slot] = null;
- markDirty();
+ if (this.items[slot].stackSize == amount) {
+ itemstack = this.items[slot];
+ this.items[slot] = null;
+ this.markDirty();
return itemstack;
}
- itemstack = items[slot].splitStack(amount);
- if (items[slot].stackSize == 0) items[slot] = null;
- markDirty();
+ itemstack = this.items[slot].splitStack(amount);
+ if (this.items[slot].stackSize == 0) {
+ this.items[slot] = null;
+ }
+ this.markDirty();
return itemstack;
}
return null;
}
- @Override
- public ItemStack getStackInSlotOnClosing(int slot)
- {
- if (items[slot] != null)
- {
- ItemStack itemstack = items[slot];
- items[slot] = null;
- return itemstack;
- }
- return null;
+ public float getCharge() {
+ return this.charge_Current;
}
@Override
- public void setInventorySlotContents(int slot, ItemStack stack)
- {
- if (stack != null){
- items[slot] = stack;
- if (stack != null && stack.stackSize > getInventoryStackLimit())
- {
- stack.stackSize = getInventoryStackLimit();
- }
+ public String getInventoryName() {
+ return "container.Charger";
+ }
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
- markDirty();
- }
+ public int getProgress() {
+ return this.progress_Current;
}
@Override
- public String getInventoryName()
- {
- return "container.Charger";
+ public int getSizeInventory() {
+ return this.items.length;
}
@Override
- public boolean hasCustomInventoryName()
- {
- return false;
+ public ItemStack getStackInSlot(final int slot) {
+ return this.items[slot];
}
@Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
- items = new ItemStack[getSizeInventory()];
-
- for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound comp = list.getCompoundTagAt(i); int j = comp.getByte("Slot") & 255; if (j >= 0 && j < items.length)
- {
- items[j] = ItemStack.loadItemStackFromNBT(comp);
- }
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ if (this.items[slot] != null) {
+ final ItemStack itemstack = this.items[slot];
+ this.items[slot] = null;
+ return itemstack;
}
+ return null;
}
@Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- NBTTagList list = new NBTTagList();
-
- for (int i = 0; i < items.length; ++i)
- {
- if (items[i] != null)
- {
- NBTTagCompound comp = new NBTTagCompound();
- comp.setByte("Slot", (byte)i);
- items[i].writeToNBT(comp);
- list.appendTag(comp);
- }
- }
-
- nbt.setTag("Items", list);
+ public boolean hasCustomInventoryName() {
+ return false;
}
@Override
- public int getInventoryStackLimit()
- {
- return 64;
+ public boolean isItemValidForSlot(final int slot, final ItemStack stack) {
+ return true;
}
@Override
- public boolean isUseableByPlayer(EntityPlayer player)
- {
- return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
+ public boolean isUseableByPlayer(final EntityPlayer player) {
+ return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
+ : player.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
}
@Override
- public void openInventory() {}
+ public void openInventory() {
+ }
@Override
- public void closeInventory() {}
+ public void readFromNBT(final NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ final NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
+ this.items = new ItemStack[this.getSizeInventory()];
+
+ for (int i = 0; i < list.tagCount(); ++i) {
+ final NBTTagCompound comp = list.getCompoundTagAt(i);
+ final int j = comp.getByte("Slot") & 255;
+ if (j >= 0 && j < this.items.length) {
+ this.items[j] = ItemStack.loadItemStackFromNBT(comp);
+ }
+ }
+ }
@Override
- public boolean isItemValidForSlot(int slot, ItemStack stack)
- {
- return true;
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ if (stack != null) {
+ this.items[slot] = stack;
+ if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
+
+ this.markDirty();
+ }
}
@Override
public void updateEntity() {
- if(!this.worldObj.isRemote){
- if (progress_Current < progress_Max){
- progress_Current++;
+ if (!this.worldObj.isRemote) {
+ if (this.progress_Current < this.progress_Max) {
+ this.progress_Current++;
}
- else if (progress_Current >= progress_Max){
- if (charge_Current < charge_Max){
- charge_Current = charge_Current+500;
- }
- if (getStackInSlot(0).getItem() instanceof BaseItemWithCharge){
+ else if (this.progress_Current >= this.progress_Max) {
+ if (this.charge_Current < this.charge_Max) {
+ this.charge_Current = this.charge_Current + 500;
+ }
+ if (this.getStackInSlot(0).getItem() instanceof BaseItemWithCharge) {
float tempCharge;
- ItemStack output = getStackInSlot(0).copy();
- if (output.stackTagCompound != null){
+ final ItemStack output = this.getStackInSlot(0).copy();
+ if (output.stackTagCompound != null) {
tempCharge = output.stackTagCompound.getFloat("charge_Current");
output.stackTagCompound = new NBTTagCompound();
- output.stackTagCompound.setFloat("charge_Current", tempCharge+40);
- this.charge_Current = charge_Current-40;
+ output.stackTagCompound.setFloat("charge_Current", tempCharge + 40);
+ this.charge_Current = this.charge_Current - 40;
tempCharge = 0;
}
}
- progress_Current = 0;
+ this.progress_Current = 0;
}
}
}
+ @Override
+ public void writeToNBT(final NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ final NBTTagList list = new NBTTagList();
+
+ for (int i = 0; i < this.items.length; ++i) {
+ if (this.items[i] != null) {
+ final NBTTagCompound comp = new NBTTagCompound();
+ comp.setByte("Slot", (byte) i);
+ this.items[i].writeToNBT(comp);
+ list.appendTag(comp);
+ }
+ }
+
+ nbt.setTag("Items", list);
+ }
+
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java
index 3a9dbbd4c7..1183b906dc 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java
@@ -12,491 +12,486 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
-public class TileEntityNHG extends TileEntity implements IInventory
-{
- private ItemStack[] items = new ItemStack[19]; //18
- private int progress = 1;
- private int maxProgress = 180;
- private int heatCycleProgress = 12;
- public float coreTemp;
- public float maxTemp = 10000;
- private boolean fuelrod_1 = false;
- private boolean fuelrod_2 = false;
- private boolean fuelrod_3 = false;
- private boolean fuelrod_4 = false;
- private boolean fuelrod_5 = false;
- private boolean fuelrod_6 = false;
- private boolean fuelrod_7 = false;
- private boolean fuelrod_8 = false;
- private boolean fuelrod_9 = false;
- private boolean fuelrod_10 = false;
- private boolean fuelrod_11 = false;
- private boolean fuelrod_12 = false;
- private boolean fuelrod_13 = false;
- private boolean fuelrod_14 = false;
- private boolean fuelrod_15 = false;
- private boolean fuelrod_16 = false;
- private boolean fuelrod_17 = false;
- private boolean fuelrod_18 = false;
-
- public float getCoreTemp(){
- return coreTemp;
- }
-
- public int getProgress(){
- return progress;
- }
-
- public boolean isValidFuelRod(ItemStack input){
- if(!this.worldObj.isRemote){
- if (input != null){
- if (input.getItem() instanceof FuelRod_Base){
- int fuelRodFuelLevel = getRodFuelValue(input);
- float fuelRodHeatLevel = getRodHeatValue(input);
- Utils.LOG_WARNING("Fuel Left: "+fuelRodFuelLevel+" Current Temp: "+fuelRodHeatLevel);
- return true;
- //return input.stackTagCompound.getInteger("code");
- }
- }
-
- }
- return false;
- }
-
- public ItemStack doFuelRodHeatDamage(ItemStack input){
- if(!this.worldObj.isRemote){
- if (input != null){
- if (isValidFuelRod(input)){
- int fuelRodFuelLevel = getRodFuelValue(input);
- float fuelRodHeatLevel = getRodHeatValue(input);
- if(fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0){
- return null;
- }
- if(fuelRodHeatLevel == 0 && fuelRodFuelLevel > 0){
- if(fuelRodFuelLevel >= 5){
- int tempInt=fuelRodFuelLevel;
- float tempFloat=fuelRodHeatLevel;
- ItemStack output = input.copy();
- if (input.stackTagCompound != null){
- output.stackTagCompound = new NBTTagCompound();
- output.stackTagCompound.setInteger("fuelRemaining", tempInt-40);
- output.stackTagCompound.setFloat("heat", tempFloat+20);
- }
- return output;
- }
- return null;
- }
- else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel > 0){
- int tempInt=fuelRodFuelLevel;
- float tempFloat=fuelRodHeatLevel;
- ItemStack output = input.copy();
- if (input.stackTagCompound != null){
- output.stackTagCompound = new NBTTagCompound();
- output.stackTagCompound.setInteger("fuelRemaining", tempInt-5);
- output.stackTagCompound.setFloat("heat", tempFloat+5);
- }
- return output;
- }
+public class TileEntityNHG extends TileEntity implements IInventory {
+ private ItemStack[] items = new ItemStack[19]; // 18
+ private int progress = 1;
+ private final int maxProgress = 180;
+ private int heatCycleProgress = 12;
+ public float coreTemp;
+ public float maxTemp = 10000;
+ private boolean fuelrod_1 = false;
+ private boolean fuelrod_2 = false;
+ private boolean fuelrod_3 = false;
+ private boolean fuelrod_4 = false;
+ private boolean fuelrod_5 = false;
+ private boolean fuelrod_6 = false;
+ private boolean fuelrod_7 = false;
+ private boolean fuelrod_8 = false;
+ private boolean fuelrod_9 = false;
+ private boolean fuelrod_10 = false;
+ private boolean fuelrod_11 = false;
+ private boolean fuelrod_12 = false;
+ private boolean fuelrod_13 = false;
+ private boolean fuelrod_14 = false;
+ private boolean fuelrod_15 = false;
+ private boolean fuelrod_16 = false;
+ private boolean fuelrod_17 = false;
+ private boolean fuelrod_18 = false;
+
+ // Machine Code - TODO
+ private ItemStack neutrons;
- else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0){
- ItemStack output = input.copy();
- if (input.stackTagCompound != null){
- output.stackTagCompound = new NBTTagCompound();
- output.stackTagCompound.setInteger("heat", -5);
- }
- return output;
- }
- else {
- return null;
+ public boolean calculateHeat() {
+ /*
+ * if (!fuelrod_1 || !fuelrod_2 || !fuelrod_3 || !fuelrod_4 ||
+ * !fuelrod_5 || !fuelrod_6 || !fuelrod_7 || !fuelrod_8 || !fuelrod_9 ||
+ * !fuelrod_10 || !fuelrod_11 || !fuelrod_12 || !fuelrod_13 ||
+ * !fuelrod_14 || !fuelrod_15 || !fuelrod_16 || !fuelrod_17 ||
+ * !fuelrod_18){ coreTemp = 0; } else {
+ */
+ if (!this.worldObj.isRemote) {
+ for (int i = 0; i < this.getSizeInventory(); i++) {
+ if (this.items[i] != null) {
+ if (this.items[i].getItem() instanceof FuelRod_Base) {
+ final ItemStack fuelRodStack = this.getStackInSlot(i).copy();
+ // if (fuelRodStack.stackTagCompound.getFloat("heat") !=
+ // 0){
+ this.doFuelRodHeatDamage(fuelRodStack);
+ this.coreTemp = this.coreTemp + fuelRodStack.stackTagCompound.getFloat("heat");
+ return true;
+ // }
}
}
}
}
- return null;
- }
-
- public float getRodHeatValue(ItemStack value){
- if (value != null){
- if (value.stackTagCompound != null){
- return value.stackTagCompound.getFloat("heat");
- }
- }
- return 0f;
- }
+ // }
- public int getRodFuelValue(ItemStack value){
- if (value != null){
- if (value.stackTagCompound != null){
- int tempInt = value.stackTagCompound.getInteger("fuelRemaining");
- return tempInt;
- }
- }
- return 0;
+ return false;
}
- public void checkFuelRods(){
-
- if(!this.worldObj.isRemote){
- for (int i = 0; i < getSizeInventory(); i++){
- if (items[i] != null){
- if (items[i].getItem() instanceof FuelRod_Base){
- ItemStack fuelRodStack = getStackInSlot(i).copy();
- //setInventorySlotContents(i, doFuelRodHeatDamage(fuelRodStack));
- if (i == 0){
- fuelrod_1 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ public void checkFuelRods() {
+
+ if (!this.worldObj.isRemote) {
+ for (int i = 0; i < this.getSizeInventory(); i++) {
+ if (this.items[i] != null) {
+ if (this.items[i].getItem() instanceof FuelRod_Base) {
+ final ItemStack fuelRodStack = this.getStackInSlot(i).copy();
+ // setInventorySlotContents(i,
+ // doFuelRodHeatDamage(fuelRodStack));
+ if (i == 0) {
+ this.fuelrod_1 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 1){
- fuelrod_2 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 1) {
+ this.fuelrod_2 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 2){
- fuelrod_3 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 2) {
+ this.fuelrod_3 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 3){
- fuelrod_4 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 3) {
+ this.fuelrod_4 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 4){
- fuelrod_5 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 4) {
+ this.fuelrod_5 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 5){
- fuelrod_6 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 5) {
+ this.fuelrod_6 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 6){
- fuelrod_7 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 6) {
+ this.fuelrod_7 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 7){
- fuelrod_8 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 7) {
+ this.fuelrod_8 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 8){
- fuelrod_9 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 8) {
+ this.fuelrod_9 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 9){
- fuelrod_10 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 9) {
+ this.fuelrod_10 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 10){
- fuelrod_11 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 10) {
+ this.fuelrod_11 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 11){
- fuelrod_12 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 11) {
+ this.fuelrod_12 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 12){
- fuelrod_13 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 12) {
+ this.fuelrod_13 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 13){
- fuelrod_14 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 13) {
+ this.fuelrod_14 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 14){
- fuelrod_15 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 14) {
+ this.fuelrod_15 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 15){
- fuelrod_16 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 15) {
+ this.fuelrod_16 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 16){
- fuelrod_17 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 16) {
+ this.fuelrod_17 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
- else if (i == 17){
- fuelrod_18 = true;
- ItemStack r = doFuelRodHeatDamage(fuelRodStack);
- setInventorySlotContents(i, r);
+ else if (i == 17) {
+ this.fuelrod_18 = true;
+ final ItemStack r = this.doFuelRodHeatDamage(fuelRodStack);
+ this.setInventorySlotContents(i, r);
}
-
}
}
}
- Utils.LOG_WARNING("|"+fuelrod_1+"|"+fuelrod_2+"|"+fuelrod_3+"| "+"|"+fuelrod_10+"|"+fuelrod_11+"|"+fuelrod_12+"|");
- Utils.LOG_WARNING("|"+fuelrod_4+"|"+fuelrod_5+"|"+fuelrod_6+"| "+"|"+fuelrod_13+"|"+fuelrod_14+"|"+fuelrod_15+"|");
- Utils.LOG_WARNING("|"+fuelrod_7+"|"+fuelrod_8+"|"+fuelrod_9+"| "+"|"+fuelrod_16+"|"+fuelrod_17+"|"+fuelrod_18+"|");
+ Utils.LOG_WARNING(
+ "|" + this.fuelrod_1 + "|" + this.fuelrod_2 + "|" + this.fuelrod_3 + "| " + "|"
+ + this.fuelrod_10 + "|" + this.fuelrod_11 + "|" + this.fuelrod_12 + "|");
+ Utils.LOG_WARNING(
+ "|" + this.fuelrod_4 + "|" + this.fuelrod_5 + "|" + this.fuelrod_6 + "| " + "|"
+ + this.fuelrod_13 + "|" + this.fuelrod_14 + "|" + this.fuelrod_15 + "|");
+ Utils.LOG_WARNING(
+ "|" + this.fuelrod_7 + "|" + this.fuelrod_8 + "|" + this.fuelrod_9 + "| " + "|"
+ + this.fuelrod_16 + "|" + this.fuelrod_17 + "|" + this.fuelrod_18 + "|");
}
}
- public boolean calculateHeat(){
- /*if (!fuelrod_1 || !fuelrod_2 || !fuelrod_3 || !fuelrod_4 || !fuelrod_5 || !fuelrod_6 || !fuelrod_7 || !fuelrod_8 || !fuelrod_9 || !fuelrod_10 || !fuelrod_11 || !fuelrod_12 || !fuelrod_13 || !fuelrod_14 || !fuelrod_15 || !fuelrod_16 || !fuelrod_17 || !fuelrod_18){
- coreTemp = 0;
+ @Override
+ public void closeInventory() {
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int amount) {
+ if (this.items[slot] != null) {
+ ItemStack itemstack;
+
+ if (this.items[slot].stackSize == amount) {
+ itemstack = this.items[slot];
+ this.items[slot] = null;
+ this.markDirty();
+ return itemstack;
+ }
+ itemstack = this.items[slot].splitStack(amount);
+ if (this.items[slot].stackSize == 0) {
+ this.items[slot] = null;
+ }
+ this.markDirty();
+ return itemstack;
}
- else {*/
- if(!this.worldObj.isRemote){
- for (int i = 0; i < getSizeInventory(); i++){
- if (items[i] != null){
- if (items[i].getItem() instanceof FuelRod_Base){
- ItemStack fuelRodStack = getStackInSlot(i).copy();
- //if (fuelRodStack.stackTagCompound.getFloat("heat") != 0){
- doFuelRodHeatDamage(fuelRodStack);
- coreTemp = coreTemp+fuelRodStack.stackTagCompound.getFloat("heat");
- return true;
- //}
+ return null;
+ }
+
+ public ItemStack doFuelRodHeatDamage(final ItemStack input) {
+ if (!this.worldObj.isRemote) {
+ if (input != null) {
+ if (this.isValidFuelRod(input)) {
+ final int fuelRodFuelLevel = this.getRodFuelValue(input);
+ final float fuelRodHeatLevel = this.getRodHeatValue(input);
+ if (fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0) {
+ return null;
+ }
+ if (fuelRodHeatLevel == 0 && fuelRodFuelLevel > 0) {
+ if (fuelRodFuelLevel >= 5) {
+ final int tempInt = fuelRodFuelLevel;
+ final float tempFloat = fuelRodHeatLevel;
+ final ItemStack output = input.copy();
+ if (input.stackTagCompound != null) {
+ output.stackTagCompound = new NBTTagCompound();
+ output.stackTagCompound.setInteger("fuelRemaining", tempInt - 40);
+ output.stackTagCompound.setFloat("heat", tempFloat + 20);
+ }
+ return output;
+ }
+ return null;
+ }
+ else if (fuelRodHeatLevel >= 5 && fuelRodFuelLevel > 0) {
+ final int tempInt = fuelRodFuelLevel;
+ final float tempFloat = fuelRodHeatLevel;
+ final ItemStack output = input.copy();
+ if (input.stackTagCompound != null) {
+ output.stackTagCompound = new NBTTagCompound();
+ output.stackTagCompound.setInteger("fuelRemaining", tempInt - 5);
+ output.stackTagCompound.setFloat("heat", tempFloat + 5);
+ }
+ return output;
+ }
+
+ else if (fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0) {
+ final ItemStack output = input.copy();
+ if (input.stackTagCompound != null) {
+ output.stackTagCompound = new NBTTagCompound();
+ output.stackTagCompound.setInteger("heat", -5);
+ }
+ return output;
+ }
+ else {
+ return null;
}
}
}
}
- //}
-
-
+ return null;
+ }
- return false;
+ public float getCoreTemp() {
+ return this.coreTemp;
}
@Override
- public int getSizeInventory()
- {
- return items.length;
+ public String getInventoryName() {
+ return "container.NHG";
}
@Override
- public ItemStack getStackInSlot(int slot)
- {
-
- return items[slot];
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+ public int getProgress() {
+ return this.progress;
}
- @Override
- public ItemStack decrStackSize(int slot, int amount)
- {
- if (items[slot] != null)
- {
- ItemStack itemstack;
+ public int getRodFuelValue(final ItemStack value) {
+ if (value != null) {
+ if (value.stackTagCompound != null) {
+ final int tempInt = value.stackTagCompound.getInteger("fuelRemaining");
+ return tempInt;
+ }
+ }
+ return 0;
+ }
- if (items[slot].stackSize == amount)
- {
- itemstack = items[slot];
- items[slot] = null;
- markDirty();
- return itemstack;
+ public float getRodHeatValue(final ItemStack value) {
+ if (value != null) {
+ if (value.stackTagCompound != null) {
+ return value.stackTagCompound.getFloat("heat");
}
- itemstack = items[slot].splitStack(amount);
- if (items[slot].stackSize == 0) items[slot] = null;
- markDirty();
- return itemstack;
}
- return null;
+ return 0f;
}
@Override
- public ItemStack getStackInSlotOnClosing(int slot)
- {
- if (items[slot] != null)
- {
- ItemStack itemstack = items[slot];
- items[slot] = null;
- return itemstack;
- }
- return null;
+ public int getSizeInventory() {
+ return this.items.length;
}
@Override
- public void setInventorySlotContents(int slot, ItemStack stack)
- {
- if (stack != null){
- items[slot] = stack;
- if (stack != null && stack.stackSize > getInventoryStackLimit())
- {
- stack.stackSize = getInventoryStackLimit();
- }
+ public ItemStack getStackInSlot(final int slot) {
+ return this.items[slot];
- markDirty();
- }
}
@Override
- public String getInventoryName()
- {
- return "container.NHG";
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ if (this.items[slot] != null) {
+ final ItemStack itemstack = this.items[slot];
+ this.items[slot] = null;
+ return itemstack;
+ }
+ return null;
}
@Override
- public boolean hasCustomInventoryName()
- {
+ public boolean hasCustomInventoryName() {
return false;
}
@Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
- items = new ItemStack[getSizeInventory()];
-
- for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound comp = list.getCompoundTagAt(i); int j = comp.getByte("Slot") & 255; if (j >= 0 && j < items.length)
- {
- items[j] = ItemStack.loadItemStackFromNBT(comp);
- }
- }
+ public boolean isItemValidForSlot(final int slot, final ItemStack stack) {
+ return true;
}
@Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- NBTTagList list = new NBTTagList();
-
- for (int i = 0; i < items.length; ++i)
- {
- if (items[i] != null)
- {
- NBTTagCompound comp = new NBTTagCompound();
- comp.setByte("Slot", (byte)i);
- items[i].writeToNBT(comp);
- list.appendTag(comp);
+ public boolean isUseableByPlayer(final EntityPlayer player) {
+ return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
+ : player.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
+ }
+
+ public boolean isValidFuelRod(final ItemStack input) {
+ if (!this.worldObj.isRemote) {
+ if (input != null) {
+ if (input.getItem() instanceof FuelRod_Base) {
+ final int fuelRodFuelLevel = this.getRodFuelValue(input);
+ final float fuelRodHeatLevel = this.getRodHeatValue(input);
+ Utils.LOG_WARNING("Fuel Left: " + fuelRodFuelLevel + " Current Temp: " + fuelRodHeatLevel);
+ return true;
+ // return input.stackTagCompound.getInteger("code");
+ }
}
- }
- nbt.setTag("Items", list);
+ }
+ return false;
}
@Override
- public int getInventoryStackLimit()
- {
- return 64;
+ public void openInventory() {
}
- @Override
- public boolean isUseableByPlayer(EntityPlayer player)
- {
- return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
+ public void readCustomNBT(final NBTTagCompound tag) {
+ this.neutrons = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Neutrons"));
+ this.progress = tag.getInteger("Progress");
+ this.coreTemp = tag.getFloat("coreTemp");
}
@Override
- public void openInventory() {}
+ public void readFromNBT(final NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ final NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
+ this.items = new ItemStack[this.getSizeInventory()];
+
+ for (int i = 0; i < list.tagCount(); ++i) {
+ final NBTTagCompound comp = list.getCompoundTagAt(i);
+ final int j = comp.getByte("Slot") & 255;
+ if (j >= 0 && j < this.items.length) {
+ this.items[j] = ItemStack.loadItemStackFromNBT(comp);
+ }
+ }
+ }
@Override
- public void closeInventory() {}
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ if (stack != null) {
+ this.items[slot] = stack;
+ if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
- @Override
- public boolean isItemValidForSlot(int slot, ItemStack stack)
- {
- return true;
+ this.markDirty();
+ }
}
- //Machine Code - TODO
- private ItemStack neutrons;
-
@Override
public void updateEntity() {
- if(!this.worldObj.isRemote){
+ if (!this.worldObj.isRemote) {
- if(progress >= heatCycleProgress){
- //Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 376);
- if (MathUtils.divideXintoY(heatCycleProgress, maxProgress)){
- Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 378);
- calculateHeat();
- heatCycleProgress=0;
+ if (this.progress >= this.heatCycleProgress) {
+ // Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity
+ // "+this.getBlockType().getUnlocalizedName(), 376);
+ if (MathUtils.divideXintoY(this.heatCycleProgress, this.maxProgress)) {
+ Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity " + this.getBlockType().getUnlocalizedName(),
+ 378);
+ this.calculateHeat();
+ this.heatCycleProgress = 0;
}
- }
-
- if(++progress >= maxProgress){
+ }
+ if (++this.progress >= this.maxProgress) {
- Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 338);
- if (items[18] != null){
- ItemStack checkOutput = getStackInSlot(18);
- if(neutrons == null){
- neutrons = new ItemStack(ModItems.itemHeliumBlob, 1);
- if (checkOutput == null){
+ Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity " + this.getBlockType().getUnlocalizedName(), 338);
+ if (this.items[18] != null) {
+ final ItemStack checkOutput = this.getStackInSlot(18);
+ if (this.neutrons == null) {
+ this.neutrons = new ItemStack(ModItems.itemHeliumBlob, 1);
+ if (checkOutput == null) {
Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack.");
-