From ad5b4e6e71af48c2a39f27865454d6707a6d830d Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Thu, 1 Jul 2021 19:48:29 +0800 Subject: make item filter recipe more reasonable --- .../java/gregtech/common/items/GT_MetaGenerated_Item_01.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/main/java/gregtech/common/items') diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java index f0904485d4..9bac6eefe4 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java @@ -849,17 +849,13 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 { GregTech_API.registerCover(ItemList.Cover_NeedsMaintainance.get(1L), TextureFactory.of(MACHINE_CASINGS[2][0], TextureFactory.of(TextureFactory.of(OVERLAY_ACTIVITYDETECTOR), TextureFactory.builder().addIcon(OVERLAY_ACTIVITYDETECTOR_GLOW).glow().build())), new GT_Cover_NeedMaintainance()); GT_Values.RA.addAssemblerRecipe(ItemList.Emitter_MV.get(1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), ItemList.Cover_NeedsMaintainance.get(1L), 600, 24); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plateDouble.get(Materials.StainlessSteel),'S',OrePrefixes.screw.get(Materials.StainlessSteel),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_HV}); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plateDouble.get(Materials.StainlessSteel),'S',OrePrefixes.screw.get(Materials.StainlessSteel),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_HV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{ItemList.ItemFilter_Import.get(1L)}); GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{ItemList.ItemFilter_Export.get(1L)}); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.SolderingAlloy.getMolten(72L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.Tin.getMolten(144L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.Lead.getMolten(288L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.SolderingAlloy.getMolten(72L),ItemList.ItemFilter_Import.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.Tin.getMolten(144L),ItemList.ItemFilter_Import.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.Lead.getMolten(288L),ItemList.ItemFilter_Import.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(1)},null,ItemList.ItemFilter_Export.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(2)},null,ItemList.ItemFilter_Import.get(1L),100,30); } private static final Map cauldronRemap =new HashMap<>(); -- cgit From 0b1fb32ae1b83cb91e9d83ff4c229172f5aa7700 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Fri, 2 Jul 2021 14:42:23 +0800 Subject: add the space --- .../java/gregtech/common/items/GT_MetaGenerated_Item_01.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/common/items') diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java index 9bac6eefe4..839e7db715 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java @@ -849,13 +849,13 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 { GregTech_API.registerCover(ItemList.Cover_NeedsMaintainance.get(1L), TextureFactory.of(MACHINE_CASINGS[2][0], TextureFactory.of(TextureFactory.of(OVERLAY_ACTIVITYDETECTOR), TextureFactory.builder().addIcon(OVERLAY_ACTIVITYDETECTOR_GLOW).glow().build())), new GT_Cover_NeedMaintainance()); GT_Values.RA.addAssemblerRecipe(ItemList.Emitter_MV.get(1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), ItemList.Cover_NeedsMaintainance.get(1L), 600, 24); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); - GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{ItemList.ItemFilter_Import.get(1L)}); - GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{ItemList.ItemFilter_Export.get(1L)}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L), new Object[]{"SPS", "dIC", "SPS", 'P', OrePrefixes.plate.get(Materials.Tin), 'S', OrePrefixes.screw.get(Materials.Iron), 'I', ItemList.Component_Filter, 'C', ItemList.Conveyor_Module_LV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L), new Object[]{"SPS", "CId", "SPS", 'P', OrePrefixes.plate.get(Materials.Tin), 'S', OrePrefixes.screw.get(Materials.Iron), 'I', ItemList.Component_Filter, 'C', ItemList.Conveyor_Module_LV}); + GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L), new Object[]{ItemList.ItemFilter_Import.get(1L)}); + GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L), new Object[]{ItemList.ItemFilter_Export.get(1L)}); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(1)},null,ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(2)},null,ItemList.ItemFilter_Import.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L), ItemList.Component_Filter.get(1L), ItemList.Conveyor_Module_LV.get(1L), GT_Utility.getIntegratedCircuit(1)}, null, ItemList.ItemFilter_Export.get(1L), 100, 30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L), ItemList.Component_Filter.get(1L), ItemList.Conveyor_Module_LV.get(1L), GT_Utility.getIntegratedCircuit(2)}, null, ItemList.ItemFilter_Import.get(1L), 100, 30); } private static final Map cauldronRemap =new HashMap<>(); -- cgit From 77f22e029303ba48f9aabad32367e500bdcefee3 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 15 Jul 2021 02:53:54 +0300 Subject: Removed useless array creation in most #copy methods by changing them to #copyOrNull variant with single parameter. --- src/main/java/gregtech/api/gui/GT_Container.java | 8 +-- .../api/metatileentity/MetaPipeEntity.java | 2 +- .../api/metatileentity/MetaTileEntity.java | 2 +- .../GT_MetaTileEntity_BasicGenerator.java | 2 +- .../GT_MetaTileEntity_BasicMachine.java | 2 +- .../GT_MetaTileEntity_MultiBlockBase.java | 2 +- src/main/java/gregtech/api/util/GT_BaseCrop.java | 10 ++-- src/main/java/gregtech/api/util/GT_FoodStat.java | 4 +- src/main/java/gregtech/api/util/GT_ModHandler.java | 57 +++++++++++----------- .../gregtech/api/util/GT_OreDictUnificator.java | 8 +-- src/main/java/gregtech/api/util/GT_Recipe.java | 18 +++---- src/main/java/gregtech/api/util/GT_Utility.java | 14 +++--- .../java/gregtech/common/GT_ThaumcraftCompat.java | 4 +- .../gregtech/common/entities/GT_Entity_Arrow.java | 2 +- .../common/gui/GT_Container_Regulator.java | 2 +- .../common/items/behaviors/Behaviour_DataOrb.java | 2 +- .../items/behaviors/Behaviour_Sonictron.java | 2 +- .../machines/basic/GT_MetaTileEntity_Scanner.java | 4 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../GT_MetaTileEntity_PrimitiveBlastFurnace.java | 2 +- .../loaders/oreprocessing/ProcessingLog.java | 8 +-- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 6 +-- .../java/gregtech/nei/GT_NEI_DefaultHandler.java | 6 +-- 23 files changed, 86 insertions(+), 83 deletions(-) (limited to 'src/main/java/gregtech/common/items') diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index 608c6015d5..e00759bf24 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -142,7 +142,7 @@ public class GT_Container extends Container { if (aSlot != null && aSlot.canTakeStack(aPlayer)) { tTempStack = this.transferStackInSlot(aPlayer, aSlotIndex); if (tTempStack != null) { - rStack = GT_Utility.copy(tTempStack); + rStack = GT_Utility.copyOrNull(tTempStack); if (aSlot.getStack() != null && aSlot.getStack().getItem() == tTempStack.getItem()) { slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @@ -157,7 +157,7 @@ public class GT_Container extends Container { tTempStack = aSlot.getStack(); ItemStack var13 = aPlayerInventory.getItemStack(); if (tTempStack != null) { - rStack = GT_Utility.copy(tTempStack); + rStack = GT_Utility.copyOrNull(tTempStack); } if (tTempStack == null) { if (var13 != null && aSlot.isItemValid(var13)) { @@ -253,7 +253,7 @@ public class GT_Container extends Container { } else if (aShifthold == 3 && aPlayer.capabilities.isCreativeMode && aPlayerInventory.getItemStack() == null && aSlotIndex >= 0) { aSlot = (Slot) this.inventorySlots.get(aSlotIndex); if (aSlot != null && aSlot.getHasStack()) { - tTempStack = GT_Utility.copy(aSlot.getStack()); + tTempStack = GT_Utility.copyOrNull(aSlot.getStack()); tTempStack.stackSize = tTempStack.getMaxStackSize(); aPlayerInventory.setItemStack(tTempStack); } @@ -271,7 +271,7 @@ public class GT_Container extends Container { //null checks and checks if the item can be stacked (maxStackSize > 1) if (getSlotCount() > 0 && slotObject != null && slotObject.getHasStack() && !(slotObject instanceof GT_Slot_Holo)) { ItemStack stackInSlot = slotObject.getStack(); - stack = GT_Utility.copy(stackInSlot); + stack = GT_Utility.copyOrNull(stackInSlot); //TileEntity -> Player if (aSlotIndex < getAllSlotCount()) { diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 601b6fb4f9..1070c97364 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -503,7 +503,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); + ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copyOrNull(tStack); if (tStack != null) { if (tStack.stackSize <= aAmount) { if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 87eee3e6ac..d9f90b06b7 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -696,7 +696,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { @Override public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); + ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copyOrNull(tStack); if (tStack != null) { if (tStack.stackSize <= aAmount) { if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index ccc0fc0af4..9bbfbf0a3a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -303,7 +303,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public ItemStack getEmptyContainer(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + if (tFuel != null) return GT_Utility.copyOrNull(tFuel.getOutput(0)); return GT_Utility.getContainerItem(aStack, true); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 834344d2d2..5698eabc76 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -549,7 +549,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; for (int i = 0; i < mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + mOutputItems[i] = GT_Utility.copyOrNull(mOutputItems[i]); if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) mOutputItems[i].stackSize = 64; mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 193b9d482c..0de4dfecbb 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -741,7 +741,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean addOutput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; - aStack = GT_Utility.copy(aStack); + aStack = GT_Utility.copyOrNull(aStack); for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { if (isValidMetaTileEntity(tHatch) && tHatch.storeAll(aStack)) { return true; diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index c06bf82b89..97f8db0547 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -68,7 +68,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { aID = GT_Config.addIDConfig(ConfigCategories.IDs.crops, mName.replaceAll(" ", "_"), aID); if (aDiscoveredBy != null && !aDiscoveredBy.equals(E)) mDiscoveredBy = aDiscoveredBy; if (aDrop != null && aID > 0 && aID < 256) { - mDrop = GT_Utility.copy(aDrop); + mDrop = GT_Utility.copyOrNull(aDrop); mSpecialDrops = aSpecialDrops; mTier = Math.max(1, aTier); mMaxSize = Math.max(3, aMaxSize); @@ -177,9 +177,9 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { public ItemStack getGain(ICropTile aCrop) { int tDrop = 0; if (mSpecialDrops != null && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { - return GT_Utility.copy(mSpecialDrops[tDrop]); + return GT_Utility.copyOrNull(mSpecialDrops[tDrop]); } - return GT_Utility.copy(mDrop); + return GT_Utility.copyOrNull(mDrop); } @Override @@ -247,9 +247,9 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public ItemStack getDisplayItem() { if (mSpecialDrops != null && mSpecialDrops[mSpecialDrops.length - 1] != null) { - return GT_Utility.copy(mSpecialDrops[mSpecialDrops.length - 1]); + return GT_Utility.copyOrNull(mSpecialDrops[mSpecialDrops.length - 1]); } - return GT_Utility.copy(mDrop); + return GT_Utility.copyOrNull(mDrop); } } diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java index ce89881a5b..193977476a 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -36,7 +36,7 @@ public class GT_FoodStat implements IFoodStat { mSaturation = aSaturation; mAction = aAction == null ? EnumAction.eat : aAction; mPotionEffects = aPotionEffects; - mEmptyContainer = GT_Utility.copy(aEmptyContainer); + mEmptyContainer = GT_Utility.copyOrNull(aEmptyContainer); mInvisibleParticles = aInvisibleParticles; mAlwaysEdible = aAlwaysEdible; mIsRotten = aIsRotten; @@ -65,7 +65,7 @@ public class GT_FoodStat implements IFoodStat { @Override public void onEaten(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) { aStack.stackSize--; - ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer)); + ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copyOrNull(mEmptyContainer)); if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack)) aPlayer.dropPlayerItemWithRandomChoice(tStack, true); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index f82b0ecb7e..7e66e6cc2a 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -460,8 +460,8 @@ public class GT_ModHandler { aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance); if (aChance <= 0) return false; try { - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copy(aOutput), aChance); - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copy(aOutput), aChance); + GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copyOrNull(aOutput), aChance); + GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copyOrNull(aOutput), aChance); } catch (Throwable e) {/*Do nothing*/} return true; } @@ -484,7 +484,7 @@ public class GT_ModHandler { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null || GT_Utility.getContainerItem(aInput, false) != null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.smelting, aInput, true)) return false; - FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F); + FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copyOrNull(aOutput), 0.0F); return true; } @@ -562,8 +562,8 @@ public class GT_ModHandler { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null || aTime <= 0) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rcblastfurnace, aInput, true)) return false; - aInput = GT_Utility.copy(aInput); - aOutput = GT_Utility.copy(aOutput); + aInput = GT_Utility.copyOrNull(aInput); + aOutput = GT_Utility.copyOrNull(aOutput); try { mods.railcraft.api.crafting.RailcraftCraftingManager.blastFurnace.addRecipe(aInput, true, false, aTime, aOutput); } catch (Throwable e) { @@ -614,28 +614,28 @@ public class GT_ModHandler { if (Materials.Wood.contains(aOutput1)) { if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) - ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); + ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1)); else - ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2); + ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1), GT_Utility.copyOrNull(aOutput2), aChance2 <= 0 ? 10 : aChance2); } } else { if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rockcrushing, aInput, true)) { try { if (GT_Utility.getBlockFromStack(aInput) != Blocks.obsidian && GT_Utility.getBlockFromStack(aInput) != Blocks.gravel) { mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != W, false); - tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput1), 1.0F / aInput.stackSize); if (aOutput2 != null) - tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize); if (aOutput3 != null) - tRecipe.addOutput(GT_Utility.copy(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize); } } catch (Throwable e) {/*Do nothing*/} } if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) - ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); + ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1)); else - ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2); + ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1), GT_Utility.copyOrNull(aOutput2), aChance2 <= 0 ? 10 : aChance2); } } } @@ -702,7 +702,7 @@ public class GT_ModHandler { if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true)) return false; try { - ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copy(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance); + ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copyOrNull(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance); } catch (Throwable e) {/*Do nothing*/} return true; } @@ -713,7 +713,7 @@ public class GT_ModHandler { public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null) return false; - FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F); + FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copyOrNull(aOutput), 0.0F); return true; } @@ -847,9 +847,9 @@ public class GT_ModHandler { aResult = GT_OreDictUnificator.get(true, aResult); if (aResult == null || aRecipe == null || aResult.stackSize <= 0) return false; try { - mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copy(aResult), aRecipe)); + mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copyOrNull(aResult), aRecipe)); } catch (Throwable e) { - return addCraftingRecipe(GT_Utility.copy(aResult), aRecipe); + return addCraftingRecipe(GT_Utility.copyOrNull(aResult), aRecipe); } return true; } @@ -1084,8 +1084,9 @@ public class GT_ModHandler { Character chr = (Character) aRecipe[idx]; Object in = aRecipe[idx + 1]; if (in instanceof ItemStack) { - tItemStackMap.put(chr, GT_Utility.copy(in)); - tItemDataMap.put(chr, GT_OreDictUnificator.getItemData((ItemStack) in)); + ItemStack is = (ItemStack) in; + tItemStackMap.put(chr, GT_Utility.copyOrNull(is)); + tItemDataMap.put(chr, GT_OreDictUnificator.getItemData(is)); } else if (in instanceof ItemData) { String tString = in.toString(); switch (tString) { @@ -1184,9 +1185,9 @@ public class GT_ModHandler { if (tThereWasARecipe || !aOnlyAddIfThereIsAnyRecipeOutputtingThis) { if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); else - GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); } return true; } @@ -1260,9 +1261,9 @@ public class GT_ModHandler { GT_Utility.updateItemStack(aResult); if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); else - GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); return true; } @@ -1531,7 +1532,7 @@ public class GT_ModHandler { throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); } else { if (aUncopiedStack) return tOutput; - return GT_Utility.copy(tOutput); + return GT_Utility.copyOrNull(tOutput); } } } @@ -1679,7 +1680,7 @@ public class GT_ModHandler { if (tRecipe instanceof ShapelessRecipes) continue; if (tRecipe instanceof ShapelessOreRecipe) continue; if (tRecipe instanceof IGT_CraftingRecipe) continue; - rList.add(GT_Utility.copy(tOutput)); + rList.add(GT_Utility.copyOrNull(tOutput)); aList.remove(i--); } } @@ -1691,7 +1692,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getMaceratorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1699,7 +1700,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getExtractorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1707,7 +1708,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getCompressorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1748,7 +1749,7 @@ public class GT_ModHandler { for (byte i = 0; i < aOutputSlots.length && i < tList.length; i++) { if (tList[i] != null) { if (aOutputSlots[i] == null || (GT_Utility.areStacksEqual(tList[i], aOutputSlots[i]) && tList[i].stackSize + aOutputSlots[i].stackSize <= aOutputSlots[i].getMaxStackSize())) { - rList[i] = GT_Utility.copy(tList[i]); + rList[i] = GT_Utility.copyOrNull(tList[i]); } else { return new ItemStack[aOutputSlots.length]; } diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 98809bbf45..54ef5b2866 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -123,7 +123,7 @@ public class GT_OreDictUnificator { } public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) { - for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); + for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copyOrNull(aStacks[i])); return aStacks; } @@ -155,15 +155,15 @@ public class GT_OreDictUnificator { ItemData tPrefixMaterial = getAssociation(aStack); ItemStack rStack = null; if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return GT_Utility.copy(aStack); + return GT_Utility.copyOrNull(aStack); if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; - return GT_Utility.copy(aStack); + return GT_Utility.copyOrNull(aStack); } if (tPrefixMaterial.mUnificationTarget == null) tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); rStack = tPrefixMaterial.mUnificationTarget; - if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack); + if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copyOrNull(aStack); assert rStack != null; rStack.setTagCompound(aStack.getTagCompound()); return GT_Utility.copyAmount(aStack.stackSize, rStack); diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index aa54b55277..0214eab54b 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -312,12 +312,12 @@ public class GT_Recipe implements Comparable { public ItemStack getRepresentativeInput(int aIndex) { if (aIndex < 0 || aIndex >= mInputs.length) return null; - return GT_Utility.copy(mInputs[aIndex]); + return GT_Utility.copyOrNull(mInputs[aIndex]); } public ItemStack getOutput(int aIndex) { if (aIndex < 0 || aIndex >= mOutputs.length) return null; - return GT_Utility.copy(mOutputs[aIndex]); + return GT_Utility.copyOrNull(mOutputs[aIndex]); } public int getOutputChance(int aIndex) { @@ -1215,7 +1215,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.compressor.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1238,7 +1238,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.extractor.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1261,7 +1261,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.centrifuge.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 48, 0) : null; } @@ -1285,7 +1285,7 @@ public class GT_Recipe implements Comparable { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 || !GT_ModHandler.isWater(aFluids[0])) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); NBTTagCompound aRecipeMetaData = new NBTTagCompound(); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.oreWashing.getRecipes(), true, aRecipeMetaData, null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount"))}, null, 400, 16, 0) : null; @@ -1334,7 +1334,7 @@ public class GT_Recipe implements Comparable { if (D1) GT_Log.err.println("Railcraft Not loaded"); } catch (NullPointerException e) {/**/} - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.macerator.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1823,13 +1823,13 @@ public class GT_Recipe implements Comparable { if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) { ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length]; for (int i = 0; i < mOreDictAlt[aIndex].length; i++) { - rStacks[i] = GT_Utility.copy(mOreDictAlt[aIndex][i]); + rStacks[i] = GT_Utility.copyOrNull(mOreDictAlt[aIndex][i]); } return rStacks; } } if (aIndex >= mInputs.length) return null; - return GT_Utility.copy(mInputs[aIndex]); + return GT_Utility.copyOrNull(mInputs[aIndex]); } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8e283956cb..8e839c8ba0 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -89,6 +89,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.lang.reflect.Constructor; @@ -439,7 +441,7 @@ public class GT_Utility { if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack)); + ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyOrNull(tStack)); byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) { //((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F); @@ -459,7 +461,7 @@ public class GT_Utility { if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copy(tStack), false, ForgeDirection.getOrientation(aPutTo)); + byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyOrNull(tStack), false, ForgeDirection.getOrientation(aPutTo)); if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) { tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo))); aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); @@ -510,7 +512,7 @@ public class GT_Utility { ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), tStack3 = null; if (tStack1 != null) { if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0; - tStack3 = copy(tStack1); + tStack3 = copyOrNull(tStack1); aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, Math.min(tStack3.getMaxStackSize(), Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), aTileEntity2.getInventoryStackLimit()))); tStack3.stackSize = Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize)); if (tStack3.stackSize > aMaxMoveAtOnce) tStack3.stackSize = aMaxMoveAtOnce; @@ -519,7 +521,7 @@ public class GT_Utility { aTileEntity1.markDirty(); if (tStack3 != null) { if (tStack2 == null) { - aTileEntity2.setInventorySlotContents(aPutTo, copy(tStack3)); + aTileEntity2.setInventorySlotContents(aPutTo, copyOrNull(tStack3)); } else { tStack2.stackSize += tStack3.stackSize; } @@ -1147,7 +1149,7 @@ public class GT_Utility { if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false; aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } else { - aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); + aRecipeList.put(new RecipeInputItemStack(copyOrNull(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } return true; } @@ -1191,7 +1193,7 @@ public class GT_Utility { rStack.setTagCompound(tNBT); GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + "' - Author: '" + aAuthor + "'"); GregTech_API.sBookList.put(aMapping, rStack); - return copy(rStack); + return copyOrNull(rStack); } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength) { diff --git a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java index bc6372e41c..e4472824e7 100644 --- a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java +++ b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java @@ -182,7 +182,7 @@ public class GT_ThaumcraftCompat implements IThaumcraftCompat { if ((GT_Utility.isStringInvalid(aResearch)) || (aInput == null) || (aOutput == null) || (aAspects == null) || (aAspects.isEmpty())) { return null; } - return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), ((aInput instanceof ItemStack)) || ((aInput instanceof ArrayList)) ? aInput : aInput.toString(), getAspectList(aAspects)); + return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copyOrNull(aOutput), ((aInput instanceof ItemStack)) || ((aInput instanceof ArrayList)) ? aInput : aInput.toString(), getAspectList(aAspects)); } @Override @@ -190,7 +190,7 @@ public class GT_ThaumcraftCompat implements IThaumcraftCompat { if ((GT_Utility.isStringInvalid(aResearch)) || (aMainInput == null) || (aSideInputs == null) || (aOutput == null) || (aAspects == null) || (aAspects.isEmpty())) { return null; } - return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), aInstability, getAspectList(aAspects), aMainInput, aSideInputs); + return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, GT_Utility.copyOrNull(aOutput), aInstability, getAspectList(aAspects), aMainInput, aSideInputs); } @Override diff --git a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java index b7c87b4860..7a44ade127 100644 --- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java +++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java @@ -345,7 +345,7 @@ public class GT_Entity_Arrow extends EntityArrow { } public ItemStack getArrowItem() { - return GT_Utility.copy(this.mArrow); + return GT_Utility.copyOrNull(this.mArrow); } public void setArrowItem(ItemStack aStack) { diff --git a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java index f432c9b5d5..f50ac2dae3 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java @@ -81,7 +81,7 @@ public class GT_Container_Regulator extends GT_ContainerMetaTile_Machine { if ((aSlotIndex < 19)) { ItemStack tStack = aPlayer.inventory.getItemStack(); if (tStack != null) { - tSlot.putStack(GT_Utility.copy(new Object[]{tStack})); + tSlot.putStack(GT_Utility.copyOrNull(tStack)); } else if (tSlot.getStack() != null) { if (aMouseclick == 0) { tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java index b909593694..a5393cdec5 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java @@ -14,7 +14,7 @@ public class Behaviour_DataOrb extends Behaviour_None { if (aNewContent[i] == null) { aInventory[i] = null; } else { - aInventory[i] = GT_Utility.copy(new Object[]{aNewContent[i]}); + aInventory[i] = GT_Utility.copyOrNull(aNewContent[i]); } } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java index a0dea777f7..bcaa8242f3 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java @@ -90,7 +90,7 @@ public class Behaviour_Sonictron extends Behaviour_None { if (aNewContent[i] == null) { aInventory[i] = null; } else { - aInventory[i] = GT_Utility.copy(aNewContent[i]); + aInventory[i] = GT_Utility.copyOrNull(aNewContent[i]); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index 11430c6862..eba61ad1b1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -86,7 +86,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { if (tIndividual != null) { if (tIndividual.analyze()) { getFillableStack().amount -= 100; - this.mOutputItems[0] = GT_Utility.copy(aStack); + this.mOutputItems[0] = GT_Utility.copyOrNull(aStack); aStack.stackSize = 0; NBTTagCompound tNBT = new NBTTagCompound(); tIndividual.writeToNBT(tNBT); @@ -97,7 +97,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } - this.mOutputItems[0] = GT_Utility.copy(aStack); + this.mOutputItems[0] = GT_Utility.copyOrNull(aStack); aStack.stackSize = 0; this.mMaxProgresstime = 1; this.mEUt = 1; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index d7b7e2aa4d..a57a237060 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -207,7 +207,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu if (!storedItem.isItemEqual(miningPipe)) continue; if (pipes == null) { - setInventorySlotContents(1, GT_Utility.copy(miningPipe)); + setInventorySlotContents(1, GT_Utility.copyOrNull(miningPipe)); pipes = getStackInSlot(1); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java index f1b304a1b1..eab4e9c896 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -282,7 +282,7 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn for (int i = 0; i < limit; i++) { int absi = INPUT_SLOTS + i; if (this.mInventory[absi] == null) { - this.mInventory[absi] = GT_Utility.copy(this.mOutputItems[i]); + this.mInventory[absi] = GT_Utility.copyOrNull(this.mOutputItems[i]); } else if (GT_Utility.areStacksEqual(this.mInventory[absi], this.mOutputItems[i])) { this.mInventory[absi].stackSize = Math.min(this.mInventory[absi].getMaxStackSize(), this.mInventory[absi].stackSize + this.mOutputItems[i].stackSize); diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java index dfccc35684..fc60328e44 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java @@ -56,9 +56,9 @@ public class ProcessingLog implements gregtech.api.interfaces.IOreRecipeRegistra } else { - ItemStack tPlanks = GT_Utility.copy(tStack); + ItemStack tPlanks = GT_Utility.copyOrNull(tStack); tPlanks.stackSize = (tPlanks.stackSize * 3 / 2); - GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), Materials.Lubricant.getFluid(1L), GT_Utility.copy(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); + GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), Materials.Lubricant.getFluid(1L), GT_Utility.copyOrNull(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), GT_Utility.copyAmount(GT_Mod.gregtechproxy.mNerfedWoodPlank ? tStack.stackSize : tStack.stackSize * 5 / 4, tStack), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 2L), 200, 8); GT_ModHandler.addSawmillRecipe(new ItemStack(aStack.getItem(), 1, i), tPlanks, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L)); GT_ModHandler.removeRecipeDelayed(new ItemStack(aStack.getItem(), 1, i)); @@ -75,9 +75,9 @@ public class ProcessingLog implements gregtech.api.interfaces.IOreRecipeRegistra } ItemStack tStack = GT_ModHandler.getRecipeOutput(GT_Utility.copyAmount(1L, aStack)); if (tStack != null) { - ItemStack tPlanks = GT_Utility.copy(tStack); + ItemStack tPlanks = GT_Utility.copyOrNull(tStack); tPlanks.stackSize = (tPlanks.stackSize * 3 / 2); - GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), Materials.Lubricant.getFluid(1L), GT_Utility.copy(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); + GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), Materials.Lubricant.getFluid(1L), GT_Utility.copyOrNull(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), GT_Utility.copyAmount(GT_Mod.gregtechproxy.mNerfedWoodPlank ? tStack.stackSize : tStack.stackSize * 5 / 4, tStack), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 2L), 200, 8); GT_ModHandler.addSawmillRecipe(GT_Utility.copyAmount(1L, aStack), tPlanks, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L)); GT_ModHandler.removeRecipeDelayed(GT_Utility.copyAmount(1L, aStack)); diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index 6c315edb42..c692a2dce1 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -105,7 +105,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); + tResults.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -147,7 +147,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); + tInputs.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -370,7 +370,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tDisplayStacks.add(base); } } else { - tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + tDisplayStacks.add(GT_Utility.copyOrNull(tStack)); } } } diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index f37eea25e9..a4fc75a24e 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -102,7 +102,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); + tResults.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -136,7 +136,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); + tInputs.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -385,7 +385,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tDisplayStacks.add(base); } } else { - tDisplayStacks.add(GT_Utility.copy(tStack)); + tDisplayStacks.add(GT_Utility.copyOrNull(tStack)); } } } -- cgit From 3e59d9f8f2db7d56d9b1431b1e3b93c97752e20a Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 1 Aug 2021 16:29:52 -0600 Subject: Add cracked fluid cells --- build.properties | 2 +- src/main/java/gregtech/api/enums/OrePrefixes.java | 30 ++++- .../GT_MetaTileEntity_BasicGenerator.java | 21 +-- src/main/java/gregtech/api/util/GT_ModHandler.java | 17 ++- src/main/java/gregtech/common/GT_Proxy.java | 28 ++-- .../common/items/GT_MetaGenerated_Item_04.java | 146 +++++++++++++++++++++ .../preload/GT_Loader_Item_Block_And_Fluid.java | 1 + 7 files changed, 222 insertions(+), 23 deletions(-) create mode 100644 src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java (limited to 'src/main/java/gregtech/common/items') diff --git a/build.properties b/build.properties index 6f7b5408b8..9c6f282480 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.05 +gt.version=5.09.37.06 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 3aaea29f28..77b6ee9426 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -1,6 +1,7 @@ package gregtech.api.enums; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.interfaces.ICondition; @@ -319,8 +320,27 @@ public enum OrePrefixes { bars("Bars", "", "", false, false, false, false, false, false, false, false, false, false, 0, -1, 64, -1), bar("Bars", "", "", false, false, false, false, false, false, false, false, false, false, 0, -1, 64, -1), toolHeadMallet("Mallet Heads", "", " Mallet Head", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 127), // Reverse Head consisting out of 6 Ingots. - handleMallet("Mallet Handle", "", " Handle", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 126); // Reverse Stick made of half an Ingot. Introduced by Eloraam - + handleMallet("Mallet Handle", "", " Handle", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 126), // Reverse Stick made of half an Ingot. Introduced by Eloraam + + // Cracked fluids + cellHydroCracked1("Cells", "Lightly Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellHydroCracked2("Cells", "Moderately Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellHydroCracked3("Cells", "Severely Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked1("Cells", "Lightly Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked2("Cells", "Moderately Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked3("Cells", "Severely Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30); + + public static final ImmutableList CELL_TYPES = + ImmutableList.of( + cell, cellMolten, cellPlasma, + cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, + cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); + + public static final ImmutableList CRACKED_CELL_TYPES = + ImmutableList.of( + cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, + cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); + public static volatile int VERSION = 509; static { @@ -531,6 +551,12 @@ public enum OrePrefixes { cell.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellPlasma.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellMolten.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); oreRedgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteRed, dust.mMaterialAmount); oreBlackgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteBlack, dust.mMaterialAmount); oreNetherrack.mSecondaryMaterial = new MaterialStack(Materials.Netherrack, dust.mMaterialAmount); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 48d1bd8a18..57f7073e24 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -245,16 +245,17 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public boolean solidFuelOverride(ItemStack stack) { //this could be used for a coal generator for example aswell... ItemData association = GT_OreDictUnificator.getAssociation(stack); - //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK, cell, motlen cell or plasma cell, else do vanilla checks - return association != null ? !OrePrefixes.cell.equals(association.mPrefix) && - !OrePrefixes.cellMolten.equals(association.mPrefix) && - !OrePrefixes.cellPlasma.equals(association.mPrefix) && - !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true) : - stack != null && //when the stack is null its not a solid - stack.getItem() != null && //when the item in the stack is null its not a solid - !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... - !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... - !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK or any type of cell, else do vanilla checks + if (association != null) { + return !OrePrefixes.CELL_TYPES.contains(association.mPrefix) && + !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true); + } else { + return stack != null && //when the stack is null its not a solid + stack.getItem() != null && //when the item in the stack is null its not a solid + !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... + !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... + !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + } } public abstract int getPollution(); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index ac9f7bd3d4..a910723069 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -2008,7 +2008,22 @@ public class GT_ModHandler { public static int getCapsuleCellContainerCount(ItemStack aStack) { if (aStack == null) return 0; - return GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(aStack, true), ItemList.Cell_Empty.get(1)) || OrePrefixes.cell.contains(aStack) || OrePrefixes.cellMolten.contains(aStack) || OrePrefixes.cellPlasma.contains(aStack) || GT_Utility.areStacksEqual(aStack, getIC2Item("waterCell", 1, W)) ? 1 : 0; + + if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(aStack, true), ItemList.Cell_Empty.get(1))) { + return 1; + } + + if (GT_Utility.areStacksEqual(aStack, getIC2Item("waterCell", 1, W))) { + return 1; + } + + for (OrePrefixes cellType : OrePrefixes.CELL_TYPES) { + if (cellType.contains(aStack)) { + return 1; + } + } + + return 0; } public static class RecipeBits { diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 51aadf574e..3e76335410 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1781,8 +1781,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public void addAutoGeneratedHydroCrackedFluids(Materials aMaterial){ Fluid[] crackedFluids = new Fluid[3]; - String[] prefixes = {"lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked."}; - String[] localPrefixes = {"Lightly Hydro-Cracked ", "Moderately Hydro-Cracked ", "Severely Hydro-Cracked "}; + String[] namePrefixes = { "lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked." }; + OrePrefixes[] orePrefixes = { OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3 }; GT_Fluid uncrackedFluid = null; if (aMaterial.mFluid != null) { uncrackedFluid = (GT_Fluid) aMaterial.mFluid; @@ -1790,8 +1790,13 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { uncrackedFluid = (GT_Fluid) aMaterial.mGas; } for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid(prefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, - localPrefixes[i] + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, null, null, 0); + crackedFluids[i] = addFluid( + namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, + orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, + null, aMaterial.mRGBa, 2, 775, + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), + ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + int hydrogenAmount = 2 * i + 2; GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), Materials.Hydrogen.getGas(hydrogenAmount * 1000), new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 120 + 60 * i); @@ -1805,8 +1810,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public void addAutoGeneratedSteamCrackedFluids(Materials aMaterial){ Fluid[] crackedFluids = new Fluid[3]; - String[] prefixes = {"lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked."}; - String[] localPrefixes = {"Lightly Steam-Cracked ", "Moderately Steam-Cracked ", "Severely Steam-Cracked "}; + String[] namePrefixes = { "lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked." }; + OrePrefixes[] orePrefixes = { OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3 }; GT_Fluid uncrackedFluid = null; if (aMaterial.mFluid != null) { uncrackedFluid = (GT_Fluid) aMaterial.mFluid; @@ -1814,9 +1819,14 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { uncrackedFluid = (GT_Fluid) aMaterial.mGas; } for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid(prefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, - localPrefixes[i] + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, null, null, 0); - GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), + crackedFluids[i] = addFluid( + namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, + orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, + null, aMaterial.mRGBa, 2, 775, + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), + ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + + GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); GT_Values.RA.addChemicalRecipe(GT_ModHandler.getIC2Item("steamCell", 1L), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java new file mode 100644 index 0000000000..728128ac39 --- /dev/null +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java @@ -0,0 +1,146 @@ +package gregtech.common.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.BitSet; +import java.util.List; + +import static gregtech.api.enums.GT_Values.M; + +/** Generates cells for cracked fluids. */ +public class GT_MetaGenerated_Item_04 extends GT_MetaGenerated_Item { + public static GT_MetaGenerated_Item_04 INSTANCE; + + private static final int NUM_CRACKED_CELL_TYPES = OrePrefixes.CRACKED_CELL_TYPES.size(); + + private BitSet enabled = new BitSet(); + + public GT_MetaGenerated_Item_04() { + super("metaitem.04", (short) (NUM_CRACKED_CELL_TYPES * 1000), (short) 0); + INSTANCE = this; + + for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { + if (tMaterial == null || !tMaterial.canBeCracked() || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1000) { + continue; + } + register(tMaterial, tMaterial.mMetaItemSubID); + } + + // We're not going to use these BitSets, so clear them to save memory. + mEnabledItems.clear(); + mVisibleItems.clear(); + } + + private void register(Materials tMaterial, int i) { + int currIndex = NUM_CRACKED_CELL_TYPES * i; + for (OrePrefixes type : OrePrefixes.CRACKED_CELL_TYPES) { + ItemStack tStack = new ItemStack(this, 1, currIndex); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", type.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(type.mMaterialAmount / M)); + + if (type.mIsUnificatable) { + GT_OreDictUnificator.set(type, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(type.get(tMaterial), tStack); + } + + enabled.set(currIndex); + currIndex++; + } + } + + private int getMaterialIndex(int damage) { + return damage / NUM_CRACKED_CELL_TYPES; + } + + /** Returns null for item damage out of bounds. */ + private OrePrefixes getOrePrefix(int damage) { + if (damage < 0 || damage >= NUM_CRACKED_CELL_TYPES * 1000) { + return null; + } + return OrePrefixes.CRACKED_CELL_TYPES.get(damage % NUM_CRACKED_CELL_TYPES); + } + + @Override + public short[] getRGBa(ItemStack aStack) { + Materials tMaterial = GregTech_API.sGeneratedMaterials[getMaterialIndex(aStack.getItemDamage())]; + return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + + int index = getMaterialIndex(aStack.getItemDamage()); + if (index >= 0 && index < 1000) { + return Materials.getLocalizedNameForItem(aName, index); + } + + return aName; + } + + @Override + public ItemStack getContainerItem(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mContainerItem; + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + enabled.stream() + .mapToObj(i -> new ItemStack(this, 1, i)) + .forEach(aList::add); + } + + @Override + public final IIcon getIconFromDamage(int aMetaData) { + IIconContainer iconContainer = getIconContainer(aMetaData); + if (iconContainer != null) { + return iconContainer.getIcon(); + } + return null; + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + int index = getMaterialIndex(aMetaData); + if (index < 0 || index >= 1000) { + return null; + } + + Materials material = GregTech_API.sGeneratedMaterials[index]; + OrePrefixes prefix = getOrePrefix(aMetaData); + if (material != null && prefix != null) { + return material.mIconSet.mTextures[prefix.mTextureIndex]; + } + + return null; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mDefaultStackSize; + } else { + // If we're here, then something went wrong. Use cell.mDefaultStackSize as a fallback. + return OrePrefixes.cell.mDefaultStackSize; + } + } +} diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index 4fbc25f226..77b65e5b18 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -71,6 +71,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { new GT_MetaGenerated_Item_01(); new GT_MetaGenerated_Item_02(); new GT_MetaGenerated_Item_03(); + new GT_MetaGenerated_Item_04(); new GT_MetaGenerated_Item_99(); new GT_MetaGenerated_Tool_01(); new GT_FluidDisplayItem(); -- cgit From 2b698673853da3c2ef05954a884f08be3434315e Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:27:44 -0600 Subject: Use MetaGenerated_Item_99 --- src/main/java/gregtech/api/enums/OrePrefixes.java | 5 - .../common/items/GT_MetaGenerated_Item_04.java | 146 --------------- .../common/items/GT_MetaGenerated_Item_99.java | 200 ++++++++++++--------- .../preload/GT_Loader_Item_Block_And_Fluid.java | 1 - 4 files changed, 115 insertions(+), 237 deletions(-) delete mode 100644 src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java (limited to 'src/main/java/gregtech/common/items') diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 77b6ee9426..cf8c776469 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -336,11 +336,6 @@ public enum OrePrefixes { cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); - public static final ImmutableList CRACKED_CELL_TYPES = - ImmutableList.of( - cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, - cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); - public static volatile int VERSION = 509; static { diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java deleted file mode 100644 index 728128ac39..0000000000 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java +++ /dev/null @@ -1,146 +0,0 @@ -package gregtech.common.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.items.GT_MetaGenerated_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import java.util.BitSet; -import java.util.List; - -import static gregtech.api.enums.GT_Values.M; - -/** Generates cells for cracked fluids. */ -public class GT_MetaGenerated_Item_04 extends GT_MetaGenerated_Item { - public static GT_MetaGenerated_Item_04 INSTANCE; - - private static final int NUM_CRACKED_CELL_TYPES = OrePrefixes.CRACKED_CELL_TYPES.size(); - - private BitSet enabled = new BitSet(); - - public GT_MetaGenerated_Item_04() { - super("metaitem.04", (short) (NUM_CRACKED_CELL_TYPES * 1000), (short) 0); - INSTANCE = this; - - for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { - if (tMaterial == null || !tMaterial.canBeCracked() || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1000) { - continue; - } - register(tMaterial, tMaterial.mMetaItemSubID); - } - - // We're not going to use these BitSets, so clear them to save memory. - mEnabledItems.clear(); - mVisibleItems.clear(); - } - - private void register(Materials tMaterial, int i) { - int currIndex = NUM_CRACKED_CELL_TYPES * i; - for (OrePrefixes type : OrePrefixes.CRACKED_CELL_TYPES) { - ItemStack tStack = new ItemStack(this, 1, currIndex); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", type.getDefaultLocalNameFormatForItem(tMaterial)); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(type.mMaterialAmount / M)); - - if (type.mIsUnificatable) { - GT_OreDictUnificator.set(type, tMaterial, tStack); - } else { - GT_OreDictUnificator.registerOre(type.get(tMaterial), tStack); - } - - enabled.set(currIndex); - currIndex++; - } - } - - private int getMaterialIndex(int damage) { - return damage / NUM_CRACKED_CELL_TYPES; - } - - /** Returns null for item damage out of bounds. */ - private OrePrefixes getOrePrefix(int damage) { - if (damage < 0 || damage >= NUM_CRACKED_CELL_TYPES * 1000) { - return null; - } - return OrePrefixes.CRACKED_CELL_TYPES.get(damage % NUM_CRACKED_CELL_TYPES); - } - - @Override - public short[] getRGBa(ItemStack aStack) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[getMaterialIndex(aStack.getItemDamage())]; - return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - - int index = getMaterialIndex(aStack.getItemDamage()); - if (index >= 0 && index < 1000) { - return Materials.getLocalizedNameForItem(aName, index); - } - - return aName; - } - - @Override - public ItemStack getContainerItem(ItemStack aStack) { - OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); - if (prefix != null) { - return prefix.mContainerItem; - } - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - enabled.stream() - .mapToObj(i -> new ItemStack(this, 1, i)) - .forEach(aList::add); - } - - @Override - public final IIcon getIconFromDamage(int aMetaData) { - IIconContainer iconContainer = getIconContainer(aMetaData); - if (iconContainer != null) { - return iconContainer.getIcon(); - } - return null; - } - - @Override - public IIconContainer getIconContainer(int aMetaData) { - int index = getMaterialIndex(aMetaData); - if (index < 0 || index >= 1000) { - return null; - } - - Materials material = GregTech_API.sGeneratedMaterials[index]; - OrePrefixes prefix = getOrePrefix(aMetaData); - if (material != null && prefix != null) { - return material.mIconSet.mTextures[prefix.mTextureIndex]; - } - - return null; - } - - @Override - public int getItemStackLimit(ItemStack aStack) { - OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); - if (prefix != null) { - return prefix.mDefaultStackSize; - } else { - // If we're here, then something went wrong. Use cell.mDefaultStackSize as a fallback. - return OrePrefixes.cell.mDefaultStackSize; - } - } -} diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java index 2b94d96cb0..1c27310d99 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java @@ -1,5 +1,6 @@ package gregtech.common.items; +import com.google.common.collect.ImmutableList; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -24,145 +25,174 @@ import static gregtech.api.enums.OrePrefixes.cellMolten; public class GT_MetaGenerated_Item_99 extends GT_MetaGenerated_Item { public static GT_MetaGenerated_Item_99 INSTANCE; - private BitSet enabled=new BitSet(); + /** + * Ore prefixes appear in this list in the order in which they will be assigned ID blocks. + * + *

In order to avoid breaking existing worlds, the entries in this list must not be re-ordered! The only safe + * modification that can be made to this list is adding new entries to the end. + */ + private static final ImmutableList CRACKED_CELL_TYPES = + ImmutableList.of( + OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3, + OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3); + private static final int NUM_CRACKED_CELL_TYPES = CRACKED_CELL_TYPES.size(); - private void register(Materials tMaterial,int i){ - ItemStack tStack = new ItemStack(this, 1, i); - enabled.set(i); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalizationFormat(cellMolten, tMaterial, i)); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(cellMolten.mMaterialAmount / M)); - if (cellMolten.mIsUnificatable) { - GT_OreDictUnificator.set(cellMolten, tMaterial, tStack); - } else { - GT_OreDictUnificator.registerOre(cellMolten.get(tMaterial), tStack); - } - } - //x32 + /** + * Assignment of metadata IDs: + * 0 - 999: Molten cells + * 10_000 - 15_999: Cracked fluid cells (# IDs used is NUM_CRACKED_CELL_TYPES * 1_000; update this if you add any) + */ + private BitSet enabled = new BitSet(); public GT_MetaGenerated_Item_99() { - super("metaitem.99", (short) 1000, (short) 0); + super("metaitem.99", (short) (10_000 + NUM_CRACKED_CELL_TYPES * 1_000), (short) 0); INSTANCE = this; - for (Materials tMaterial:GregTech_API.sGeneratedMaterials) { - if (tMaterial == null || tMaterial.mMetaItemSubID<0 || tMaterial.mMetaItemSubID>=1000) continue; - //if (tMaterial.getcells(1)==null) { + for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { + if (tMaterial == null || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1_000) { + continue; + } + if ((tMaterial.contains(SubTag.SMELTING_TO_FLUID)) && (!tMaterial.contains(SubTag.NO_SMELTING)) && !tMaterial.contains(SubTag.SMELTING_TO_GEM)) { - register(tMaterial,tMaterial.mMetaItemSubID); - if (tMaterial.mSmeltInto != tMaterial) { - register(tMaterial.mSmeltInto,tMaterial.mSmeltInto.mMetaItemSubID); + registerMolten(tMaterial, tMaterial.mMetaItemSubID); + if (tMaterial.mSmeltInto != tMaterial + && tMaterial.mSmeltInto.mMetaItemSubID >= 0 && tMaterial.mSmeltInto.mMetaItemSubID < 1_000) { + registerMolten(tMaterial.mSmeltInto, tMaterial.mSmeltInto.mMetaItemSubID); } } - //} + + if (tMaterial.canBeCracked()) { + registerCracked(tMaterial, tMaterial.mMetaItemSubID); + } } + + // We're not going to use these BitSets, so clear them to save memory. mEnabledItems.clear(); mVisibleItems.clear(); } - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + private void registerMolten(Materials tMaterial,int i){ + ItemStack tStack = new ItemStack(this, 1, i); + enabled.set(i); - /** - * @return the Color Modulation the Material is going to be rendered with. - */ - @Override - public short[] getRGBa(ItemStack aStack) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[getDamage(aStack)]; - return tMaterial == null ? Materials._NULL.mMoltenRGBa : tMaterial.mMoltenRGBa; + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", cellMolten.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(cellMolten.mMaterialAmount / M)); + + if (cellMolten.mIsUnificatable) { + GT_OreDictUnificator.set(cellMolten, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(cellMolten.get(tMaterial), tStack); + } } - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + private void registerCracked(Materials tMaterial, int i) { + int offset = 10_000; + for (OrePrefixes prefix : CRACKED_CELL_TYPES) { + ItemStack tStack = new ItemStack(this, 1, offset + i); + enabled.set(offset + i); - /** - * @param aPrefix the OreDict Prefix - * @param aMaterial the Material - * @param aMetaData a Index from [0 - 31999] - * @return the Localized Name when default LangFiles are used. - */ - @Deprecated - public String getDefaultLocalization(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { - return aPrefix.getDefaultLocalNameForItem(aMaterial); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", prefix.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(prefix.mMaterialAmount / M)); + + if (prefix.mIsUnificatable) { + GT_OreDictUnificator.set(prefix, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(prefix.get(tMaterial), tStack); + } + + offset += 1_000; + } } - /** - * @param aPrefix the OreDict Prefix - * @param aMaterial the Material - * @param aMetaData a Index from [0 - 31999] - * @return the Localized Name Format when default LangFiles are used. - */ - public String getDefaultLocalizationFormat(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { - return aPrefix.getDefaultLocalNameFormatForItem(aMaterial); + /** Returns null for item damage out of bounds. */ + private Materials getMaterial(int damage) { + if (damage < 0) { + return null; + } + return GregTech_API.sGeneratedMaterials[damage % 1_000]; } - /** - * @param aPrefix always != null - * @param aMaterial always != null - * @param aDoShowAllItems this is the Configuration Setting of the User, if he wants to see all the Stuff like Tiny Dusts or Crushed Ores as well. - * @return if this Item should be visible in NEI or Creative - */ - public boolean doesShowInCreative(OrePrefixes aPrefix, Materials aMaterial, boolean aDoShowAllItems) { - return true; + /** Returns null for item damage out of bounds. */ + private OrePrefixes getOrePrefix(int damage) { + if (damage < 0) { + return null; + } else if (damage < 1_000) { + return cellMolten; + } else if (damage >= 10_000 && damage < 10_000 + (NUM_CRACKED_CELL_TYPES * 1_000)) { + return CRACKED_CELL_TYPES.get((damage / 1_000) - 10); + } + return null; } - /* ---------- INTERNAL OVERRIDES ---------- */ + @Override + public short[] getRGBa(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + Materials material = getMaterial(aStack.getItemDamage()); + if (material == null) { + material = Materials._NULL; + } + + if (prefix == cellMolten) { + return material.mMoltenRGBa; + } else { + return material.mRGBa; + } + } @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); - int aDamage = aStack.getItemDamage(); - if (aDamage < 1000 && aDamage >= 0) - return Materials.getLocalizedNameForItem(aName, aDamage); + Materials material = getMaterial(aStack.getItemDamage()); + if (material != null) { + return material.getLocalizedNameForItem(aName); + } return aName; } @Override public ItemStack getContainerItem(ItemStack aStack) { - int aDamage = aStack.getItemDamage(); - if (aDamage < 1000 && aDamage >= 0) { - return cellMolten.mContainerItem; + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mContainerItem; } return null; } @Override @SideOnly(Side.CLIENT) - public final void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 1000; i++) { - Materials aMaterial = GregTech_API.sGeneratedMaterials[i]; - if (aMaterial != null && enabled.get(i)) { - ItemStack tStack = new ItemStack(this, 1, i); - isItemStackUsable(tStack); - aList.add(tStack); - } - } - super.getSubItems(var1, aCreativeTab, aList); + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + enabled.stream() + .mapToObj(i -> new ItemStack(this, 1, i)) + .forEach(aList::add); } @Override public final IIcon getIconFromDamage(int aMetaData) { - if (aMetaData < 0) return null; - if (aMetaData < 1000) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData]; - if (tMaterial == null) return null; - IIconContainer tIcon = getIconContainer(aMetaData); - if (tIcon != null) return tIcon.getIcon(); - return null; + IIconContainer iconContainer = getIconContainer(aMetaData); + if (iconContainer != null) { + return iconContainer.getIcon(); } return null; } @Override public IIconContainer getIconContainer(int aMetaData) { - if (aMetaData < 0) return null; - if (aMetaData < 1000) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData]; - if (tMaterial == null) return null; - return tMaterial.mIconSet.mTextures[cellMolten.mTextureIndex]; + Materials material = getMaterial(aMetaData); + OrePrefixes prefix = getOrePrefix(aMetaData); + if (material != null && prefix != null) { + return material.mIconSet.mTextures[prefix.mTextureIndex]; } return null; } @Override public int getItemStackLimit(ItemStack aStack) { - return cellMolten.mDefaultStackSize; + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mDefaultStackSize; + } else { + return 64; + } } } diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index 77b65e5b18..4fbc25f226 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -71,7 +71,6 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { new GT_MetaGenerated_Item_01(); new GT_MetaGenerated_Item_02(); new GT_MetaGenerated_Item_03(); - new GT_MetaGenerated_Item_04(); new GT_MetaGenerated_Item_99(); new GT_MetaGenerated_Tool_01(); new GT_FluidDisplayItem(); -- cgit From b05f1651f62eb87823f4ed9fe5143931b48150d9 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Mon, 16 Aug 2021 02:34:35 +0300 Subject: Removed useless concurrency for some maps --- .../gregtech/api/items/GT_MetaGenerated_Tool.java | 3 ++- .../implementations/GT_MetaPipeEntity_Item.java | 4 +-- .../java/gregtech/api/objects/CollectorUtils.java | 29 ++++++++++++++++++++++ src/main/java/gregtech/api/util/GT_Utility.java | 12 +++------ .../items/behaviors/Behaviour_Plunger_Item.java | 4 +-- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 src/main/java/gregtech/api/objects/CollectorUtils.java (limited to 'src/main/java/gregtech/common/items') 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 65e9dfcc39..82f19351a5 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -47,6 +47,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.world.BlockEvent; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; @@ -645,7 +646,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements return false; } Materials aMaterial = getPrimaryMaterial(aStack); - ConcurrentHashMap tMap = new ConcurrentHashMap(), tResult = new ConcurrentHashMap(); + HashMap tMap = new HashMap<>(), tResult = new HashMap<>(); if (aMaterial.mEnchantmentTools != null) { tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); if (aMaterial.mEnchantmentTools == Enchantment.fortune) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index a4cc0e407e..edec79fe65 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -29,8 +29,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.Textures.BlockIcons.PIPE_RESTRICTOR; @@ -174,7 +174,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) { temp = false; tPipeList.clear(); - for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new ConcurrentHashMap(), 0, false, false)).keySet()) { + for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<>(), 0, false, false)).keySet()) { if (temp) break; tPipeList.add(tTileEntity); while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) diff --git a/src/main/java/gregtech/api/objects/CollectorUtils.java b/src/main/java/gregtech/api/objects/CollectorUtils.java new file mode 100644 index 0000000000..3f89ad0773 --- /dev/null +++ b/src/main/java/gregtech/api/objects/CollectorUtils.java @@ -0,0 +1,29 @@ +package gregtech.api.objects; + +import java.util.Map; +import java.util.function.BiFunction; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collector; +import java.util.stream.Collectors; + +public class CollectorUtils { + /** + * Returns a merge function, suitable for use in + * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or + * {@link Collectors#toMap(Function, Function, BinaryOperator) toMap()}, which always + * throws {@code IllegalStateException}. This can be used to enforce the + * assumption that the elements being collected are distinct. + * + * @param the type of input arguments to the merge function + * @return a merge function which always throw {@code IllegalStateException} + */ + public static BinaryOperator throwingMerger() { + return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; + } + + public static , M extends Map> Collector entriesToMap(Supplier mapSupplier) { + return Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, CollectorUtils.throwingMerger(), mapSupplier); + } +} diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 17606b85a4..be5f978d6e 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -22,6 +22,7 @@ import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.net.GT_Packet_Sound; +import gregtech.api.objects.CollectorUtils; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; @@ -1752,15 +1753,8 @@ public class GT_Utility { return aMap; } - /** - * Why the fuck do neither Java nor Guava have a Function to do this? - */ - public static LinkedHashMap sortMapByValuesAcending(Map aMap) { - List> tEntrySet = new LinkedList<>(aMap.entrySet()); - tEntrySet.sort(Entry.comparingByValue()); - LinkedHashMap rMap = new LinkedHashMap<>(); - for (Map.Entry tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue()); - return rMap; + public static > LinkedHashMap sortMapByValuesAcending(Map map) { + return map.entrySet().stream().sorted(Entry.comparingByValue()).collect(CollectorUtils.entriesToMap(LinkedHashMap::new)); } /** diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java index 43a95fd2c7..ddb88b80c8 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java @@ -14,8 +14,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; public class Behaviour_Plunger_Item extends Behaviour_None { private final int mCosts; @@ -34,7 +34,7 @@ public class Behaviour_Plunger_Item extends Behaviour_None { if ((aTileEntity instanceof IGregTechTileEntity)) { IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); if ((tMetaTileEntity instanceof IMetaTileEntityItemPipe)) { - for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, new ConcurrentHashMap(), 0L, false, true)).keySet()) + for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, new HashMap<>(), 0L, false, true)).keySet()) { int i = 0; -- cgit