From d4f11459f2e78e954a4c060c92861614c114d1cb Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 19 Jun 2016 14:53:32 +1000 Subject: +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. --- .../core/item/base/BaseItemWithCharge.java | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/Java/miscutil/core/item/base/BaseItemWithCharge.java (limited to 'src/Java/miscutil/core/item/base') 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); + } + + + +} -- cgit