aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/core/item
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/item
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/item')
-rw-r--r--src/Java/miscutil/core/item/ModItems.java24
-rw-r--r--src/Java/miscutil/core/item/base/BaseItemWithCharge.java74
-rw-r--r--src/Java/miscutil/core/item/general/BedLocator_Base.java106
-rw-r--r--src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java78
4 files changed, 245 insertions, 37 deletions
diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java
index fbec6a59a3..6da428c924 100644
--- a/src/Java/miscutil/core/item/ModItems.java
+++ b/src/Java/miscutil/core/item/ModItems.java
@@ -105,6 +105,9 @@ Gold Tool: 22*/
public static Item FuelRod_Uranium;
public static Item FuelRod_Plutonium;
+ public static Item itemBedLocator_Base;
+ public static Item itemBaseItemWithCharge;
+
//@SuppressWarnings("unused")
public static final void init(){
@@ -225,10 +228,10 @@ Gold Tool: 22*/
FuelRod_Uranium = new FuelRod_Base("itemFuelRod_Uranium", "Uranium", 2500, 2500);
FuelRod_Plutonium = new FuelRod_Base("itemFuelRod_Plutonium", "Plutonium", 5000, 5000);
//Registry
- GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty");
- GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium");
- GameRegistry.registerItem(FuelRod_Uranium, "itemFuelRod_Uranium");
- GameRegistry.registerItem(FuelRod_Plutonium, "itemFuelRod_Plutonium");
+ //GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty");
+ //GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium");
+ //GameRegistry.registerItem(FuelRod_Uranium, "itemFuelRod_Uranium");
+ //GameRegistry.registerItem(FuelRod_Plutonium, "itemFuelRod_Plutonium");
}
else {
Utils.LOG_WARNING("IndustrialCraft2 not Found - Skipping Resources.");
@@ -236,6 +239,14 @@ Gold Tool: 22*/
/*
* Misc Items
*/
+
+
+ //itemBedLocator_Base = new BedLocator_Base("itemBedLocator_Base");
+ //GameRegistry.registerItem(itemBedLocator_Base, "itemBedLocator_Base");
+
+ //itemBaseItemWithCharge = new BaseItemWithCharge("itemBaseItemWithCharge", 0, 1000);
+ //GameRegistry.registerItem(itemBaseItemWithCharge, "itemBaseItemWithCharge");
+
//Staballoy Equipment
itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools);
GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName());
@@ -257,10 +268,10 @@ Gold Tool: 22*/
//Buffer Cores!
Item itemBufferCore;
for(int i=1; i<=10; i++){
- Utils.LOG_INFO(""+i);
+ //Utils.LOG_INFO(""+i);
itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMisc);
GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()+i);
- System.out.println("Buffer Core registration count is: "+i);
+ //System.out.println("Buffer Core registration count is: "+i);
}
//Dev Items
itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemStickyRubber");
@@ -270,6 +281,7 @@ Gold Tool: 22*/
GameRegistry.registerItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy");
itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateBatteryAlloy");
GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy");
+
itemHeliumBlob = new Item().setUnlocalizedName("itemHeliumBlob").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob");
GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob");
diff --git a/src/Java/miscutil/core/item/base/BaseItemWithCharge.java b/src/Java/miscutil/core/item/base/BaseItemWithCharge.java
new file mode 100644
index 0000000000..7c88a62ed0
--- /dev/null
+++ b/src/Java/miscutil/core/item/base/BaseItemWithCharge.java
@@ -0,0 +1,74 @@
+package miscutil.core.item.base;
+
+import java.util.List;
+
+import miscutil.core.creative.AddToCreativeTab;
+import miscutil.core.lib.CORE;
+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 BaseItemWithCharge extends Item{
+
+ public int int_Charge = 0;
+ public int int_Max_Charge = 0;
+
+ public BaseItemWithCharge(String unlocalizedName, int constructor_Charge, int constructor_Max_Charge) {
+ this.setUnlocalizedName(unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setMaxStackSize(1);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ this.int_Charge = constructor_Charge;
+ this.int_Max_Charge = constructor_Max_Charge;
+ }
+
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+ int NBT_Charge = int_Charge;
+ int NBT_Max_Charge = int_Max_Charge;
+ if (stack.stackTagCompound != null) {
+ NBT_Charge = stack.stackTagCompound.getInteger("charge_Current");
+ NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max");
+ String tempX = String.valueOf(NBT_Charge);
+ String tempY = String.valueOf(NBT_Max_Charge);
+ String formattedX = EnumChatFormatting.RED+tempX+EnumChatFormatting.GRAY;
+ String formattedY = EnumChatFormatting.DARK_RED+tempY+EnumChatFormatting.GRAY;
+ list.add(EnumChatFormatting.GRAY+"Charge:"+formattedX+"/"+formattedY+".");
+ super.addInformation(stack, aPlayer, list, bool);
+ }
+ }
+
+ //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) {
+
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
+ itemStack.stackTagCompound = new NBTTagCompound();
+ return super.onItemRightClick(itemStack, world, par3Entity);
+ }
+
+
+
+}
diff --git a/src/Java/miscutil/core/item/general/BedLocator_Base.java b/src/Java/miscutil/core/item/general/BedLocator_Base.java
new file mode 100644
index 0000000000..b4402e0689
--- /dev/null
+++ b/src/Java/miscutil/core/item/general/BedLocator_Base.java
@@ -0,0 +1,106 @@
+package miscutil.core.item.general;
+
+import java.util.List;
+
+import miscutil.core.creative.AddToCreativeTab;
+import miscutil.core.lib.CORE;
+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 BedLocator_Base extends Item{
+
+ public int bed_X = 0;
+ public int bed_Y = 0;
+ public int bed_Z = 0;
+
+ public BedLocator_Base(String unlocalizedName) {
+ this.setUnlocalizedName(unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setMaxStackSize(1);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+
+
+ int NBT_X = bed_X;
+ int NBT_Y = bed_Y;
+ int NBT_Z = bed_Z;
+
+
+ if (stack.stackTagCompound != null) {
+ NBT_X = stack.stackTagCompound.getInteger("pos_x");
+ NBT_Y = stack.stackTagCompound.getInteger("pos_y");
+ NBT_Z = stack.stackTagCompound.getInteger("pos_z");
+
+ String tempX = String.valueOf(NBT_X);
+ String tempY = String.valueOf(NBT_Y);
+ String tempZ = String.valueOf(NBT_Z);
+ String formattedX = EnumChatFormatting.DARK_RED+tempX+EnumChatFormatting.GRAY;
+ String formattedY = EnumChatFormatting.RED+tempY+EnumChatFormatting.GRAY;
+ String formattedZ = EnumChatFormatting.RED+tempZ+EnumChatFormatting.GRAY;
+
+ list.add(EnumChatFormatting.GRAY+"X: "+formattedX+".");
+ list.add(EnumChatFormatting.GRAY+"Y: "+formattedY+".");
+ list.add(EnumChatFormatting.GRAY+"Z: "+formattedZ+".");
+ super.addInformation(stack, aPlayer, list, bool);
+ }
+ }
+
+ //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();
+ this.bed_X = 0;
+ this.bed_Y = 0;
+ this.bed_Z = 0;
+ itemStack.stackTagCompound.setInteger("pos_x", bed_X);
+ itemStack.stackTagCompound.setInteger("pos_y", bed_Y);
+ itemStack.stackTagCompound.setInteger("pos_z", bed_Z);
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+
+
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
+ itemStack.stackTagCompound = new NBTTagCompound();
+ if (par3Entity.getBedLocation() != null){
+ this.bed_X = par3Entity.getBedLocation().posX;
+ this.bed_Y = par3Entity.getBedLocation().posY;
+ this.bed_Z = par3Entity.getBedLocation().posZ;
+ }
+ else {
+ this.bed_X = 0;
+ this.bed_Y = 0;
+ this.bed_Z = 0;
+ }
+ itemStack.stackTagCompound.setInteger("pos_x", bed_X);
+ itemStack.stackTagCompound.setInteger("pos_y", bed_Y);
+ itemStack.stackTagCompound.setInteger("pos_z", bed_Z);
+ return super.onItemRightClick(itemStack, world, par3Entity);
+ }
+
+
+
+}
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 20d6fcd08e..4aa9f57092 100644
--- a/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java
+++ b/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java
@@ -19,7 +19,6 @@ public class FuelRod_Base extends Item{
public String fuelType = "";
public float heat = 0;
public float maxHeat = getMaxHeat();
- private ItemStack thisStack = null;
public FuelRod_Base(String unlocalizedName, String type, int fuelLeft, int maxFuel) {
this.setUnlocalizedName(unlocalizedName);
this.setTextureName(CORE.MODID + ":" + unlocalizedName);
@@ -30,12 +29,6 @@ public class FuelRod_Base extends Item{
this.fuelType = type;
this.setCreativeTab(AddToCreativeTab.tabMachines);
}
-
- /*@Override
- public void setDamage(ItemStack stack, int damage) {
- this.heat=heat+5;
- super.setDamage(stack, damage);
- }*/
private float getMaxHeat(){
float tempvar;
@@ -58,6 +51,13 @@ public class FuelRod_Base extends Item{
}
+ private void updateVars(ItemStack stack){
+ if (stack.stackTagCompound != null) {
+ heat = stack.stackTagCompound.getFloat("heat");
+ fuelRemaining = stack.stackTagCompound.getInteger("fuelRemaining");
+ }
+ }
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
@@ -67,12 +67,12 @@ public class FuelRod_Base extends Item{
int NBT_Fuel = fuelRemaining;
String NBT_Type= fuelType;
- thisStack = stack;
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");}
+ NBT_Type = stack.stackTagCompound.getString("fuelType");
+ }
String tempHeat = String.valueOf(NBT_Heat);
String tempMaxHeat = String.valueOf(NBT_MaxHeat);
@@ -85,6 +85,8 @@ public class FuelRod_Base extends Item{
int tempMax = maximumFuel;
float tempCurrentHeat = heat;
int tempFuelLeft = fuelRemaining;
+
+ //Fuel Usage Formatting
if (tempFuelLeft <= maximumFuel/3){
formattedFuelLeft = EnumChatFormatting.RED+tempFuel+EnumChatFormatting.GRAY;
}
@@ -97,44 +99,54 @@ public class FuelRod_Base extends Item{
else {
formattedFuelLeft = EnumChatFormatting.GRAY+tempFuel+EnumChatFormatting.GRAY;
}
- if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat != 0){
+
+ //Heat Formatting
+ if (tempCurrentHeat <= 200 && tempCurrentHeat >= 0){
formattedHeat = EnumChatFormatting.GRAY+tempHeat+EnumChatFormatting.GRAY;
}
- else if (tempCurrentHeat >= maxHeat/3 && tempMax <= (maxHeat/3)*2 && tempCurrentHeat != 0){
+ else if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat > 200){
formattedHeat = EnumChatFormatting.YELLOW+tempHeat+EnumChatFormatting.GRAY;
}
- else if (tempCurrentHeat <= (maxHeat/3)*2 && tempMax <= maxHeat && tempCurrentHeat != 0){
+ else if (tempCurrentHeat >= maxHeat/3 && tempMax < (maxHeat/3)*2 && tempCurrentHeat != 0){
+ formattedHeat = EnumChatFormatting.GOLD+tempHeat+EnumChatFormatting.GRAY;
+ }
+ else if (tempCurrentHeat >= ((maxHeat/3)*2) && tempMax <= maxHeat && tempCurrentHeat != 0){
formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY;
}
else {
formattedHeat = EnumChatFormatting.BLUE+tempHeat+EnumChatFormatting.GRAY;
}
-
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);
}
- public String getType(){
- return fuelType;
+ public String getType(ItemStack stack){
+ if (stack.stackTagCompound != null){
+ return stack.stackTagCompound.getString("fuelType");
+ }
+ return fuelType;
}
- public int getFuelRemaining(){
- return fuelRemaining;
+ public int getFuelRemaining(ItemStack stack){
+ if (stack.stackTagCompound != null){
+ return stack.stackTagCompound.getInteger("fuelRemaining");
+ }
+ return 0;
}
public int getMaxFuel(){
return maximumFuel;
}
- public int getFuel(){
- if (thisStack != null){
- int i = thisStack.getItemDamage();
+ public int getFuel(ItemStack stack){
+ if (stack != null){
+ int i = stack.getItemDamage();
int r = maximumFuel - i;
return r;
}
- return fuelRemaining;
+ return getFuelRemaining(stack);
}
public boolean setFuelRemainingExplicitly(int i){
@@ -155,8 +167,11 @@ public class FuelRod_Base extends Item{
return false;
}
- public float getHeat(){
- return heat;
+ public float getHeat(ItemStack value){
+ if (value.stackTagCompound != null){
+ return value.stackTagCompound.getFloat("heat");
+ }
+ return 0f;
}
public boolean addHeat(float i){
@@ -183,22 +198,23 @@ public class FuelRod_Base extends Item{
@Override
public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setInteger("fuelRemaining", fuelRemaining);
+ itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack));
itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel);
- itemStack.stackTagCompound.setFloat("heat", heat);
- itemStack.stackTagCompound.setFloat("maxHeat", maxHeat);
- itemStack.stackTagCompound.setString("fuelType", fuelType);
+ itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack));
+ itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat());
+ itemStack.stackTagCompound.setString("fuelType", getType(itemStack));
+ updateVars(itemStack);
}
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining());
+ itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack));
itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel);
- itemStack.stackTagCompound.setFloat("heat", getHeat());
+ itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack));
itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat());
- itemStack.stackTagCompound.setString("fuelType", fuelType);
-
+ itemStack.stackTagCompound.setString("fuelType", getType(itemStack));
+ updateVars(itemStack);
}