aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/core/tileentities
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-06-19 14:53:32 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-06-19 14:53:32 +1000
commitd4f11459f2e78e954a4c060c92861614c114d1cb (patch)
treea9d22e4f658e25163ae0fdbe4a1e3395da9efac9 /src/Java/miscutil/core/tileentities
parent2615992e7d0d4ed3ac205800be71c831029b2dc5 (diff)
downloadGT5-Unofficial-d4f11459f2e78e954a4c060c92861614c114d1cb.tar.gz
GT5-Unofficial-d4f11459f2e78e954a4c060c92861614c114d1cb.tar.bz2
GT5-Unofficial-d4f11459f2e78e954a4c060c92861614c114d1cb.zip
+More classes stolen from GT to implement my own items on a metaitem.
+Added LuV -> Max Voltage Machine components. +Added Rocket Engines, High tier diesel generators. +Added new textures for everything. +Added BedLocator_Base.java - Debug item for testing and NBT data storage. +Added Machine_Charger.java - Another Debug machine for testing NBT value manipulation.
Diffstat (limited to 'src/Java/miscutil/core/tileentities')
-rw-r--r--src/Java/miscutil/core/tileentities/ModTileEntities.java9
-rw-r--r--src/Java/miscutil/core/tileentities/general/TileEntityReverter.java (renamed from src/Java/miscutil/core/tileentities/TileEntityReverter.java)2
-rw-r--r--src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java186
-rw-r--r--src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java (renamed from src/Java/miscutil/core/tileentities/TileEntityNHG.java)80
4 files changed, 238 insertions, 39 deletions
diff --git a/src/Java/miscutil/core/tileentities/ModTileEntities.java b/src/Java/miscutil/core/tileentities/ModTileEntities.java
index a27e7be6ad..0f5ba5ed56 100644
--- a/src/Java/miscutil/core/tileentities/ModTileEntities.java
+++ b/src/Java/miscutil/core/tileentities/ModTileEntities.java
@@ -1,8 +1,6 @@
package miscutil.core.tileentities;
-import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator;
import miscutil.core.util.Utils;
-import cpw.mods.fml.common.registry.GameRegistry;
public class ModTileEntities {
@@ -10,9 +8,10 @@ public class ModTileEntities {
public static void init(){
Utils.LOG_INFO("Registering Tile Entities.");
//GameRegistry.registerTileEntity(TileEntityReverter.class, "TE_blockGriefSaver");
- GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower Reverter");
- GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator");
- GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium");
+ //GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower Reverter");
+ //GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator");
+ //GameRegistry.registerTileEntity(TileEntityCharger.class, "TE_Charger");
+ // GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium");
}
}
diff --git a/src/Java/miscutil/core/tileentities/TileEntityReverter.java b/src/Java/miscutil/core/tileentities/general/TileEntityReverter.java
index 4ee8eeed4b..8793271985 100644
--- a/src/Java/miscutil/core/tileentities/TileEntityReverter.java
+++ b/src/Java/miscutil/core/tileentities/general/TileEntityReverter.java
@@ -1,4 +1,4 @@
-package miscutil.core.tileentities;
+package miscutil.core.tileentities.general;
import java.util.Random;
diff --git a/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java b/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java
new file mode 100644
index 0000000000..6d78cb829e
--- /dev/null
+++ b/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java
@@ -0,0 +1,186 @@
+package miscutil.core.tileentities.machines;
+
+import miscutil.core.item.base.BaseItemWithCharge;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return items.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return items[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ if (items[slot] != null)
+ {
+ ItemStack itemstack;
+
+ if (items[slot].stackSize == amount)
+ {
+ itemstack = items[slot];
+ items[slot] = null;
+ markDirty();
+ return itemstack;
+ }
+ itemstack = items[slot].splitStack(amount);
+ if (items[slot].stackSize == 0) items[slot] = null;
+ 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;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ if (stack != null){
+ items[slot] = stack;
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+
+
+ markDirty();
+ }
+ }
+
+ @Override
+ public String getInventoryName()
+ {
+ return "container.Charger";
+ }
+
+ @Override
+ 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);
+ }
+ }
+ }
+
+ @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);
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ @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;
+ }
+
+ @Override
+ public void openInventory() {}
+
+ @Override
+ public void closeInventory() {}
+
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack stack)
+ {
+ return true;
+ }
+
+ @Override
+ public void updateEntity() {
+ if(!this.worldObj.isRemote){
+ if (progress_Current < progress_Max){
+ progress_Current++;
+ }
+ else if (progress_Current >= progress_Max){
+ if (charge_Current < charge_Max){
+ charge_Current = charge_Current+500;
+ }
+ if (getStackInSlot(0).getItem() instanceof BaseItemWithCharge){
+ float tempCharge;
+ ItemStack output = 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;
+ tempCharge = 0;
+ }
+ }
+ progress_Current = 0;
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/miscutil/core/tileentities/TileEntityNHG.java b/src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java
index 17dd8d4216..3581592c02 100644
--- a/src/Java/miscutil/core/tileentities/TileEntityNHG.java
+++ b/src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java
@@ -1,4 +1,4 @@
-package miscutil.core.tileentities;
+package miscutil.core.tileentities.machines;
import miscutil.core.item.ModItems;
import miscutil.core.item.general.fuelrods.FuelRod_Base;
@@ -49,7 +49,7 @@ public class TileEntityNHG extends TileEntity implements IInventory
public boolean isValidFuelRod(ItemStack input){
if(!this.worldObj.isRemote){
if (input != null){
- if (input.copy().getItem() instanceof FuelRod_Base){
+ if (input.getItem() instanceof FuelRod_Base){
int fuelRodFuelLevel = getRodFuelValue(input);
float fuelRodHeatLevel = getRodHeatValue(input);
Utils.LOG_WARNING("Fuel Left: "+fuelRodFuelLevel+" Current Temp: "+fuelRodHeatLevel);
@@ -64,31 +64,46 @@ public class TileEntityNHG extends TileEntity implements IInventory
public ItemStack doFuelRodHeatDamage(ItemStack input){
if(!this.worldObj.isRemote){
- if (input.copy() != null){
- if (isValidFuelRod(input.copy())){
- int fuelRodFuelLevel = getRodFuelValue(input.copy());
- float fuelRodHeatLevel = getRodHeatValue(input.copy());
- if((fuelRodHeatLevel <= 0 || fuelRodHeatLevel == 0) && fuelRodFuelLevel > 0){
-
- if(fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0){
- return null;
- }
- else if(fuelRodFuelLevel >= 5){
+ 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();
- output.stackTagCompound.setInteger("fuelRemaining", tempInt-5);
- output.stackTagCompound.setFloat("heat", tempFloat+5);
-
+ if (input.stackTagCompound != null){
+ output.stackTagCompound = new NBTTagCompound();
+ output.stackTagCompound.setInteger("fuelRemaining", tempInt-40);
+ output.stackTagCompound.setFloat("heat", tempFloat+20);
+ }
return output;
- }
- else {
- return null;
}
+ 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;
+ }
+
else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0){
- input.stackTagCompound.setInteger("heat", -5);
- return input;
+ ItemStack output = input.copy();
+ if (input.stackTagCompound != null){
+ output.stackTagCompound = new NBTTagCompound();
+ output.stackTagCompound.setInteger("heat", -5);
+ }
+ return output;
}
else {
return null;
@@ -100,18 +115,18 @@ public class TileEntityNHG extends TileEntity implements IInventory
}
public float getRodHeatValue(ItemStack value){
- if (value.copy() != null){
- if (value.copy().stackTagCompound != null){
- return value.copy().stackTagCompound.getFloat("heat");
+ if (value != null){
+ if (value.stackTagCompound != null){
+ return value.stackTagCompound.getFloat("heat");
}
}
return 0f;
}
public int getRodFuelValue(ItemStack value){
- if (value.copy() != null){
- if (value.copy().stackTagCompound != null){
- int tempInt = value.copy().stackTagCompound.getInteger("fuelRemaining");
+ if (value != null){
+ if (value.stackTagCompound != null){
+ int tempInt = value.stackTagCompound.getInteger("fuelRemaining");
return tempInt;
}
}
@@ -123,14 +138,11 @@ public class TileEntityNHG extends TileEntity implements IInventory
if(!this.worldObj.isRemote){
for (int i = 0; i < getSizeInventory(); i++){
if (items[i] != null){
- if (items[i].copy().getItem() instanceof FuelRod_Base){
+ if (items[i].getItem() instanceof FuelRod_Base){
ItemStack fuelRodStack = getStackInSlot(i).copy();
//setInventorySlotContents(i, doFuelRodHeatDamage(fuelRodStack));
if (i == 0){
- fuelrod_1 = true;
- FuelRod_Base x = (FuelRod_Base) fuelRodStack.getItem();
- x.addHeat(5);
- x.addFuel(-5);
+ fuelrod_1 = true;
ItemStack r = doFuelRodHeatDamage(fuelRodStack);
setInventorySlotContents(i, r);
}
@@ -224,7 +236,9 @@ public class TileEntityNHG extends TileEntity implements IInventory
}
}
}
-
+ 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+"|");
}
}
@@ -237,7 +251,7 @@ public class TileEntityNHG extends TileEntity implements IInventory
if(!this.worldObj.isRemote){
for (int i = 0; i < getSizeInventory(); i++){
if (items[i] != null){
- if (items[i].copy().getItem() instanceof FuelRod_Base){
+ if (items[i].getItem() instanceof FuelRod_Base){
ItemStack fuelRodStack = getStackInSlot(i).copy();
//if (fuelRodStack.stackTagCompound.getFloat("heat") != 0){
doFuelRodHeatDamage(fuelRodStack);