From ae8a4b14a0de47c081d518681647d14122163f8e Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 23 Nov 2016 21:53:04 +1000 Subject: $ Heavily improved the code for item replacements in CoreItem.java. + Added handlers in Material.java for materials with invalid names. % Changed logging on some math related functions in Utils.java. + Added an extra case for Infused dusts into MaterialUtils.java. --- src/Java/gtPlusPlus/core/item/base/CoreItem.java | 23 ++++++--- src/Java/gtPlusPlus/core/material/Material.java | 56 ++++++++++++---------- src/Java/gtPlusPlus/core/util/Utils.java | 6 +-- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 4 +- .../core/util/materials/MaterialUtils.java | 4 +- 5 files changed, 55 insertions(+), 38 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java index 5f4ef7a823..22896fcf9b 100644 --- a/src/Java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -22,7 +22,7 @@ public class CoreItem extends Item private final EnumChatFormatting descColour; private final String itemDescription; private final boolean hasEffect; - + //Replace Item - What does this item turn into when held. private final ItemStack turnsInto; @@ -42,7 +42,7 @@ public class CoreItem extends Item public CoreItem(String unlocalizedName, CreativeTabs creativeTab, ItemStack OverrideItem) { this(unlocalizedName, creativeTab, 64, 0, "This item will be replaced by another when helf by a player, it is old and should not be used in recipes.", EnumRarity.uncommon, EnumChatFormatting.UNDERLINE, false, OverrideItem); //Calls 5 - + } //1 @@ -131,16 +131,27 @@ public class CoreItem extends Item public boolean hasEffect(ItemStack par1ItemStack){ return hasEffect; } - + @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { if (turnsInto != null){ if (entityHolding instanceof EntityPlayer){ + Utils.LOG_INFO("Replacing "+iStack.getDisplayName()+" with "+turnsInto.getDisplayName()+"."); ItemStack tempTransform = turnsInto; - tempTransform.stackSize = iStack.stackSize; - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + if (iStack.stackSize == 64){ + tempTransform.stackSize=64; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l=0;l<64;l++){ + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + + } + else { + tempTransform.stackSize=1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } } } } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index b7263d26a6..1ddd93003a 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -23,7 +23,7 @@ public class Material { private final Fluid vMoltenFluid; - protected Object dataVar; + protected Object dataVar = MathUtils.generateSingularRandomHexValue(); private ArrayList vMaterialInput = new ArrayList(); public final long[] vSmallestRatio; @@ -172,15 +172,21 @@ public class Material { } final public String getLocalizedName(){ - return localizedName; + if (this.localizedName != null) + return this.localizedName; + return "ERROR BAD LOCALIZED NAME"; } final public String getUnlocalizedName(){ - return unlocalizedName; + if (this.unlocalizedName != null) + return this.unlocalizedName; + return "ERROR.BAD.UNLOCALIZED.NAME"; } final public short[] getRGBA(){ - return this.RGBA; + if (this.RGBA != null) + return this.RGBA; + return new short[] {255,0,0}; } final public int getRgbAsHex(){ @@ -287,29 +293,29 @@ public class Material { final public ItemStack[] getMaterialComposites(){ //Utils.LOG_WARNING("Something requested the materials needed for "+localizedName); if (vMaterialInput != null){ - if (!vMaterialInput.isEmpty()){ - ItemStack[] temp = new ItemStack[vMaterialInput.size()]; - for (int i=0;i