mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-30 04:19:13 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@f00727c5 1.21.5 PaperMC/Paper@8eede4bb Fix AbstractHorse get/setSaddle PaperMC/Paper@93b6829e Also fix AbstractHorse getSize and isEmpty PaperMC/Paper@f517267c Add passthrough for air serialization PaperMC/Paper@4511edb8 [ci/skip] Don't promote checking enchantment by legacy lore (#12421) PaperMC/Paper@8f62e0fb Correctly order getArmorContents PaperMC/Paper@652cea57 Allow `getAsString()`-ing non-persistent entities (#12424) PaperMC/Paper@de64e704 Update spark PaperMC/Paper@1b889688 Add Entity#isTrackedBy (#12332) PaperMC/Paper@8ff94c63 Update a bunch of dependencies PaperMC/Paper@79036210 Remove json-simple imports from API, keep it as implementation in server PaperMC/Paper@dcb755ac Update log4j jd link PaperMC/Paper@91bfb6fb Fix freeze locked (#12434) PaperMC/Paper@121a7bf4 Make GameRule a FeatureDependant (#12429) PaperMC/Paper@7d5695d7 Improve ItemMeta#hasCustomModelData compatibility (#12414)
132 lines
5.0 KiB
Diff
132 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Thu, 13 Feb 2025 01:25:40 +0100
|
|
Subject: [PATCH] Remove iterators from Inventory
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java
|
|
index d9cb4f0ed0c4f63362c837aeef3c4194911455c9..a31b6b8b56ecced421ead0119a4423b0229ae188 100644
|
|
--- a/net/minecraft/world/entity/player/Inventory.java
|
|
+++ b/net/minecraft/world/entity/player/Inventory.java
|
|
@@ -439,13 +439,16 @@ public class Inventory implements Container, Nameable {
|
|
}
|
|
}
|
|
|
|
- for (EquipmentSlot equipmentSlot : EQUIPMENT_SLOT_MAPPING.values()) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) {
|
|
+ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i);
|
|
ItemStack itemStack = this.equipment.get(equipmentSlot);
|
|
if (itemStack == stack) {
|
|
this.equipment.set(equipmentSlot, ItemStack.EMPTY);
|
|
return;
|
|
}
|
|
}
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
}
|
|
|
|
@Override
|
|
@@ -504,17 +507,21 @@ public class Inventory implements Container, Nameable {
|
|
|
|
@Override
|
|
public boolean isEmpty() {
|
|
- for (ItemStack itemStack : this.items) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < this.items.size(); i++) {
|
|
+ ItemStack itemStack = this.items.get(i);
|
|
if (!itemStack.isEmpty()) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
- for (EquipmentSlot equipmentSlot : EQUIPMENT_SLOT_MAPPING.values()) {
|
|
+ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) {
|
|
+ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i);
|
|
if (!this.equipment.get(equipmentSlot).isEmpty()) {
|
|
return false;
|
|
}
|
|
}
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
|
|
return true;
|
|
}
|
|
@@ -561,31 +568,61 @@ public class Inventory implements Container, Nameable {
|
|
}
|
|
|
|
public boolean contains(ItemStack stack) {
|
|
- for (ItemStack itemStack : this) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < this.items.size(); i++) {
|
|
+ ItemStack itemStack = this.items.get(i);
|
|
if (!itemStack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack)) {
|
|
return true;
|
|
}
|
|
}
|
|
+ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) {
|
|
+ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i);
|
|
+ ItemStack itemStack = this.equipment.get(equipmentSlot);
|
|
+ if (!itemStack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack)) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
|
|
return false;
|
|
}
|
|
|
|
public boolean contains(TagKey<Item> tag) {
|
|
- for (ItemStack itemStack : this) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < this.items.size(); i++) {
|
|
+ ItemStack itemStack = this.items.get(i);
|
|
if (!itemStack.isEmpty() && itemStack.is(tag)) {
|
|
return true;
|
|
}
|
|
}
|
|
+ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) {
|
|
+ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i);
|
|
+ ItemStack itemStack = this.equipment.get(equipmentSlot);
|
|
+ if (!itemStack.isEmpty() && itemStack.is(tag)) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
|
|
return false;
|
|
}
|
|
|
|
public boolean contains(Predicate<ItemStack> predicate) {
|
|
- for (ItemStack itemStack : this) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < this.items.size(); i++) {
|
|
+ ItemStack itemStack = this.items.get(i);
|
|
+ if (predicate.test(itemStack)) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) {
|
|
+ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i);
|
|
+ ItemStack itemStack = this.equipment.get(equipmentSlot);
|
|
if (predicate.test(itemStack)) {
|
|
return true;
|
|
}
|
|
}
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
|
|
return false;
|
|
}
|
|
@@ -605,9 +642,12 @@ public class Inventory implements Container, Nameable {
|
|
}
|
|
|
|
public void fillStackedContents(StackedItemContents contents) {
|
|
- for (ItemStack itemStack : this.items) {
|
|
+ // Leaf start - Remove iterators from Inventory
|
|
+ for (int i = 0; i < this.items.size(); i++) {
|
|
+ ItemStack itemStack = this.items.get(i);
|
|
contents.accountSimpleStack(itemStack);
|
|
}
|
|
+ // Leaf end - Remove iterators from Inventory
|
|
}
|
|
|
|
public ItemStack removeFromSelected(boolean removeStack) {
|