diff options
author | TimeConqueror <timeconqueror999@gmail.com> | 2021-07-15 02:53:54 +0300 |
---|---|---|
committer | TimeConqueror <timeconqueror999@gmail.com> | 2021-07-15 02:53:54 +0300 |
commit | 77f22e029303ba48f9aabad32367e500bdcefee3 (patch) | |
tree | 1e8d2753ef86908f64a759e4743a0ef2fa4925e6 /src/main/java/gregtech/api/util/GT_Utility.java | |
parent | 9f7fd2675139d4a575b6a1dc2fa1b472800a0757 (diff) | |
download | GT5-Unofficial-77f22e029303ba48f9aabad32367e500bdcefee3.tar.gz GT5-Unofficial-77f22e029303ba48f9aabad32367e500bdcefee3.tar.bz2 GT5-Unofficial-77f22e029303ba48f9aabad32367e500bdcefee3.zip |
Removed useless array creation in most #copy methods by changing them to #copyOrNull variant with single parameter.
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Utility.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 14 |
1 files changed, 8 insertions, 6 deletions
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) { |