mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
* Fix TE Lag * Sepals Rearrange the attackable conditions * Cache ItemStack max stack size * fix build * extra: Skip dirty stats copy when requesting player stats * extra: Reset dirty flag when loading maps from the disk * extra: Supporting block cache * extra: Avoid useless deque clear on - credit: @MachineBreaker * experimental/draft: Optimize SortedArraySet * experimental/draft: Simplify SortedArraySet - sometime complex stuff doesnt mean faster. * extra: Change maps/sets in brain + remove streams from villagers * extra: Remove 'copyOf' from Baby Villager Sensor * experimental: Rewrite trigger in SimpleCriterionTrigger * [ci/skip] fix comments * Faster setter for SimpleCriterionTrigger * extra: Cache and optimize fluidOnEyes * Sync changes * [ci/skip] cleanup * extra: QuadTree implementation for isChunkNearPlayer * [ci/skip] cleanup * [ci/skip] cleanup * [ci/skip] clean up * [ci/skip] cleanup * Only player pushable * Store chunkPos with keys * [ci/skip] cleanup * [ci/skip] cleanup * cleanup * rebuild patches * cache some more stuff * extra: optimize collectTickingChunks * remove quadTree optimization for now (will open a new PR just for that) * temp: Lazily optimize isChunkNearPlayer * Inline filter & merge as a single loop * [ci/skip] Add diff on change * extra: optimize everything but the testing itself on getEntities * [ci/skip] cleanup * Optimize chunkUnloadQueue * Remove iterators from inventory * [ci/skip] Add TODOs * i hate programming * remove forEach * extra: Alternative Brain Behaviour * remove: opt getEntities + cache fluidOnEyes * extra: Improve checkDespawn - credits: @kidofcubes * extra: Improve pushEntity and getEntities * yeet this * VERY EXPERIMENTAL: getEntities Optimization * fix bunch of issues from getEntities patch * extra: slightly optimize getNearestPlayer - credits: @kidofcubes * drop a patch for now (will open a new pr) * move these to a new branch * fix and optimize checkDespawn patches * Rebuild Patches * [ci/skip] Update benchmark * [ci/skip] cleanup * Drop * [ci/skip] Drop * Rebuild * [ci/skip] * Add configurable brain running behavior cache update interval * Move to new pr * [ci/skip] Update benchmark --------- Co-authored-by: MachineBreaker <saltspigotpp@gmail.com> Co-authored-by: kidofcubes <kidofcubes@gmail.com> Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
67 lines
3.1 KiB
Diff
67 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Fri, 7 Feb 2025 21:41:51 +0100
|
|
Subject: [PATCH] Cache ItemStack max stack size
|
|
|
|
TODO: check this, fix get max stack size
|
|
|
|
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
|
|
index fd7c1e800cbd4919a1a47f6c468c8776535bd028..fdd7e89bacc98e23f067ba17d0bd93ee84a388cb 100644
|
|
--- a/net/minecraft/world/item/ItemStack.java
|
|
+++ b/net/minecraft/world/item/ItemStack.java
|
|
@@ -194,6 +194,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
public static final ItemStack EMPTY = new ItemStack((Void)null);
|
|
private static final Component DISABLED_ITEM_TOOLTIP = Component.translatable("item.disabled").withStyle(ChatFormatting.RED);
|
|
+ private int maxStackSize;
|
|
private int count;
|
|
private int popTime;
|
|
@Deprecated
|
|
@@ -289,11 +290,13 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods
|
|
this.count = count;
|
|
this.components = components;
|
|
this.getItem().verifyComponentsAfterLoad(this);
|
|
+ this.maxStackSize = getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size
|
|
}
|
|
|
|
private ItemStack(@Nullable Void unused) {
|
|
this.item = null;
|
|
this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY);
|
|
+ this.maxStackSize = 1; // Leaf - Cache ItemStack max stack size - taken from ItemStack#isEmpty
|
|
}
|
|
|
|
public static DataResult<Unit> validateComponents(DataComponentMap components) {
|
|
@@ -619,9 +622,15 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods
|
|
}
|
|
|
|
public int getMaxStackSize() {
|
|
- return this.getOrDefault(DataComponents.MAX_STACK_SIZE, Integer.valueOf(1));
|
|
+ return maxStackSize; // Leaf - Cache ItemStack max stack size
|
|
}
|
|
|
|
+ // Leaf start - Cache ItemStack max stack size
|
|
+ private int getMaxStackSizeInternal() {
|
|
+ return this.getOrDefault(DataComponents.MAX_STACK_SIZE, 1);
|
|
+ }
|
|
+ // Leaf end - Cache ItemStack max stack size
|
|
+
|
|
public boolean isStackable() {
|
|
return this.getMaxStackSize() > 1 && (!this.isDamageableItem() || !this.isDamaged());
|
|
}
|
|
@@ -1339,6 +1348,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods
|
|
this.components = new PatchedDataComponentMap(this.item.components());
|
|
this.applyComponents(patch);
|
|
// Paper end - change base component prototype
|
|
+ this.maxStackSize = getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size
|
|
}
|
|
// CraftBukkit end
|
|
|
|
@@ -1396,6 +1406,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods
|
|
}
|
|
// Leaf end - Lithium - equipment tracking
|
|
this.count = count;
|
|
+ maxStackSize = count <= 0 ? 1 : getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size - taken from ItemStack#isEmpty
|
|
}
|
|
|
|
public void limitSize(int maxSize) {
|