mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 08:59:23 +00:00
Readd Leaves protocols
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
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) {
|
||||
Reference in New Issue
Block a user