diff options
author | Owen1212055 <[email protected]> | 2024-04-24 18:36:49 -0400 |
---|---|---|
committer | Owen1212055 <[email protected]> | 2024-04-24 18:36:55 -0400 |
commit | e0a245d2ea9dbb8cecd94aef33ae348e9bd6374b (patch) | |
tree | b67614ddaf337049b256b768e293480e55c3133c /removed-patches-1-20-5 | |
parent | 051855997e52adb64a9837627a5194b38c84c2d9 (diff) | |
download | Paper-e0a245d2ea9dbb8cecd94aef33ae348e9bd6374b.tar.gz Paper-e0a245d2ea9dbb8cecd94aef33ae348e9bd6374b.zip |
Patches!!!!!!!
Diffstat (limited to 'removed-patches-1-20-5')
4 files changed, 165 insertions, 0 deletions
diff --git a/removed-patches-1-20-5/0876-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch b/removed-patches-1-20-5/0876-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch new file mode 100644 index 0000000000..0731970718 --- /dev/null +++ b/removed-patches-1-20-5/0876-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Mon, 15 May 2023 00:20:59 -0700 +Subject: [PATCH] Fix concurrenct access to lookups field in RegistryOps + +The concurrent access occurs on the Netty IO threads when +serializing packets. Thus, it seems it was an oversight of +the implementator of this function as there are typically +more than one Netty IO thread. + +Fixes https://github.com/PaperMC/Folia/issues/11 + +diff --git a/src/main/java/net/minecraft/resources/RegistryOps.java b/src/main/java/net/minecraft/resources/RegistryOps.java +index 0272fe45449785e8589b6e42fa454f2abfcc0476..dd8a6bd463e5c8fe69271663cb46b45b201ba59c 100644 +--- a/src/main/java/net/minecraft/resources/RegistryOps.java ++++ b/src/main/java/net/minecraft/resources/RegistryOps.java +@@ -19,7 +19,10 @@ public class RegistryOps<T> extends DelegatingOps<T> { + + private static RegistryOps.RegistryInfoLookup memoizeLookup(RegistryOps.RegistryInfoLookup registryInfoGetter) { + return new RegistryOps.RegistryInfoLookup() { +- private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new HashMap<>(); ++ // The concurrent access occurs on the Netty IO threads when serializing packets. ++ // Thus, it seems it was an oversight of the implementator of this function as there ++ // are typically more than one Netty IO thread. ++ private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - fix concurrent access to lookups field + + @Override + public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) { diff --git a/removed-patches-1-20-5/0896-Array-backed-synched-entity-data.patch b/removed-patches-1-20-5/0896-Array-backed-synched-entity-data.patch new file mode 100644 index 0000000000..2345458940 --- /dev/null +++ b/removed-patches-1-20-5/0896-Array-backed-synched-entity-data.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: jellysquid3 <[email protected]> +Date: Sat, 8 Jul 2023 21:38:05 +0200 +Subject: [PATCH] Array backed synched entity data + +Original code by jellysquid3 in Lithium, licensed under the GNU Lesser General Public License v3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java +index d088479d160dbd2fc90b48a30553be141db8eef2..07a362f9e485d0d507f16f1dda1ac84ade07ab27 100644 +--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java ++++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java +@@ -34,6 +34,11 @@ public class SynchedEntityData { + private final Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = new Int2ObjectOpenHashMap(); + // private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required + private boolean isDirty; ++ // Paper start - Perf: array backed synched entity data ++ private static final int DEFAULT_ENTRY_COUNT = 10; ++ private static final int GROW_FACTOR = 8; ++ private SynchedEntityData.DataItem<?>[] itemsArray = new SynchedEntityData.DataItem<?>[DEFAULT_ENTRY_COUNT]; ++ // Paper end - Perf: array backed synched entity data + + public SynchedEntityData(Entity trackedEntity) { + this.entity = trackedEntity; +@@ -103,6 +108,15 @@ public class SynchedEntityData { + // this.lock.writeLock().lock(); // Spigot - not required + this.itemsById.put(key.getId(), datawatcher_item); + // this.lock.writeLock().unlock(); // Spigot - not required ++ // Paper start - Perf: array backed synched entity data ++ if (this.itemsArray.length <= key.getId()) { ++ final int newSize = Math.min(key.getId() + GROW_FACTOR, MAX_ID_VALUE); ++ ++ this.itemsArray = java.util.Arrays.copyOf(this.itemsArray, newSize); ++ } ++ ++ this.itemsArray[key.getId()] = datawatcher_item; ++ // Paper end - Perf: array backed synched entity data + } + + public <T> boolean hasItem(EntityDataAccessor<T> key) { +@@ -130,7 +144,15 @@ public class SynchedEntityData { + + return datawatcher_item; + */ +- return (SynchedEntityData.DataItem) this.itemsById.get(key.getId()); ++ // Paper start - Perf: array backed synched entity data ++ final int id = key.getId(); ++ ++ if (id < 0 || id >= this.itemsArray.length) { ++ return null; ++ } ++ ++ return (DataItem<T>) this.itemsArray[id]; ++ // Paper end - Perf: array backed synched entity data + // Spigot end + } + diff --git a/removed-patches-1-20-5/0931-Deep-clone-unhandled-nbt-tags.patch b/removed-patches-1-20-5/0931-Deep-clone-unhandled-nbt-tags.patch new file mode 100644 index 0000000000..0f522edd88 --- /dev/null +++ b/removed-patches-1-20-5/0931-Deep-clone-unhandled-nbt-tags.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: SoSeDiK <[email protected]> +Date: Thu, 26 May 2022 03:30:05 +0300 +Subject: [PATCH] Deep clone unhandled nbt tags + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +index 7d3d32679bdfe373d89a28c3616da5069640d1bb..9137d6d56386111dfd072859df84e533580ee294 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +@@ -305,7 +305,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + + private CompoundTag internalTag; +- final Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper ++ Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper - Deep clone unhandled nbt tags; remove final + private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY); + + private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only +@@ -346,8 +346,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + this.destroyableKeys = new java.util.HashSet<>(meta.destroyableKeys); + } + // Paper end - Add API for CanPlaceOn and CanDestroy NBT values +- this.unhandledTags.putAll(meta.unhandledTags); +- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw()); ++ // Paper start - Deep clone unhandled nbt tags ++ meta.unhandledTags.forEach((key, tag) -> this.unhandledTags.put(key, tag.copy())); ++ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); ++ // Paper end - Deep clone unhandled nbt tags + + this.internalTag = meta.internalTag; + if (this.internalTag != null) { +@@ -1393,7 +1395,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + if (this.hasAttributeModifiers()) { + clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers); + } +- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY); ++ // Paper start - Deep clone unhandled nbt tags ++ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY); ++ clone.unhandledTags = new TreeMap<>(this.unhandledTags); ++ clone.unhandledTags.replaceAll((key, tag) -> tag.copy()); ++ // Paper end - Deep clone unhandled nbt tags + clone.hideFlag = this.hideFlag; + clone.unbreakable = this.unbreakable; + clone.damage = this.damage; +diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +index 5a4e7e7150b7c137b077e0b393f17ed35b5aec34..f55fdd57ced259ad5a95878840e98ffaa3db2e05 100644 +--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java ++++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +@@ -207,4 +207,12 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { + } + } + // Paper end - byte array serialization ++ ++ // Paper start - deep clone tags ++ public Map<String, Tag> getTagsCloned() { ++ final Map<String, Tag> tags = new HashMap<>(); ++ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy())); ++ return tags; ++ } ++ // Paper end - deep clone tags + } diff --git a/removed-patches-1-20-5/0955-Use-correct-variable-for-initializing-CraftLootTable.patch b/removed-patches-1-20-5/0955-Use-correct-variable-for-initializing-CraftLootTable.patch new file mode 100644 index 0000000000..ab46cdf78a --- /dev/null +++ b/removed-patches-1-20-5/0955-Use-correct-variable-for-initializing-CraftLootTable.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <[email protected]> +Date: Tue, 10 Oct 2023 10:17:43 -0700 +Subject: [PATCH] Use correct variable for initializing CraftLootTable + + +diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +index 973b786368cf628815f099eefe968338c97c52ed..3ddf6ab00de2456ebf504985b88994f970e3b5c4 100644 +--- a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java ++++ b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +@@ -103,7 +103,7 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv + }); + // CraftBukkit start + map1.forEach((key, lootTable) -> { +- if (object instanceof LootTable table) { ++ if (lootTable instanceof LootTable table) { // Paper - Use correct variable for initializing CraftLootTable + table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table); + } + }); |