mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-22 00:19:33 +00:00
Update 1.20.2 (#139)
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Wed, 17 Aug 2022 11:04:12 +0800
|
||||
Subject: [PATCH] Remove iterators from inventory contains
|
||||
|
||||
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
index 96d664c28738d6090f7067761c2978dd1aa0fd0e..41cb0d1efd81b7754b68c89af289c1260779c08b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
@@ -687,21 +687,35 @@ public class Inventory implements Container, Nameable {
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack stack) {
|
||||
- Iterator iterator = this.compartments.iterator();
|
||||
+ // Leaves start - don't allocate iterators
|
||||
+ if (top.leavesmc.leaves.LeavesConfig.removeInventoryContainsIterators) {
|
||||
+ for (int i = 0; i < this.compartments.size(); i++) {
|
||||
+ List<ItemStack> list = this.compartments.get(i);
|
||||
+ for (int j = 0; j < list.size(); j++) {
|
||||
+ ItemStack itemstack1 = list.get(j);
|
||||
+
|
||||
+ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ Iterator iterator = this.compartments.iterator();
|
||||
|
||||
- while (iterator.hasNext()) {
|
||||
- List<ItemStack> list = (List) iterator.next();
|
||||
- Iterator iterator1 = list.iterator();
|
||||
+ while (iterator.hasNext()) {
|
||||
+ List<ItemStack> list = (List) iterator.next();
|
||||
+ Iterator iterator1 = list.iterator();
|
||||
|
||||
- while (iterator1.hasNext()) {
|
||||
- ItemStack itemstack1 = (ItemStack) iterator1.next();
|
||||
+ while (iterator1.hasNext()) {
|
||||
+ ItemStack itemstack1 = (ItemStack) iterator1.next();
|
||||
|
||||
- if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) {
|
||||
- return true;
|
||||
+ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) {
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
+ // Leaves end - don't allocate iterators
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user