Skip to content

Commit

Permalink
remove some unnecessary ItemStack.copy()s
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Jul 21, 2024
1 parent e07ec4b commit 7ac8f69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public final MethodResult listCraftableItems() {
return notConnected();

List<Object> items = new ArrayList<>();
RefinedStorage.getCraftableItems(getNetwork()).forEach(item -> items.add(RefinedStorage.getObjectFromStack(item.copy(), getNetwork())));
RefinedStorage.getCraftableItems(getNetwork()).forEach(item -> items.add(RefinedStorage.getObjectFromStack(item, getNetwork())));
return MethodResult.of(items);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static ItemStack findStackFromStack(INetwork network, @Nullable ICrafting

public static ItemStack findStackFromFilter(INetwork network, @Nullable ICraftingManager crafting, ItemFilter filter) {
for (StackListEntry<ItemStack> temp : network.getItemStorageCache().getList().getStacks()) {
if (filter.test(temp.getStack().copy()))
if (filter.test(temp.getStack()))
return temp.getStack().copy();
}

Expand All @@ -64,7 +64,7 @@ public static ItemStack findStackFromFilter(INetwork network, @Nullable ICraftin

for (ICraftingPattern pattern : crafting.getPatterns()) {
for(ItemStack stack : pattern.getOutputs()) {
if (filter.test(stack.copy()))
if (filter.test(stack))
return stack.copy();
}
}
Expand All @@ -78,7 +78,7 @@ public static FluidStack findFluidFromStack(INetwork network, @Nullable ICraftin

public static FluidStack findFluidFromFilter(INetwork network, @Nullable ICraftingManager crafting, FluidFilter filter) {
for (StackListEntry<FluidStack> temp : network.getFluidStorageCache().getList().getStacks()) {
if (filter.test(temp.getStack().copy()))
if (filter.test(temp.getStack()))
return temp.getStack().copy();
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public static Object getObjectFromPattern(ICraftingPattern pattern, INetwork net
List<ItemStack> outputsList = pattern.getOutputs();
List<Object> outputs = new ArrayList<>();
for (ItemStack itemStack : outputsList)
outputs.add(getObjectFromStack(itemStack.copy(), network));
outputs.add(getObjectFromStack(itemStack, network));

map.put("outputs", outputs);

Expand All @@ -174,15 +174,15 @@ public static Object getObjectFromPattern(ICraftingPattern pattern, INetwork net
for (List<ItemStack> singleInputList : inputList) {
List<Object> inputs1 = new ArrayList<>();
for (ItemStack stack : singleInputList)
inputs1.add(getObjectFromStack(stack.copy(), network));
inputs1.add(getObjectFromStack(stack, network));
inputs.add(inputs1);
}

List<Object> byproducts = new ArrayList<>();
if (!pattern.isProcessing()) {
List<ItemStack> byproductsList = pattern.getByproducts();
for (ItemStack stack : byproductsList)
byproducts.add(getObjectFromStack(stack.copy(), network));
byproducts.add(getObjectFromStack(stack, network));
}

map.put("inputs", inputs);
Expand Down Expand Up @@ -228,7 +228,7 @@ public static Map<String, Object> getObjectFromFluid(@Nullable FluidStack fluidS
public static Object getItem(INetwork network, ItemStack item) {
for (ItemStack itemStack : getItems(network)) {
if (itemStack.sameItem(item) && Objects.equals(itemStack.getTag(), item.getTag()))
return getObjectFromStack(itemStack.copy(), network);
return getObjectFromStack(itemStack, network);
}
return null;
}
Expand Down

0 comments on commit 7ac8f69

Please sign in to comment.