diff --git a/paper-server/patches/sources/net/minecraft/core/Holder.java.patch b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch new file mode 100644 index 0000000000..634a2b2190 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/Holder.java ++++ b/net/minecraft/core/Holder.java +@@ -230,7 +230,7 @@ + } + + void bindTags(Collection> tags) { +- this.tags = Set.copyOf(tags); ++ this.tags = java.util.Collections.unmodifiableSet(new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(tags)); // Paper + } + + @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java index 6cf8af0c85..d230cbc26f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java @@ -25,11 +25,11 @@ public class CraftEntityType { return bukkit; } + private static final java.util.Map>> KEY_CACHE = java.util.Collections.synchronizedMap(new java.util.EnumMap<>(EntityType.class)); // Paper public static net.minecraft.world.entity.EntityType bukkitToMinecraft(EntityType bukkit) { Preconditions.checkArgument(bukkit != null); - return CraftRegistry.getMinecraftRegistry(Registries.ENTITY_TYPE) - .getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow(); + .getOptional(KEY_CACHE.computeIfAbsent(bukkit, type -> net.minecraft.resources.ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(type.getKey())))).orElseThrow(); } public static Holder> bukkitToMinecraftHolder(EntityType bukkit) {