diff options
Diffstat (limited to 'src/main/java')
6 files changed, 127 insertions, 98 deletions
diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index 9f35b0c0d2..7cae9dffdd 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -7,6 +7,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IIconContainer; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import net.minecraft.creativetab.CreativeTabs; @@ -61,6 +62,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { } if ((tPrefix == OrePrefixes.stick || tPrefix == OrePrefixes.wireFine || tPrefix == OrePrefixes.ingot) && (tMaterial == Materials.Lead || tMaterial == Materials.Tin || tMaterial == Materials.SolderingAlloy)) { GregTech_API.sSolderingMetalList.add(tStack); + GT_ModHandler.registerBoxableItemToToolBox(tStack); } } } @@ -87,7 +89,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { // if (!super.doesMaterialAllowGeneration(aPrefix, aMaterial)) return false; return aPrefix != null && aMaterial != null && aPrefix.doGenerateItem(aMaterial); } - + /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ /** @@ -128,7 +130,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { public boolean doesShowInCreative(OrePrefixes aPrefix, Materials aMaterial, boolean aDoShowAllItems) { return true; } - + /* ---------- INTERNAL OVERRIDES ---------- */ @Override diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 87593fdc5d..ea5ef281d3 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -80,12 +80,11 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements */ public GT_MetaGenerated_Tool(String aUnlocalized) { super(aUnlocalized); - GT_ModHandler.registerBoxableItemToToolBox(this); setCreativeTab(GregTech_API.TAB_GREGTECH); setMaxStackSize(1); sInstances.put(getUnlocalizedName(), this); } - + /* ---------- FOR ADDING CUSTOM ITEMS INTO THE REMAINING 766 RANGE ---------- */ public static final Materials getPrimaryMaterial(ItemStack aStack) { @@ -105,7 +104,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements } return Materials._NULL; } - + /* ---------- INTERNAL OVERRIDES ---------- */ public static final long getToolMaxDamage(ItemStack aStack) { @@ -168,6 +167,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements } if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + GT_ModHandler.registerBoxableItemToToolBox(rStack); return rStack; } return null; @@ -217,14 +217,14 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements if (isItemStackUsable(aStack) && getDigSpeed(aStack, aBlock, aMetaData) > 0.0F) doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); } - + @Mod.EventHandler public float onBlockBreakSpeedEvent(float aDefault, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, PlayerEvent.BreakSpeed aEvent) { - IToolStats tStats = getToolStats(aStack); + IToolStats tStats = getToolStats(aStack); return tStats == null ? aDefault : tStats.getMiningSpeed(aBlock, aMetaData, aDefault, aPlayer, aPlayer.worldObj, aX, aY, aZ); } - + @Override public boolean onBlockStartBreak(ItemStack aStack, int aX, int aY, int aZ, EntityPlayer aPlayer) { @@ -393,7 +393,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements aNBT.setLong("HeatTime", tWorldTime); if(tHeat>-10000)aNBT.setInteger("Heat", tHeat); } - + aList.add(tOffset + 3, EnumChatFormatting.RED + "Heat: " + aNBT.getInteger("Heat")+" K" + EnumChatFormatting.GRAY); } } @@ -542,7 +542,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IToolStats tStats = getToolStats(aStack); if (tStats != null) doDamage(aStack, tStats.getToolDamagePerEntityAttack()); } - + @Override public boolean canWrench(EntityPlayer player, int x, int y, int z) { if(player==null)return false; @@ -559,7 +559,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IToolStats tStats = getToolStats(player.getCurrentEquippedItem()); if (tStats != null) doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); } - + @Override public boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z){ return canWrench(player, x, y, z); @@ -569,7 +569,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements public void used(ItemStack stack, EntityPlayer player, int x, int y, int z){ wrenchUsed(player, x, y, z); } - + @Override public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) { if(player==null)return false; @@ -578,7 +578,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IToolStats tStats = getToolStats(player.getCurrentEquippedItem()); return tStats.isWrench(); } - + @Override public boolean canLink(EntityPlayer aPlayer, ItemStack aStack, EntityMinecart cart) { diff --git a/src/main/java/gregtech/api/items/GT_Tool_Item.java b/src/main/java/gregtech/api/items/GT_Tool_Item.java index aa53ddaba1..736c7e4b13 100644 --- a/src/main/java/gregtech/api/items/GT_Tool_Item.java +++ b/src/main/java/gregtech/api/items/GT_Tool_Item.java @@ -1,6 +1,7 @@ package gregtech.api.items; import gregtech.api.util.GT_ModHandler; +import net.minecraft.item.ItemStack; /** * This is just a basic Tool, which has normal durability and could break Blocks. @@ -20,6 +21,6 @@ public class GT_Tool_Item extends GT_Generic_Item { setMaxStackSize(1); setNoRepair(); setFull3D(); - GT_ModHandler.registerBoxableItemToToolBox(this); + GT_ModHandler.registerBoxableItemToToolBox(new ItemStack(this)); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index 44e3771ab8..1321ce29ab 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -1,6 +1,5 @@ package gregtech.api.metatileentity.implementations; -import com.mojang.authlib.GameProfile; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; @@ -23,12 +22,11 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.FakePlayer; - import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE; @@ -77,7 +75,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch String[] desc = new String[mDescriptionArray.length + 3]; System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); desc[mDescriptionArray.length] = "4 Ducttape, 2 Lubricant Cells"; - desc[mDescriptionArray.length + 1] = "4 Steel Screws, 2 Adv Circuits"; + desc[mDescriptionArray.length + 1] = "4 Steel Screws, 2 HV Circuits"; desc[mDescriptionArray.length + 2] = "For each autorepair"; return desc; } else { @@ -240,9 +238,9 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch return true; } - public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { + public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer, IInventory aToolboxInventory) { if (aStack == null || aPlayer == null) return; - + // Allow IC2 Toolbox with tools to function for maint issues. if (aStack.getItem() instanceof ItemToolbox && aPlayer instanceof EntityPlayer) { applyToolbox(aStack, (EntityPlayer)aPlayer); @@ -259,7 +257,8 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch mHardHammer = true; if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && !mCrowbar && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mCrowbar = true; - if (!mSolderingTool && GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true; + if (!mSolderingTool && GT_ModHandler.useSolderingIron(aStack, aPlayer, aToolboxInventory)) + mSolderingTool = true; if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) { mWrench = mScrewdriver = mSoftHammer = mHardHammer = mCrowbar = mSolderingTool = true; getBaseMetaTileEntity().setActive(false); @@ -274,11 +273,15 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } } + public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { + onToolClick(aStack, aPlayer, null); + } + private void applyToolbox(ItemStack aStack, EntityPlayer aPlayer) { ItemToolbox aToolbox = (ItemToolbox) aStack.getItem(); IHasGui aToolboxGUI = aToolbox.getInventory(aPlayer, aStack); for (int i=0; i<aToolboxGUI.getSizeInventory(); i++) - onToolClick(aToolboxGUI.getStackInSlot(i), aPlayer); + onToolClick(aToolboxGUI.getStackInSlot(i), aPlayer, aToolboxGUI); } @Override diff --git a/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java b/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java index dadbe57518..747ca15249 100644 --- a/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java +++ b/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java @@ -6,6 +6,6 @@ import net.minecraft.item.ItemStack; public class GT_IBoxableWrapper implements IBoxable { @Override public boolean canBeStoredInToolbox(ItemStack itemstack) { - return true; + return GT_Utility.isStackInList(itemstack, GT_ModHandler.sBoxableItems); } } diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 1471fd843f..e1e5184b60 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1,10 +1,9 @@ package gregtech.api.util; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OreDictNames; @@ -30,6 +29,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -90,6 +90,7 @@ public class GT_ModHandler { public static Collection<String> sNativeRecipeClasses = new HashSet<>(), sSpecialRecipeClasses = new HashSet<>(); public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<>(); public static Object sBoxableWrapper = new GT_IBoxableWrapper(); + public static Collection<GT_ItemStack> sBoxableItems = new ArrayList<>(); private static final Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new HashMap<>(); private static final Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new HashMap<>(); private static final Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new HashMap<>(); @@ -493,10 +494,10 @@ public class GT_ModHandler { boolean temp = false; if (aInput.stackSize == 1 && addSmeltingRecipe(aInput, aOutput)) temp = true; return (RA.addAlloySmelterRecipe( - aInput, - OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, - aOutput, - 130, + aInput, + OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, + aOutput, + 130, 3, hidden )); @@ -579,7 +580,7 @@ public class GT_ModHandler { } return true; } - + public static boolean addImmersiveEngineeringRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ return true; } @@ -846,22 +847,22 @@ public class GT_ModHandler { */ public static boolean addCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { return addCraftingRecipe( - aResult, - new Enchantment[0], - new int[0], - (aBitMask & RecipeBits.MIRRORED) != 0, - (aBitMask & RecipeBits.BUFFERED) != 0, - (aBitMask & RecipeBits.KEEPNBT) != 0, - (aBitMask & RecipeBits.DISMANTLEABLE) != 0, - (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, - (aBitMask & RecipeBits.REVERSIBLE) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, - (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, - (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, - (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, + aResult, + new Enchantment[0], + new int[0], + (aBitMask & RecipeBits.MIRRORED) != 0, + (aBitMask & RecipeBits.BUFFERED) != 0, + (aBitMask & RecipeBits.KEEPNBT) != 0, + (aBitMask & RecipeBits.DISMANTLEABLE) != 0, + (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, + (aBitMask & RecipeBits.REVERSIBLE) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, + (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, + (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, + (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, aRecipe); } @@ -869,22 +870,22 @@ public class GT_ModHandler { * Internal realisation of the Crafting Recipe adding Process. */ private static boolean addCraftingRecipe( - ItemStack aResult, - Enchantment[] aEnchantmentsAdded, - int[] aEnchantmentLevelsAdded, - boolean aMirrored, - boolean aBuffered, - boolean aKeepNBT, - boolean aDismantleable, - boolean aRemovable, - boolean aReversible, - boolean aRemoveAllOthersWithSameOutput, - boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, - boolean aRemoveAllOtherShapedsWithSameOutput, - boolean aRemoveAllOtherNativeRecipes, - boolean aCheckForCollisions, - boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, - boolean aOnlyAddIfResultIsNotNull, + ItemStack aResult, + Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, + boolean aMirrored, + boolean aBuffered, + boolean aKeepNBT, + boolean aDismantleable, + boolean aRemovable, + boolean aReversible, + boolean aRemoveAllOthersWithSameOutput, + boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, + boolean aRemoveAllOtherShapedsWithSameOutput, + boolean aRemoveAllOtherNativeRecipes, + boolean aCheckForCollisions, + boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, + boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe ) { aResult = GT_OreDictUnificator.get(true, aResult); @@ -1083,7 +1084,7 @@ public class GT_ModHandler { else removeRecipeByOutputDelayed(aResult); } - + if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tDoWeCareIfThereWasARecipe && !tThereWasARecipe) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); int tList_sS=tList.size(); @@ -1210,7 +1211,7 @@ public class GT_ModHandler { public static ItemStack removeRecipe(ItemStack... aRecipe) { if (aRecipe == null) return null; if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return null; - + ItemStack rReturn = null; InventoryCrafting aCrafting = new InventoryCrafting(new Container() { @Override @@ -1239,7 +1240,7 @@ public class GT_ModHandler { removeRecipe(aRecipe); return; } - + if (aRecipe == null) return; if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return; @@ -1257,7 +1258,7 @@ public class GT_ModHandler { public static void bulkRemoveByRecipe(List<InventoryCrafting> toRemove) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); GT_FML_LOGGER.info("BulkRemoveByRecipe: tList: " + tList.size() + " toRemove: " + toRemove.size() ); - + Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW)); @@ -1272,7 +1273,7 @@ public class GT_ModHandler { else return removeRecipeByOutput(aOutput); } - + public static boolean removeRecipeByOutputDelayed (ItemStack aOutput, boolean aIgnoreNBT, boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) { if (sBufferCraftingRecipes && (aIgnoreNBT && !aNotRemoveShapelessRecipes && !aOnlyRemoveNativeHandlers)) // Too lazy to handle deferred versions of the parameters that aren't used very often @@ -1280,7 +1281,7 @@ public class GT_ModHandler { else return removeRecipeByOutput(aOutput, aIgnoreNBT, aNotRemoveShapelessRecipes, aOnlyRemoveNativeHandlers); } - + public static boolean removeRecipeByOutput(ItemStack aOutput) { return removeRecipeByOutput(aOutput, true, false, false); } @@ -1308,7 +1309,7 @@ public class GT_ModHandler { } ItemStack tStack = tRecipe.getRecipeOutput(); if ( - (!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) + (!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT) ) { tList.remove(i--); tList_sS=tList.size(); @@ -1322,20 +1323,20 @@ public class GT_ModHandler { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); Set<ItemStack> setToRemove = toRemove.parallelStream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet()); - + GT_FML_LOGGER.info("BulkRemoveRecipeByOutput: tList: " + tList.size() + " setToRemove: " + setToRemove.size() ); - + Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) return false; final ItemStack tStack = GT_OreDictUnificator.get_nocopy(tRecipe.getRecipeOutput()); return setToRemove.stream().anyMatch(aOutput -> GT_Utility.areStacksEqual(tStack, aOutput, true)); }).collect(Collectors.toSet()); - + tList.removeIf(tListToRemove::contains); return true; } - + /** * Checks all Crafting Handlers for Recipe Output * Used for the Autocrafting Table @@ -1407,15 +1408,15 @@ public class GT_ModHandler { public static ItemStack getRecipeOutput(ItemStack... aRecipe) { return getRecipeOutput(false, true, aRecipe); } - + public static ItemStack getRecipeOutputNoOreDict(ItemStack... aRecipe) { return getRecipeOutput(false,false, aRecipe); } - + public static ItemStack getRecipeOutput(boolean aUncopiedStack, ItemStack... aRecipe) { return getRecipeOutput(aUncopiedStack, true, aRecipe); } - + /** * Gives you a copy of the Output from a Crafting Recipe * Used for Recipe Detection. @@ -1433,11 +1434,11 @@ public class GT_ModHandler { for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); boolean found = false; - + for (IRecipe iRecipe : tList) { found = false; if (!allowOreDict && iRecipe instanceof ShapedOreRecipe) continue; - + try { found = iRecipe.matches(aCrafting, DW); } catch (Throwable e) { @@ -1828,16 +1829,17 @@ public class GT_ModHandler { } /** - * Uses a Soldering Iron + * Uses a Soldering Iron from player or external inventory */ - public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer) { + public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer, IInventory aExternalInventory) { if (aPlayer == null || aStack == null) return false; if (GT_Utility.isStackInList(aStack, GregTech_API.sSolderingToolList)) { if (aPlayer instanceof EntityPlayer) { EntityPlayer tPlayer = (EntityPlayer) aPlayer; if (tPlayer.capabilities.isCreativeMode) return true; if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) { - if (consumeSolderingMaterial(tPlayer)) { + if (consumeSolderingMaterial(tPlayer) + || (aExternalInventory != null && consumeSolderingMaterial(aExternalInventory))) { if (canUseElectricItem(aStack, 10000)) { return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer); } @@ -1853,24 +1855,40 @@ public class GT_ModHandler { return false; } - /** - * Simply consumes some soldering material - */ + public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer) { + return useSolderingIron(aStack, aPlayer, null); + } + public static boolean consumeSolderingMaterial(EntityPlayer aPlayer) { if (aPlayer.capabilities.isCreativeMode) return true; - for (int i = 0; i < aPlayer.inventory.mainInventory.length; i++) { - if (GT_Utility.isStackInList(aPlayer.inventory.mainInventory[i], GregTech_API.sSolderingMetalList)) { - if (aPlayer.inventory.mainInventory[i].stackSize < 1) return false; - if (aPlayer.inventory.mainInventory[i].stackSize == 1) { - aPlayer.inventory.mainInventory[i] = null; + if (consumeSolderingMaterial(aPlayer.inventory)) { + if (aPlayer.inventoryContainer != null) { + aPlayer.inventoryContainer.detectAndSendChanges(); + } + return true; + } + return false; + } + + /** + * Consumes soldering material from given inventory + */ + public static boolean consumeSolderingMaterial(IInventory aInventory) { + for (int i = 0; i < aInventory.getSizeInventory(); i++) { + ItemStack tStack = aInventory.getStackInSlot(i); + if (GT_Utility.isStackInList(tStack, GregTech_API.sSolderingMetalList)) { + if (tStack.stackSize < 1) return false; + if (tStack.stackSize == 1) { + tStack = null; } else { - aPlayer.inventory.mainInventory[i].stackSize--; + tStack.stackSize--; } - if (aPlayer.inventoryContainer != null) aPlayer.inventoryContainer.detectAndSendChanges(); + aInventory.setInventorySlotContents(i, tStack); + aInventory.markDirty(); return true; } } - return false; + return false; } /** @@ -1902,16 +1920,21 @@ public class GT_ModHandler { return false; } + /** + * Allow item to be inserted into ic2 toolbox + */ public static void registerBoxableItemToToolBox(ItemStack aStack) { - if (aStack != null) registerBoxableItemToToolBox(aStack.getItem()); + if (aStack != null) { + try { + ic2.api.item.ItemWrapper.registerBoxable(aStack.getItem(), (IBoxable) sBoxableWrapper); + } catch (Throwable ignored) {/*Do nothing*/} + sBoxableItems.add(new GT_ItemStack(aStack)); + } } + @Deprecated public static void registerBoxableItemToToolBox(Item aItem) { - if (aItem != null && sBoxableWrapper != null) { - try { - ic2.api.item.ItemWrapper.registerBoxable(aItem, (IBoxable) sBoxableWrapper); - } catch (Throwable e) {/*Do nothing*/} - } + registerBoxableItemToToolBox(new ItemStack(aItem, 1, GT_Values.W)); } public static int getCapsuleCellContainerCountMultipliedWithStackSize(ItemStack... aStacks) { |