13
0
geforkt von Mirrors/Paper
Paper/patches/server/0874-cache-resource-keys.patch
Nassim Jahnke ef0e5a642d
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API
48c0c547 PR-786: Add methods to get sounds from entities

CraftBukkit Changes:
5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event
4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation
4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API
e5d6a9bbf PR-1100: Add methods to get sounds from entities
b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta

Spigot Changes:
4c157bb4 Rebuild patches
2022-09-12 13:31:45 +02:00

58 Zeilen
4.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 20 Mar 2022 22:06:47 -0700
Subject: [PATCH] cache resource keys
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 22356c2380741dd811810420127e247e46b0b8e2..bfe9dc935c87e01fb435d8b46ce413b84ca74856 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -366,12 +366,13 @@ public class CraftBlock implements Block {
return (biome == null) ? Biome.CUSTOM : biome;
}
+ private static final java.util.Map<org.bukkit.block.Biome, net.minecraft.resources.ResourceKey<net.minecraft.world.level.biome.Biome>> BIOME_KEY_CACHE = Collections.synchronizedMap(new java.util.EnumMap<>(Biome.class)); // Paper
public static Holder<net.minecraft.world.level.biome.Biome> biomeToBiomeBase(net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> registry, Biome bio) {
if (bio == null || bio == Biome.CUSTOM) {
return null;
}
- return registry.getHolderOrThrow(ResourceKey.create(net.minecraft.core.Registry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(bio.getKey())));
+ return registry.getHolderOrThrow(BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(net.minecraft.core.Registry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(b.getKey())))); // Paper - cache key
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java
index 393bb27648501c6f25cf846e929f4c95b1a0b11f..979f82d589e378b9e52417d20b48d66f077f5dfd 100644
--- a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java
+++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java
@@ -16,9 +16,10 @@ public class CraftEntityTag extends CraftTag<net.minecraft.world.entity.EntityTy
super(registry, tag);
}
+ private static final java.util.Map<org.bukkit.entity.EntityType, net.minecraft.resources.ResourceKey<net.minecraft.world.entity.EntityType<?>>> KEY_CACHE = Collections.synchronizedMap(new java.util.EnumMap<>(EntityType.class)); // Paper
@Override
public boolean isTagged(EntityType entity) {
- return registry.getHolderOrThrow(ResourceKey.create(net.minecraft.core.Registry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag);
+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(entity, type -> ResourceKey.create(net.minecraft.core.Registry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(type.getKey())))).is(tag); // Paper - cache key
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
index cdd474e9b0363641839a66d3e61fec46c735879a..3611e3e9d33a0f1d82a78a27ea5c2c649225f564 100644
--- a/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
+++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
@@ -14,9 +14,10 @@ public class CraftFluidTag extends CraftTag<net.minecraft.world.level.material.F
super(registry, tag);
}
+ private static final java.util.Map<Fluid, net.minecraft.resources.ResourceKey<net.minecraft.world.level.material.Fluid>> KEY_CACHE = Collections.synchronizedMap(new java.util.EnumMap<>(Fluid.class)); // Paper
@Override
public boolean isTagged(Fluid fluid) {
- return registry.getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.Registry.FLUID_REGISTRY, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(fluid.getKey()))).is(tag); // Paper
+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(fluid, f -> net.minecraft.resources.ResourceKey.create(net.minecraft.core.Registry.FLUID_REGISTRY, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(f.getKey())))).is(tag); // Paper - cache key
}
@Override