aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/item/general
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/item/general
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/item/general')
-rw-r--r--src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java102
-rw-r--r--src/Java/gtPlusPlus/core/item/general/BufferCore.java91
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java377
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java293
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java263
-rw-r--r--src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java329
-rw-r--r--src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java359
-rw-r--r--src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java297
-rw-r--r--src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java4
9 files changed, 1047 insertions, 1068 deletions
diff --git a/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java
index 95be6aa474..fe93fdf70e 100644
--- a/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java
+++ b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java
@@ -12,95 +12,91 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-public class BedLocator_Base extends Item{
+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) {
+ public int bed_X = 0;
+ public int bed_Y = 0;
+ public int bed_Z = 0;
+
+ public BedLocator_Base(final String unlocalizedName) {
this.setUnlocalizedName(unlocalizedName);
this.setTextureName(CORE.MODID + ":" + unlocalizedName);
- this.setMaxStackSize(1);
+ this.setMaxStackSize(1);
this.setCreativeTab(AddToCreativeTab.tabMachines);
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+ public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
-
- int NBT_X = bed_X;
- int NBT_Y = bed_Y;
- int NBT_Z = bed_Z;
-
+ int NBT_X = this.bed_X;
+ int NBT_Y = this.bed_Y;
+ int NBT_Z = this.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);
- }
+ final String tempX = String.valueOf(NBT_X);
+ final String tempY = String.valueOf(NBT_Y);
+ final String tempZ = String.valueOf(NBT_Z);
+ final String formattedX = EnumChatFormatting.DARK_RED + tempX + EnumChatFormatting.GRAY;
+ final String formattedY = EnumChatFormatting.RED + tempY + EnumChatFormatting.GRAY;
+ final 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.
+ // 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;
*
- * 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) {
+ public void onCreated(final ItemStack itemStack, final World world, final 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) {
-
-
+ itemStack.stackTagCompound.setInteger("pos_x", this.bed_X);
+ itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y);
+ itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z);
}
@Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
+ public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final 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;
+ 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);
+ itemStack.stackTagCompound.setInteger("pos_x", this.bed_X);
+ itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y);
+ itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z);
return super.onItemRightClick(itemStack, world, par3Entity);
}
+ @Override
+ public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4,
+ final boolean par5) {
+ }
}
diff --git a/src/Java/gtPlusPlus/core/item/general/BufferCore.java b/src/Java/gtPlusPlus/core/item/general/BufferCore.java
index c4a113cde5..12d78b6f83 100644
--- a/src/Java/gtPlusPlus/core/item/general/BufferCore.java
+++ b/src/Java/gtPlusPlus/core/item/general/BufferCore.java
@@ -12,86 +12,87 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
-public class BufferCore extends BaseItemWithDamageValue{
-
+public class BufferCore extends BaseItemWithDamageValue {
+
public int coreTier = 0;
-
- public BufferCore(String unlocalizedName, int i) {
+
+ public BufferCore(final String unlocalizedName, final int i) {
super(unlocalizedName);
this.setTextureName(CORE.MODID + ":" + unlocalizedName);
this.setMaxStackSize(2);
this.coreTier = i;
}
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- public String getItemStackDisplayName(ItemStack stack) {
- return super.getItemStackDisplayName(stack)+" ["+CORE.VOLTAGES[this.coreTier-1]+"].";
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public boolean requiresMultipleRenderPasses()
- {
- return true;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
- list.add(EnumChatFormatting.GRAY+"A key crafting component for making energy buffers.");
+ public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
+ list.add(EnumChatFormatting.GRAY + "A key crafting component for making energy buffers.");
super.addInformation(stack, aPlayer, list, bool);
}
- public final int getCoreTier() {
- return coreTier;
- }
-
@Override
- public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) {
- //Figure Out Damage
- String s = String.format("%X", HEX_OxFFFFFF);
- //Utils.LOG_INFO(s);
- //String rgb = Utils.hex2Rgb(s);
- //Utils.LOG_INFO(rgb);
- if (coreTier == 1){
+ public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) {
+ // Figure Out Damage
+ final String s = String.format("%X", HEX_OxFFFFFF);
+ // Utils.LOG_INFO(s);
+ // String rgb = Utils.hex2Rgb(s);
+ // Utils.LOG_INFO(rgb);
+ if (this.coreTier == 1) {
HEX_OxFFFFFF = 0x4d4d4d;
}
- else if (coreTier == 2){
+ else if (this.coreTier == 2) {
HEX_OxFFFFFF = 0x666666;
}
- else if (coreTier == 3){
+ else if (this.coreTier == 3) {
HEX_OxFFFFFF = 0x8c8c8c;
}
- else if (coreTier == 4){
+ else if (this.coreTier == 4) {
HEX_OxFFFFFF = 0xa6a6a6;
}
- else if (coreTier == 5){
+ else if (this.coreTier == 5) {
HEX_OxFFFFFF = 0xcccccc;
}
- else if (coreTier == 6){
+ else if (this.coreTier == 6) {
HEX_OxFFFFFF = 0xe6e6e6;
}
- else if (coreTier == 7){
+ else if (this.coreTier == 7) {
HEX_OxFFFFFF = 0xffffcc;
}
- else if (coreTier == 8){
+ else if (this.coreTier == 8) {
HEX_OxFFFFFF = 0xace600;
}
- else if (coreTier == 9){
+ else if (this.coreTier == 9) {
HEX_OxFFFFFF = 0xffff00;
}
- /*else if (coreTier == 10){
- HEX_OxFFFFFF = 0xff0000;
- }*/
- else if (coreTier == 10){
- HEX_OxFFFFFF = Utils.rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250));
+ /*
+ * else if (coreTier == 10){ HEX_OxFFFFFF = 0xff0000; }
+ */
+ else if (this.coreTier == 10) {
+ HEX_OxFFFFFF = Utils.rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251),
+ MathUtils.randInt(220, 250));
}
else {
HEX_OxFFFFFF = 0xffffff;
}
-
return HEX_OxFFFFFF;
}
-
+
+ public final int getCoreTier() {
+ return this.coreTier;
+ }
+
+ @Override
+ public String getItemStackDisplayName(final ItemStack stack) {
+ return super.getItemStackDisplayName(stack) + " [" + CORE.VOLTAGES[this.coreTier - 1] + "].";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean requiresMultipleRenderPasses() {
+ return true;
+ }
+
}
diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
index ec7597e363..22bb194fde 100644
--- a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
+++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
@@ -20,95 +20,207 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-public class ItemBlueprint extends Item implements IItemBlueprint{
+public class ItemBlueprint extends Item implements IItemBlueprint {
- public ItemBlueprint(String unlocalizedName) {
+ public ItemBlueprint(final String unlocalizedName) {
this.setUnlocalizedName(unlocalizedName);
this.setTextureName(CORE.MODID + ":" + unlocalizedName);
- this.setMaxStackSize(1);
+ this.setMaxStackSize(1);
this.setCreativeTab(AddToCreativeTab.tabMachines);
- //this.bpID = MathUtils.randInt(0, 1000);
+ // this.bpID = MathUtils.randInt(0, 1000);
GameRegistry.registerItem(this, unlocalizedName);
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- public void addInformation(ItemStack itemStack, EntityPlayer aPlayer, List list, boolean bool) {
- //Create some NBT if it's not there, otherwise this does nothing.
- if (!itemStack.hasTagCompound()){
- createNBT(itemStack);
+ public void addInformation(final ItemStack itemStack, final EntityPlayer aPlayer, final List list,
+ final boolean bool) {
+ // Create some NBT if it's not there, otherwise this does nothing.
+ if (!itemStack.hasTagCompound()) {
+ this.createNBT(itemStack);
}
- //Set up some default variables.
+ // Set up some default variables.
int id = -1;
String name = "";
boolean blueprint = false;
- //Get proper display vars from NBT if it's there
- if (itemStack.hasTagCompound()){
- //Utils.LOG_WARNING("Found TagCompound");
- id = (int) getNBT(itemStack, "mID");
- name = (String) getNBT(itemStack, "mName");
- blueprint = (boolean) getNBT(itemStack, "mBlueprint");
+ // Get proper display vars from NBT if it's there
+ if (itemStack.hasTagCompound()) {
+ // Utils.LOG_WARNING("Found TagCompound");
+ id = (int) this.getNBT(itemStack, "mID");
+ name = (String) this.getNBT(itemStack, "mName");
+ blueprint = (boolean) this.getNBT(itemStack, "mBlueprint");
}
- //Write to tooltip list for each viable setting.
+ // Write to tooltip list for each viable setting.
if (itemStack.hasTagCompound()) {
- if (id != -1){
- list.add(EnumChatFormatting.GRAY+"Technical Document No. "+id);
+ if (id != -1) {
+ list.add(EnumChatFormatting.GRAY + "Technical Document No. " + id);
}
- if(blueprint){
- list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+name);
+ if (blueprint) {
+ list.add(EnumChatFormatting.BLUE + "Currently holding a blueprint for " + name);
}
else {
- list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything.");
+ list.add(EnumChatFormatting.RED + "Currently not holding a blueprint for anything.");
}
- }
+ }
else {
- list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything.");
+ list.add(EnumChatFormatting.RED + "Currently not holding a blueprint for anything.");
}
super.addInformation(itemStack, aPlayer, list, bool);
}
+ public boolean createNBT(final ItemStack itemStack) {
+ if (itemStack.hasTagCompound()) {
+ if (!itemStack.stackTagCompound.getBoolean("mBlueprint")
+ && !itemStack.stackTagCompound.getString("mName").equals("")) {
+ // No Blueprint and no name Set
+ Utils.LOG_WARNING("No Blueprint and no name Set");
+ return false;
+ }
+ else if (itemStack.stackTagCompound.getBoolean("mBlueprint")
+ && !itemStack.stackTagCompound.getString("mName").equals("")) {
+ // Has Blueprint but invalid name set
+ Utils.LOG_WARNING("Has Blueprint but invalid name set");
+ // itemStack.stackTagCompound = null;
+ // createNBT(itemStack);
+ return false;
+ }
+ else if (!itemStack.stackTagCompound.getBoolean("mBlueprint")
+ && itemStack.stackTagCompound.getString("mName").equals("")) {
+ // Has no Blueprint, but strangely has a name
+ Utils.LOG_WARNING("Has no Blueprint, but strangely has a name");
+ // itemStack.stackTagCompound = null;
+ // createNBT(itemStack);
+ return false;
+ }
+ return false;
+ }
+ else if (!itemStack.hasTagCompound()) {
+ final int bpID = MathUtils.randInt(0, 1000);
+ final boolean hasRecipe = false;
+ final String recipeName = "";
+ Utils.LOG_WARNING("Creating Blueprint, setting up it's NBT data. " + bpID);
+ itemStack.stackTagCompound = new NBTTagCompound();
+ itemStack.stackTagCompound.setInteger("mID", bpID);
+ itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe);
+ itemStack.stackTagCompound.setString("mName", recipeName);
+ return true;
+ }
+ else {
+ final int bpID = MathUtils.randInt(0, 1000);
+ final boolean hasRecipe = false;
+ final String recipeName = "";
+ Utils.LOG_WARNING("Creating a Blueprint, setting up it's NBT data. " + bpID);
+ itemStack.stackTagCompound = new NBTTagCompound();
+ itemStack.stackTagCompound.setInteger("mID", bpID);
+ itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe);
+ itemStack.stackTagCompound.setString("mName", recipeName);
+ return true;
+ }
+ }
+
+ @Override
+ public ItemStack[] getBlueprint(final ItemStack stack) {
+ ItemStack[] blueprint = new ItemStack[9];
+ if (stack.hasTagCompound()) {
+ blueprint = this.readItemsFromNBT(stack);
+ }
+ try {
+ final ItemStack[] returnStack = new ItemStack[9];
+ for (int o = 0; o < blueprint.length; o++) {
+ returnStack[o] = blueprint[o];
+ if (returnStack[0] != null) {
+ returnStack[0].stackSize = 1;
+ }
+ }
+ return returnStack;
+ }
+ catch (final Throwable t) {
+ return null;
+ }
+ }
+
@Override
- public String getItemStackDisplayName(ItemStack p_77653_1_) {
+ public String getItemStackDisplayName(final ItemStack p_77653_1_) {
return "Blueprint [I am useless]";
}
+ public Object getNBT(final ItemStack itemStack, final String tagNBT) {
+ if (!itemStack.hasTagCompound()) {
+ return null;
+ }
+ Object o = null;
+ if (tagNBT.equals("mID")) {
+ o = itemStack.stackTagCompound.getInteger(tagNBT);
+ }
+ else if (tagNBT.equals("mBlueprint")) {
+ o = itemStack.stackTagCompound.getBoolean(tagNBT);
+ }
+ else if (tagNBT.equals("mName")) {
+ o = itemStack.stackTagCompound.getString(tagNBT);
+ }
+ else if (tagNBT.equals("")) {
+ // For More Tag Support
+ // o = itemStack.stackTagCompound.getInteger(tagNBT);
+ }
+ if (o != null) {
+ return o;
+ }
+ return null;
+ }
+
@Override
- public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
- createNBT(itemStack);
+ public boolean hasBlueprint(final ItemStack stack) {
+ if (stack.hasTagCompound()) {
+ return (boolean) this.getNBT(stack, "mBlueprint");
+ }
+ return false;
}
@Override
- public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ public boolean isBlueprint(final ItemStack stack) {
+ return true;
+ }
+ @Override
+ public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) {
+ this.createNBT(itemStack);
}
@Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
- //Let the player know what blueprint is held
+ public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) {
+ // Let the player know what blueprint is held
if (itemStack.hasTagCompound()) {
- PlayerUtils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+ItemUtils.getArrayStackNames(readItemsFromNBT(itemStack)));
+ PlayerUtils.messagePlayer(par3Entity,
+ "This Blueprint holds NBT data. " + "|" + this.getNBT(itemStack, "mID") + "|"
+ + this.getNBT(itemStack, "mBlueprint") + "|" + this.getNBT(itemStack, "mName") + "|"
+ + ItemUtils.getArrayStackNames(this.readItemsFromNBT(itemStack)));
}
else {
- createNBT(itemStack);
- PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID"));
+ this.createNBT(itemStack);
+ PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. " + this.getNBT(itemStack, "mID"));
}
-
return super.onItemRightClick(itemStack, world, par3Entity);
}
- public ItemStack[] readItemsFromNBT(ItemStack itemStack){
+ @Override
+ public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4,
+ final boolean par5) {
+
+ }
+
+ public ItemStack[] readItemsFromNBT(final ItemStack itemStack) {
ItemStack[] blueprint = new ItemStack[9];
- if (itemStack.hasTagCompound()){
- NBTTagCompound nbt = itemStack.getTagCompound();
- NBTTagList list = nbt.getTagList("Items", 10);
- blueprint = new ItemStack[INV_SIZE];
- for(int i = 0;i<list.tagCount();i++)
- {
- NBTTagCompound data = list.getCompoundTagAt(i);
- int slot = data.getInteger("Slot");
- if(slot >= 0 && slot < INV_SIZE)
- {
+ if (itemStack.hasTagCompound()) {
+ final NBTTagCompound nbt = itemStack.getTagCompound();
+ final NBTTagList list = nbt.getTagList("Items", 10);
+ blueprint = new ItemStack[IItemBlueprint.INV_SIZE];
+ for (int i = 0; i < list.tagCount(); i++) {
+ final NBTTagCompound data = list.getCompoundTagAt(i);
+ final int slot = data.getInteger("Slot");
+ if (slot >= 0 && slot < IItemBlueprint.INV_SIZE) {
blueprint[slot] = ItemStack.loadItemStackFromNBT(data);
}
}
@@ -117,175 +229,72 @@ public class ItemBlueprint extends Item implements IItemBlueprint{
return null;
}
- public ItemStack writeItemsToNBT(ItemStack itemStack, ItemStack[] craftingGrid){
- ItemStack[] blueprint = craftingGrid;
- if (itemStack.hasTagCompound()){
- NBTTagCompound nbt = itemStack.getTagCompound();
- NBTTagList list = new NBTTagList();
- for(int i = 0;i<INV_SIZE;i++)
- {
- ItemStack stack = blueprint[i];
- if(stack != null)
- {
- NBTTagCompound data = new NBTTagCompound();
- stack.writeToNBT(data);
- data.setInteger("Slot", i);
- list.appendTag(data);
- }
- }
- nbt.setTag("Items", list);
- itemStack.setTagCompound(nbt);
- return itemStack;
- }
- return null;
- }
-
@Override
- public boolean isBlueprint(ItemStack stack) {
- return true;
- }
-
- @Override
- public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output) {
+ public boolean setBlueprint(final ItemStack stack, final IInventory craftingTable, final ItemStack output) {
boolean hasBP = false;
ItemStack[] blueprint = new ItemStack[9];
- if (stack.hasTagCompound()){
- hasBP = (boolean) getNBT(stack, "mBlueprint");
- blueprint = readItemsFromNBT(stack);
+ if (stack.hasTagCompound()) {
+ hasBP = (boolean) this.getNBT(stack, "mBlueprint");
+ blueprint = this.readItemsFromNBT(stack);
}
- if (!hasBP){
+ if (!hasBP) {
try {
- for (int o=0; o<craftingTable.getSizeInventory(); o++){
+ for (int o = 0; o < craftingTable.getSizeInventory(); o++) {
blueprint[o] = craftingTable.getStackInSlot(o);
- if (blueprint[0] != null){
+ if (blueprint[0] != null) {
blueprint[0].stackSize = 0;
}
}
- writeItemsToNBT(stack, blueprint);
- if (stack.hasTagCompound()){
- if(stack.getTagCompound().getCompoundTag("Items") != null){
+ this.writeItemsToNBT(stack, blueprint);
+ if (stack.hasTagCompound()) {
+ if (stack.getTagCompound().getCompoundTag("Items") != null) {
stack.stackTagCompound.setBoolean("mBlueprint", true);
}
else {
- //Invalid BP saved?
+ // Invalid BP saved?
}
- hasBP = (boolean) getNBT(stack, "mBlueprint");
+ hasBP = (boolean) this.getNBT(stack, "mBlueprint");
}
-
- if (output != null){
- setBlueprintName(stack, output.getDisplayName());
- return (hasBP = true);
+
+ if (output != null) {
+ this.setBlueprintName(stack, output.getDisplayName());
+ return hasBP = true;
}
return false;
- } catch (Throwable t){
- return false;
+ }
+ catch (final Throwable t) {
+ return false;
}
}
return false;
}
@Override
- public void setBlueprintName(ItemStack stack, String name) {
+ public void setBlueprintName(final ItemStack stack, final String name) {
stack.stackTagCompound.setString("mName", name);
}
- @Override
- public boolean hasBlueprint(ItemStack stack) {
- if (stack.hasTagCompound()){
- return (boolean) getNBT(stack, "mBlueprint");
- }
- return false;
- }
-
- @Override
- public ItemStack[] getBlueprint(ItemStack stack) {
- ItemStack[] blueprint = new ItemStack[9];
- if (stack.hasTagCompound()){
- blueprint = readItemsFromNBT(stack);
- }
- try {
- ItemStack[] returnStack = new ItemStack[9];
- for (int o=0; o<blueprint.length; o++){
- returnStack[o] = blueprint[o];
- if (returnStack[0] != null){
- returnStack[0].stackSize = 1;
+ public ItemStack writeItemsToNBT(final ItemStack itemStack, final ItemStack[] craftingGrid) {
+ final ItemStack[] blueprint = craftingGrid;
+ if (itemStack.hasTagCompound()) {
+ final NBTTagCompound nbt = itemStack.getTagCompound();
+ final NBTTagList list = new NBTTagList();
+ for (int i = 0; i < IItemBlueprint.INV_SIZE; i++) {
+ final ItemStack stack = blueprint[i];
+ if (stack != null) {
+ final NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
}
}
- return returnStack;
- } catch (Throwable t){
- return null;
- }
- }
-
- public boolean createNBT(ItemStack itemStack){
- if (itemStack.hasTagCompound()){
- if (!itemStack.stackTagCompound.getBoolean("mBlueprint") && !itemStack.stackTagCompound.getString("mName").equals("")){
- //No Blueprint and no name Set
- Utils.LOG_WARNING("No Blueprint and no name Set");
- return false;
- }
- else if (itemStack.stackTagCompound.getBoolean("mBlueprint") && !itemStack.stackTagCompound.getString("mName").equals("")){
- //Has Blueprint but invalid name set
- Utils.LOG_WARNING("Has Blueprint but invalid name set");
- //itemStack.stackTagCompound = null;
- //createNBT(itemStack);
- return false;
- }
- else if (!itemStack.stackTagCompound.getBoolean("mBlueprint") && itemStack.stackTagCompound.getString("mName").equals("")){
- //Has no Blueprint, but strangely has a name
- Utils.LOG_WARNING("Has no Blueprint, but strangely has a name");
- //itemStack.stackTagCompound = null;
- //createNBT(itemStack);
- return false;
- }
- return false;
- }
- else if(!itemStack.hasTagCompound()){
- int bpID = MathUtils.randInt(0, 1000);
- boolean hasRecipe = false;
- String recipeName = "";
- Utils.LOG_WARNING("Creating Blueprint, setting up it's NBT data. "+bpID);
- itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setInteger("mID", bpID);
- itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe);
- itemStack.stackTagCompound.setString("mName", recipeName);
- return true;
+ nbt.setTag("Items", list);
+ itemStack.setTagCompound(nbt);
+ return itemStack;
}
- else {
- int bpID = MathUtils.randInt(0, 1000);
- boolean hasRecipe = false;
- String recipeName = "";
- Utils.LOG_WARNING("Creating a Blueprint, setting up it's NBT data. "+bpID);
- itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setInteger("mID", bpID);
- itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe);
- itemStack.stackTagCompound.setString("mName", recipeName);
- return true;
- }
+ return null;
}
- public Object getNBT(ItemStack itemStack, String tagNBT){
- if (!itemStack.hasTagCompound()){
- return null;
- }
- Object o = null;
- if (tagNBT.equals("mID")){
- o = itemStack.stackTagCompound.getInteger(tagNBT);
- }
- else if (tagNBT.equals("mBlueprint")){
- o = itemStack.stackTagCompound.getBoolean(tagNBT);
- }
- else if (tagNBT.equals("mName")){
- o = itemStack.stackTagCompound.getString(tagNBT);
- }
- else if (tagNBT.equals("")){
- //For More Tag Support
- //o = itemStack.stackTagCompound.getInteger(tagNBT);
- }
- if (o != null)
- return o;
- return null; }
-
}
diff --git a/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java
index 5b664d181c..d0316730bf 100644
--- a/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java
+++ b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java
@@ -21,235 +21,234 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-@Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")})
-public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{
-
- private final String unlocalizedName = "personalCloakingDevice";
- private final ItemStack thisStack;
- private final static int maxValueEU = 10000*20*500;
- protected double chargeEU = 0;
-
- public ItemCloakingDevice(double charge){
+@Optional.InterfaceList(value = {
+ @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"),
+ @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")
+})
+public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble {
+
+ private final static int maxValueEU = 10000 * 20 * 500;
+ private final String unlocalizedName = "personalCloakingDevice";
+ private final ItemStack thisStack;
+ protected double chargeEU = 0;
+
+ public ItemCloakingDevice(final double charge) {
this.chargeEU = charge;
this.setCreativeTab(AddToCreativeTab.tabMachines);
- this.setUnlocalizedName(unlocalizedName);
+ this.setUnlocalizedName(this.unlocalizedName);
this.setMaxStackSize(1);
this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice");
this.thisStack = ItemUtils.getSimpleStack(this);
- this.charge(thisStack, charge, 3, true, false);
- if (charge == 10000*20*500){
- this.setDamage(thisStack, 13);
+ this.charge(this.thisStack, charge, 3, true, false);
+ if (charge == 10000 * 20 * 500) {
+ this.setDamage(this.thisStack, 13);
}
- GameRegistry.registerItem(this, unlocalizedName+"-"+charge);
+ GameRegistry.registerItem(this, this.unlocalizedName + "-" + charge);
+ }
+
+ @Override
+ public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
+ list.add("");
+ list.add(EnumChatFormatting.GREEN + "Worn as a Belt within Baubles." + EnumChatFormatting.GRAY);
+ list.add(EnumChatFormatting.GREEN + "Drains 10,000EU/t to provide invisibility." + EnumChatFormatting.GRAY);
+ list.add("");
+ list.add(EnumChatFormatting.GOLD + "IC2/EU Information" + EnumChatFormatting.GRAY);
+ list.add(EnumChatFormatting.GRAY + "Tier: [" + EnumChatFormatting.YELLOW + this.getTier(this.thisStack)
+ + EnumChatFormatting.GRAY + "] Input Limit: [" + EnumChatFormatting.YELLOW
+ + this.getTransferLimit(this.thisStack) + EnumChatFormatting.GRAY + "EU/t]");
+ list.add(EnumChatFormatting.GRAY + "Current Power: [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack)
+ + EnumChatFormatting.GRAY + "EU] [" + EnumChatFormatting.YELLOW
+ + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY
+ + "%]");
+ list.add(EnumChatFormatting.GRAY + "Time Remaining: [" + EnumChatFormatting.YELLOW + this.secondsLeft(stack)
+ + EnumChatFormatting.GRAY + " seconds]");
+ super.addInformation(stack, aPlayer, list, bool);
}
@Override
- public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) {
- if (worldObj.isRemote) {
- return;
- }
-
- if (player instanceof EntityPlayer){
- for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) {
- if (is == itemStack) {
- continue;
- }
- if (is != null) {
- if (is.getItem() instanceof IElectricItem) {
- IElectricItem electricItem = (IElectricItem) is.getItem();
- chargeEU = ElectricItem.manager.getCharge(is);
- }
-
- }
- }
- }
-
-
- super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_);
+ public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) {
+ return true;
}
@Override
- public boolean canProvideEnergy(ItemStack itemStack) {
+ public boolean canProvideEnergy(final ItemStack itemStack) {
return true;
}
@Override
- public Item getChargedItem(ItemStack itemStack) {
- ItemStack x = itemStack.copy();
- x.setItemDamage(maxValueEU);
- return x.getItem();
+ public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) {
+ return true;
}
@Override
- public Item getEmptyItem(ItemStack itemStack) {
- ItemStack x = itemStack.copy();
- x.setItemDamage(0);
- return x.getItem();
+ public boolean canUse(final ItemStack stack, final double amount) {
+ return ElectricItem.manager.canUse(stack, amount);
}
@Override
- public double getMaxCharge(ItemStack itemStack) {
- return maxValueEU;
- }
+ public double charge(final ItemStack stack, final double amount, final int tier, final boolean ignoreTransferLimit,
+ final boolean simulate) {
- @Override
- public int getTier(ItemStack itemStack) {
- return 5;
+ if (!simulate) {
+ ElectricItem.manager.charge(stack, amount, tier, true, simulate);
+
+ }
+ return ElectricItem.manager.charge(stack, amount, tier, true, simulate);
}
@Override
- public double getTransferLimit(ItemStack itemStack) {
- return 8196;
+ public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) {
+ ElectricItem.manager.chargeFromArmor(stack, entity);
}
@Override
- public String getItemStackDisplayName(ItemStack p_77653_1_) {
+ public double discharge(final ItemStack stack, final double amount, final int tier,
+ final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) {
+ if (!simulate) {
+ ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate);
+ }
- return (EnumChatFormatting.BLUE+"Personal Cloaki