9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 18:39:23 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0250-Optimize-SynchedEntityData-packDirty.patch
Dreeam 3c25377465 Drop some unused patches
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage.
And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system).
However these patches might be useful for vanilla entity storage if is used.
2025-07-09 04:20:02 +08:00

28 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Sat, 17 May 2025 19:03:31 +0900
Subject: [PATCH] Optimize SynchedEntityData#packDirty
diff --git a/net/minecraft/network/syncher/SynchedEntityData.java b/net/minecraft/network/syncher/SynchedEntityData.java
index f1ab0e66e7d464f7f31a7a360528ed97cdda0aa0..7ca540c70cd40815c0d4c18c2cae28a4cfd88e86 100644
--- a/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/net/minecraft/network/syncher/SynchedEntityData.java
@@ -84,7 +84,15 @@ public class SynchedEntityData {
return null;
} else {
this.isDirty = false;
- List<SynchedEntityData.DataValue<?>> list = new ArrayList<>();
+ // Leaf start - Optimize SynchedEntityData#packDirty
+ int cap = 0;
+ for (SynchedEntityData.DataItem<?> dataItem : this.itemsById) {
+ if (dataItem.isDirty()) {
+ cap += 1;
+ }
+ }
+ ArrayList<SynchedEntityData.DataValue<?>> list = new ArrayList<>(cap);
+ // Leaf end - Optimize SynchedEntityData#packDirty
for (SynchedEntityData.DataItem<?> dataItem : this.itemsById) {
if (dataItem.isDirty()) {