aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/miscutil')
-rw-r--r--src/Java/miscutil/core/gui/machine/GUI_NHG.java3
-rw-r--r--src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java108
-rw-r--r--src/Java/miscutil/core/tileentities/TileEntityNHG.java273
3 files changed, 326 insertions, 58 deletions
diff --git a/src/Java/miscutil/core/gui/machine/GUI_NHG.java b/src/Java/miscutil/core/gui/machine/GUI_NHG.java
index 6078a5ad00..632e9e29ac 100644
--- a/src/Java/miscutil/core/gui/machine/GUI_NHG.java
+++ b/src/Java/miscutil/core/gui/machine/GUI_NHG.java
@@ -43,6 +43,7 @@ public class GUI_NHG extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRendererObj.drawString(I18n.format(te.getInventoryName()), (xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), 6, 4210752, false);
- fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752);
+ //fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752);
+ fontRendererObj.drawString(I18n.format("CoreTemp:"+te.getCoreTemp()+"K"), 8, ySize - 96 + 2, 4210752);
}
} \ No newline at end of file
diff --git a/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java b/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java
index aedf91f66a..9a3de2c08f 100644
--- a/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java
+++ b/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java
@@ -4,11 +4,13 @@ import java.util.List;
import miscutil.core.creative.AddToCreativeTab;
import miscutil.core.lib.CORE;
-import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
public class FuelRod_Base extends Item{
@@ -16,10 +18,8 @@ public class FuelRod_Base extends Item{
public int maximumFuel = 0;
public String fuelType = "";
public float heat = 0;
- public float maxHeat = 5000;
+ public float maxHeat = getMaxHeat();
private ItemStack thisStack = null;
- private int internalClock = 0;
-
public FuelRod_Base(String unlocalizedName, String type, int fuelLeft, int maxFuel) {
this.setUnlocalizedName(unlocalizedName);
this.setTextureName(CORE.MODID + ":" + unlocalizedName);
@@ -30,35 +30,56 @@ public class FuelRod_Base extends Item{
this.fuelType = type;
this.setCreativeTab(AddToCreativeTab.tabMachines);
}
- @Override
- public boolean onEntityItemUpdate(EntityItem entityItem) {
- if (internalClock <= 200){
- internalClock++;
+
+ /*@Override
+ public void setDamage(ItemStack stack, int damage) {
+ this.heat=heat+5;
+ super.setDamage(stack, damage);
+ }*/
+
+ private float getMaxHeat(){
+ float tempvar;
+ if (fuelType == "Thorium"){
+ tempvar = 2500;
}
+
+ if (fuelType == "Uranium"){
+ tempvar = 5000;
+ }
+
+ if (fuelType == "Plutonium"){
+ tempvar = 10000;
+ }
+
else {
- if (heat < maxHeat){
- heat++;
- }
- if (fuelRemaining <= maximumFuel){
- fuelRemaining--;
- }
- internalClock = 0;
+ tempvar = 5000;
}
- return super.onEntityItemUpdate(entityItem);
+ return tempvar;
+
}
- @Override
- public void setDamage(ItemStack stack, int damage) {
- this.heat=heat+5;
- super.setDamage(stack, damage);
- }
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+
+ Float NBT_Heat = heat;
+ Float NBT_MaxHeat = maxHeat;
+ int NBT_Fuel = fuelRemaining;
+ String NBT_Type= fuelType;
+
thisStack = stack;
- String tempHeat = String.valueOf(heat);
- String tempFuel = String.valueOf(fuelRemaining);
- String formattedType = EnumChatFormatting.DARK_RED+fuelType+EnumChatFormatting.GRAY;
+ if (stack.stackTagCompound != null) {
+ NBT_Heat = stack.stackTagCompound.getFloat("heat");
+ NBT_MaxHeat = stack.stackTagCompound.getFloat("maxHeat");
+ NBT_Fuel = stack.stackTagCompound.getInteger("fuelRemaining");
+ NBT_Type = stack.stackTagCompound.getString("fuelType");}
+
+ String tempHeat = String.valueOf(NBT_Heat);
+ String tempMaxHeat = String.valueOf(NBT_MaxHeat);
+ String tempFuel = String.valueOf(NBT_Fuel);
+ String formattedType = EnumChatFormatting.DARK_RED+NBT_Type+EnumChatFormatting.GRAY;
String formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY;
+ String formattedMaxHeat = EnumChatFormatting.RED+tempMaxHeat+EnumChatFormatting.GRAY;
String formattedFuelLeft = tempFuel+EnumChatFormatting.GRAY;
int tempMax = maximumFuel;
@@ -89,9 +110,9 @@ public class FuelRod_Base extends Item{
formattedHeat = EnumChatFormatting.BLUE+tempHeat+EnumChatFormatting.GRAY;
}
- list.add(EnumChatFormatting.GRAY+"A "+formattedType+" fuel rod.");
- list.add(EnumChatFormatting.GRAY+"Running at "+formattedHeat+"K.");
- list.add(EnumChatFormatting.GRAY+"Currently there is: "+formattedFuelLeft+"L of fuel left.");
+ list.add(EnumChatFormatting.GRAY+"A "+formattedType+" Fuel Rod.");
+ list.add(EnumChatFormatting.GRAY+"Running at "+formattedHeat+"/"+formattedMaxHeat+" Kelvin.");
+ list.add(EnumChatFormatting.GRAY+"Fuel Remaining: "+formattedFuelLeft+"L.");
super.addInformation(stack, aPlayer, list, bool);
}
@@ -147,4 +168,37 @@ public class FuelRod_Base extends Item{
return false;
}
+
+ //Ticking and NBT Handling
+ /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
+ * update it's contents.
+ *
+ * public int fuelRemaining = 0;
+ public int maximumFuel = 0;
+ public String fuelType = "";
+ public float heat = 0;
+ public float maxHeat = 5000;
+ *
+ */
+ @Override
+ public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
+ itemStack.stackTagCompound = new NBTTagCompound();
+ itemStack.stackTagCompound.setInteger("fuelRemaining", fuelRemaining);
+ itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel);
+ itemStack.stackTagCompound.setFloat("heat", heat);
+ itemStack.stackTagCompound.setFloat("maxHeat", maxHeat);
+ itemStack.stackTagCompound.setString("fuelType", fuelType);
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ itemStack.stackTagCompound = new NBTTagCompound();
+ itemStack.stackTagCompound.setInteger("fuelRemaining", fuelRemaining);
+ itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel);
+ itemStack.stackTagCompound.setFloat("heat", heat);
+ itemStack.stackTagCompound.setFloat("maxHeat", maxHeat);
+ itemStack.stackTagCompound.setString("fuelType", fuelType);
+
+ }
+
}
diff --git a/src/Java/miscutil/core/tileentities/TileEntityNHG.java b/src/Java/miscutil/core/tileentities/TileEntityNHG.java
index 8813987a7b..b145bd2742 100644
--- a/src/Java/miscutil/core/tileentities/TileEntityNHG.java
+++ b/src/Java/miscutil/core/tileentities/TileEntityNHG.java
@@ -2,10 +2,9 @@ package miscutil.core.tileentities;
import miscutil.core.item.ModItems;
import miscutil.core.item.general.fuelrods.FuelRod_Base;
-import miscutil.core.util.UtilsItems;
+import miscutil.core.util.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -15,7 +14,187 @@ import net.minecraftforge.common.util.Constants;
public class TileEntityNHG extends TileEntity implements IInventory
{
private ItemStack[] items = new ItemStack[19]; //18
- private int internalClock = 0;
+ private int progress = 1;
+ private int maxProgress = 100;
+ 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 boolean isValidFuelRod(ItemStack input){
+ if (input != null){
+ if (input.getItem() instanceof FuelRod_Base){
+ int fuelRodFuelLevel = getRodFuelValue(input);
+ float fuelRodHeatLevel = getRodHeatValue(input);
+ if((fuelRodHeatLevel <= 0 || fuelRodHeatLevel == 0) && fuelRodFuelLevel > 0){
+
+ if(fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0){
+ return false;
+ }
+ else if(fuelRodFuelLevel >= 5){
+ input.stackTagCompound.setInteger("fuelRemaining", fuelRodFuelLevel-5);
+ input.stackTagCompound.setFloat("heat", fuelRodHeatLevel+5);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0){
+ input.stackTagCompound.setInteger("heat", -5);
+ return true;
+ }
+ else {
+ return false;
+ }
+ //return input.stackTagCompound.getInteger("code");
+ }
+ }
+
+
+ return false;
+ }
+
+ public float getRodHeatValue(ItemStack value){
+ if (value != null){
+ if (value.stackTagCompound.getFloat("heat") != 0){
+ return value.stackTagCompound.getFloat("heat");
+ }
+ return 0f;
+ }
+ return 0f;
+ }
+
+ public int getRodFuelValue(ItemStack value){
+ if (value != null){
+ if (value.stackTagCompound.getInteger("fuelRemaining") != 0){
+ return value.stackTagCompound.getInteger("fuelRemaining");
+ }
+ return 0;
+ }
+ return 0;
+ }
+
+ public void checkFuelRods(){
+ for (int i = 0; i < getSizeInventory(); i++){
+ if (items[i] != null){
+ if (items[i].getItem() instanceof FuelRod_Base){
+
+
+ ItemStack fuelRodStack = getStackInSlot(i);
+ isValidFuelRod(fuelRodStack);
+
+
+ if (i == 0){
+ fuelrod_1 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 1){
+ fuelrod_2 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 2){
+ fuelrod_3 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 3){
+ fuelrod_4 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 4){
+ fuelrod_5 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 5){
+ fuelrod_6 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 6){
+ fuelrod_7 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 7){
+ fuelrod_8 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 8){
+ fuelrod_9 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 9){
+ fuelrod_10 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 10){
+ fuelrod_11 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 11){
+ fuelrod_12 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 12){
+ fuelrod_13 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 13){
+ fuelrod_14 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 14){
+ fuelrod_15 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 15){
+ fuelrod_16 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 16){
+ fuelrod_17 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+ else if (i == 17){
+ fuelrod_18 = true;
+ isValidFuelRod(fuelRodStack);
+ }
+
+
+ }
+ }
+ }
+
+
+ }
+
+ 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;
+ }
+
+
+
+ return false;
+ }
@Override
public int getSizeInventory()
@@ -26,8 +205,8 @@ public class TileEntityNHG extends TileEntity implements IInventory
@Override
public ItemStack getStackInSlot(int slot)
{
-
- return items[slot];
+
+ return items[slot];
}
@@ -151,35 +330,69 @@ public class TileEntityNHG extends TileEntity implements IInventory
}
//Machine Code - TODO
+ private ItemStack neutrons;
@Override
- public void updateEntity() {
- if (internalClock <= 20){
- internalClock++;
+ public void updateEntity() {
+ if(++progress >= maxProgress){
+ Utils.LOG_WARNING("Updating Entity "+this.getInventoryName());
+ if (items[18] != null){
+ if(neutrons == null){
+ neutrons = new ItemStack(ModItems.itemHeliumBlob, 1);
+ ItemStack checkOutput = getStackInSlot(18);
+ if (checkOutput == null){
+ Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack.");
+ setInventorySlotContents(18, neutrons);
+ checkFuelRods();
+ }
+ else {
+ Utils.LOG_WARNING("Found an ItemStack to increase the size of.");
+ checkOutput.stackSize++;
+ checkFuelRods();
+ }
+ }
+ else if(neutrons.getItem() == ModItems.itemHeliumBlob && neutrons.stackSize < 64){
+ Utils.LOG_WARNING("Found an ItemStack to increase size of.");
+ neutrons.stackSize++;
+ checkFuelRods();
+ progress = 0;
+ }
+ }
+ else if (items[18] == null){
+ Utils.LOG_WARNING("ItemStack in Output slot is null");
+ neutrons = new ItemStack(ModItems.itemHeliumBlob, 1);
+ ItemStack checkOutput = getStackInSlot(18);
+ if (checkOutput == null){
+ Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack.");
+ setInventorySlotContents(18, neutrons);
+ checkFuelRods();
}
else {
- ItemStack validFuelRod_Type_A = UtilsItems.getSimpleStack(ModItems.FuelRod_Thorium);
- ItemStack validFuelRod_Type_B = UtilsItems.getSimpleStack(ModItems.FuelRod_Uranium);
- ItemStack validFuelRod_Type_C = UtilsItems.getSimpleStack(ModItems.FuelRod_Plutonium);
- for (int i = 0; i < getSizeInventory(); i++){
- ItemStack tempCurrent = items[i];
- if (tempCurrent == validFuelRod_Type_A ||tempCurrent == validFuelRod_Type_B || tempCurrent == validFuelRod_Type_C){
- Item tempItem = tempCurrent.getItem();
- FuelRod_Base tempItem2 = (FuelRod_Base) tempItem;
- if (tempItem2.getHeat() <= 5000){
- tempItem2.addHeat(5);
- }
- if (tempItem2.getFuelRemaining() >= 1){
- tempItem2.addFuel(-1);
- }
- ItemStack validFuelRod = UtilsItems.getSimpleStack(tempItem2);
- setInventorySlotContents(i, validFuelRod);
- }
- }
-
- internalClock=0;
- }
- super.updateEntity();
+ Utils.LOG_WARNING("Found an ItemStack to increase the size of.");
+ checkOutput.stackSize++;
+ checkFuelRods();
+ }
+ }
+ markDirty();
+ }
+ }
+
+ public void readCustomNBT(NBTTagCompound tag)
+ {
+ this.neutrons = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Neutrons"));
+ this.progress = tag.getInteger("Progress");
+ }
+
+ public void writeCustomNBT(NBTTagCompound tag)
+ {
+ tag.setInteger("Progress", this.progress);
+ if(neutrons != null) {
+ NBTTagCompound produce = new NBTTagCompound();
+ neutrons.writeToNBT(produce);
+ tag.setTag("Neutrons", produce);
+ }
+ else
+ tag.removeTag("Neutrons");
}