From 29b207245fad95ed37093b47d0354fe196063526 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 31 Oct 2024 23:44:34 +0100 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#11543) 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: 97c59261 PR-1073: Make Biome an interface a38581aa Fix further javadoc errors 8271c490 Fix javadoc error 8a9ecf29 PR-1072: Fix bad naming for Vault State methods 6dd58108 PR-1071: Make Fluid an interface and add missing entry ed2cdfc3 PR-1070: Make Attribute an interface and align names with the new minecraft ones 63472efb PR-1069: Add missing winter drop experimental annotation to pale boats CraftBukkit Changes: 7235ad7b0 PR-1501: Make Biome an interface 602904003 PR-1500: Rename implementation for Vault State methods 75f26f79f PR-1499: Make Fluid an interface and add missing entry 4cfd87adc PR-1498: Make Attribute an interface and align names with the new minecraft ones 6bb0db5cb SPIGOT-7928: ExactChoice acts as MaterialChoice 3eaf3a13c SPIGOT-7929: Error when setting EquippableComponent abbf57bac SPIGOT-7930: Fix spawning entities with SummonEntityEffect 92d6ab6cf PR-1497: Move boat field rename entries to below key renaming, so that keys are also renamed abfe292aa PR-1496: Use correct Fluid class on Tags type check c7aab7fa7 SPIGOT-7923: Fix Dispenser logic to avoid firing empty projectiles --- patches/api/Add-FeatureFlag-API.patch | 2 +- .../api/Add-NamespacedKey-biome-methods.patch | 4 ++ ...gistryAccess-for-managing-registries.patch | 28 +++++++++++++ .../Add-methods-to-get-translation-keys.patch | 41 +++++++------------ patches/api/Add-missing-Fluid-type.patch | 23 ----------- ...x-custom-statistic-criteria-creation.patch | 2 +- patches/api/Fix-upstream-javadocs.patch | 6 +-- patches/api/Improve-death-events.patch | 2 +- patches/api/Paper-Plugins.patch | 2 +- patches/server/Add-FeatureFlag-API.patch | 8 ++-- .../Add-NamespacedKey-biome-methods.patch | 7 +--- ...gistryAccess-for-managing-Registries.patch | 29 +++++++++++-- .../Add-methods-to-get-translation-keys.patch | 16 ++++++++ .../Add-registry-entry-and-builders.patch | 2 +- patches/server/CB-fixes.patch | 13 ------ ...eys-and-optimize-reference-Holder-ta.patch | 28 ------------- .../Expose-server-build-information.patch | 2 +- ...x-custom-statistic-criteria-creation.patch | 4 +- .../server/Fixup-NamespacedKey-handling.patch | 2 +- patches/server/General-ItemMeta-fixes.patch | 9 ---- .../Get-entity-default-attributes.patch | 4 +- patches/server/Improve-death-events.patch | 2 +- ...he-changed-item-from-dispense-events.patch | 12 +++--- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 25 files changed, 116 insertions(+), 136 deletions(-) delete mode 100644 patches/api/Add-missing-Fluid-type.patch diff --git a/patches/api/Add-FeatureFlag-API.patch b/patches/api/Add-FeatureFlag-API.patch index 9eccd985f..cb94bed50 100644 --- a/patches/api/Add-FeatureFlag-API.patch +++ b/patches/api/Add-FeatureFlag-API.patch @@ -251,7 +251,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -0,0 +0,0 @@ public interface UnsafeValues { - + @Deprecated(since = "1.21.3", forRemoval = true) String getTranslationKey(Attribute attribute); - @Nullable diff --git a/patches/api/Add-NamespacedKey-biome-methods.patch b/patches/api/Add-NamespacedKey-biome-methods.patch index b03bd574c..988dde154 100644 --- a/patches/api/Add-NamespacedKey-biome-methods.patch +++ b/patches/api/Add-NamespacedKey-biome-methods.patch @@ -22,9 +22,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param x X-coordinate of the block + * @param y Y-coordinate of the block + * @param z Z-coordinate of the block ++ * @deprecated custom biomes are properly supported in API now + * @return the biome's {@link NamespacedKey} + */ + @org.jetbrains.annotations.NotNull ++ @Deprecated(since = "1.21.3", forRemoval = true) + NamespacedKey getBiomeKey(RegionAccessor accessor, int x, int y, int z); + + /** @@ -38,8 +40,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param y Y-coordinate of the block + * @param z Z-coordinate of the block + * @param biomeKey Biome key ++ * @deprecated custom biomes are properly supported in API now + * @throws IllegalStateException if no biome by the given key is registered. + */ ++ @Deprecated(since = "1.21.3", forRemoval = true) + void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey); + // Paper end - namespaced key biome methods } diff --git a/patches/api/Add-RegistryAccess-for-managing-registries.patch b/patches/api/Add-RegistryAccess-for-managing-registries.patch index 0b128edeb..e7bb459f7 100644 --- a/patches/api/Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/Add-RegistryAccess-for-managing-registries.patch @@ -211,6 +211,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -0,0 +0,0 @@ public interface Registry extends Iterable { + * Attribute. + * + * @see Attribute ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#ATTRIBUTE} + */ +- Registry ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); ++ @Deprecated(since = "1.21.3") // Paper ++ Registry ATTRIBUTE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); + /** * Server banner patterns. * * @see PatternType @@ -222,6 +231,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Server biomes. * + * @see Biome ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#BIOME} + */ +- Registry BIOME = Objects.requireNonNull(Bukkit.getRegistry(Biome.class), "No registry present for Biome. This is a bug."); ++ @Deprecated(since = "1.21.3") // Paper ++ Registry BIOME = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Biome.class), "No registry present for Biome. This is a bug."); + /** + * Server block types. + * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { * @apiNote BlockType is not ready for public usage yet */ @@ -358,6 +376,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Memory Keys. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { + * Server fluids. + * + * @see Fluid ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#FLUID} + */ +- Registry FLUID = Objects.requireNonNull(Bukkit.getRegistry(Fluid.class), "No registry present for Fluid. This is a bug."); ++ @Deprecated(since = "1.21.3") ++ Registry FLUID = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Fluid.class), "No registry present for Fluid. This is a bug."); + /** + * Frog variants. * * @see Frog.Variant */ diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch index 1ffd838fb..0a3a6ab4e 100644 --- a/patches/api/Add-methods-to-get-translation-keys.patch +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -242,46 +242,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Types of attributes which may be present on an {@link Attributable}. */ --public enum Attribute implements Keyed, Translatable { -+public enum Attribute implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations +-public interface Attribute extends OldEnum, Keyed, Translatable { ++public interface Attribute extends OldEnum, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations /** * Maximum health of an Entity. -@@ -0,0 +0,0 @@ public enum Attribute implements Keyed, Translatable { - public String getTranslationKey() { - return Bukkit.getUnsafe().getTranslationKey(this); - } -+ -+ // Paper start -+ @SuppressWarnings("deprecation") -+ @Override -+ public @NotNull String translationKey() { -+ return Bukkit.getUnsafe().getTranslationKey(this); -+ } -+ // Paper end - } diff --git a/src/main/java/org/bukkit/block/Biome.java b/src/main/java/org/bukkit/block/Biome.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Biome.java +++ b/src/main/java/org/bukkit/block/Biome.java @@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; - /** - * Holds all accepted Biomes in the default server + * There may be additional biomes present in the server, for example from a {@link DataPack} + * which can be accessed via {@link Registry#BIOME}. */ --public enum Biome implements Keyed { -+public enum Biome implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - OCEAN, - PLAINS, - DESERT, -@@ -0,0 +0,0 @@ public enum Biome implements Keyed { - public NamespacedKey getKey() { - return key; +-public interface Biome extends OldEnum, Keyed { ++public interface Biome extends OldEnum, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + + Biome OCEAN = getBiome("ocean"); + Biome PLAINS = getBiome("plains"); +@@ -0,0 +0,0 @@ public interface Biome extends OldEnum, Keyed { + static Biome[] values() { + return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]); } + + // Paper start + @Override -+ public @NotNull String translationKey() { -+ return "biome.minecraft." + this.key.getKey(); ++ default @NotNull String translationKey() { ++ return "biome.minecraft." + this.getKey().getKey(); + } + // Paper end } diff --git a/patches/api/Add-missing-Fluid-type.patch b/patches/api/Add-missing-Fluid-type.patch deleted file mode 100644 index 570bc121b..000000000 --- a/patches/api/Add-missing-Fluid-type.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Sun, 4 Dec 2022 10:07:16 -0800 -Subject: [PATCH] Add missing Fluid type - - -diff --git a/src/main/java/org/bukkit/Fluid.java b/src/main/java/org/bukkit/Fluid.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/Fluid.java -+++ b/src/main/java/org/bukkit/Fluid.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; - */ - public enum Fluid implements Keyed { - -+ // Paper start -+ /** -+ * No fluid. -+ */ -+ EMPTY, -+ // Paper end - /** - * Stationary water. - */ diff --git a/patches/api/Fix-custom-statistic-criteria-creation.patch b/patches/api/Fix-custom-statistic-criteria-creation.patch index 7d4a07dff..9e43959f2 100644 --- a/patches/api/Fix-custom-statistic-criteria-creation.patch +++ b/patches/api/Fix-custom-statistic-criteria-creation.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -0,0 +0,0 @@ public interface UnsafeValues { - */ + @Deprecated(since = "1.21.3", forRemoval = true) void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey); // Paper end - namespaced key biome methods + diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index 74e963cea..38105436a 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -600,9 +600,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Setting the size of the slime (regardless of previous size) + * will set the following attributes: + *
    -+ *
  • {@link org.bukkit.attribute.Attribute#GENERIC_MAX_HEALTH}
  • -+ *
  • {@link org.bukkit.attribute.Attribute#GENERIC_MOVEMENT_SPEED}
  • -+ *
  • {@link org.bukkit.attribute.Attribute#GENERIC_ATTACK_DAMAGE}
  • ++ *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • ++ *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • ++ *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • + *
+ * to their per-size defaults and heal the + * slime to its max health (assuming it's alive). diff --git a/patches/api/Improve-death-events.patch b/patches/api/Improve-death-events.patch index 34e847f6f..2a0ba2e83 100644 --- a/patches/api/Improve-death-events.patch +++ b/patches/api/Improve-death-events.patch @@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException Thrown if the health is {@literal <= 0 or >} max health + */ + public void setReviveHealth(double reviveHealth) throws IllegalArgumentException { -+ double maxHealth = ((LivingEntity) entity).getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue(); ++ double maxHealth = ((LivingEntity) entity).getAttribute(org.bukkit.attribute.Attribute.MAX_HEALTH).getValue(); + if ((maxHealth != 0 && reviveHealth <= 0) || (reviveHealth > maxHealth)) { + throw new IllegalArgumentException("Health must be between 0 (exclusive) and " + maxHealth + " (inclusive), but was " + reviveHealth); + } diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index cf26d8499..2dc3870b7 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -1331,7 +1331,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface UnsafeValues { @ApiStatus.Internal - B get(Registry registry, NamespacedKey key); + Biome getCustomBiome(); + + // Paper start + @Deprecated(forRemoval = true) diff --git a/patches/server/Add-FeatureFlag-API.patch b/patches/server/Add-FeatureFlag-API.patch index 13471b923..112b0a097 100644 --- a/patches/server/Add-FeatureFlag-API.patch +++ b/patches/server/Add-FeatureFlag-API.patch @@ -287,17 +287,17 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -0,0 +0,0 @@ import org.bukkit.advancement.Advancement; - import org.bukkit.attribute.Attribute; +@@ -0,0 +0,0 @@ import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; + import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.CraftFeatureFlag; +// import org.bukkit.craftbukkit.CraftFeatureFlag; // Paper import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; - import org.bukkit.craftbukkit.attribute.CraftAttribute; + import org.bukkit.craftbukkit.block.CraftBiome; @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - return CraftAttribute.bukkitToMinecraft(attribute).getDescriptionId(); + return attribute.getTranslationKey(); } - @Override diff --git a/patches/server/Add-NamespacedKey-biome-methods.patch b/patches/server/Add-NamespacedKey-biome-methods.patch index abefd86fd..b324c7aed 100644 --- a/patches/server/Add-NamespacedKey-biome-methods.patch +++ b/patches/server/Add-NamespacedKey-biome-methods.patch @@ -16,15 +16,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public org.bukkit.NamespacedKey getBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z) { -+ org.bukkit.craftbukkit.CraftRegionAccessor cra = (org.bukkit.craftbukkit.CraftRegionAccessor) accessor; -+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(cra.getHandle().registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME).getKey(cra.getHandle().getBiome(new net.minecraft.core.BlockPos(x, y, z)).value())); ++ return accessor.getBiome(x, y, z).getKey(); + } + + @Override + public void setBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z, org.bukkit.NamespacedKey biomeKey) { -+ org.bukkit.craftbukkit.CraftRegionAccessor cra = (org.bukkit.craftbukkit.CraftRegionAccessor) accessor; -+ net.minecraft.core.Holder biomeBase = cra.getHandle().registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME).getOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey))); -+ cra.setBiome(x, y, z, biomeBase); ++ accessor.setBiome(x, y, z, org.bukkit.Registry.BIOME.getOrThrow(biomeKey)); + } // Paper end diff --git a/patches/server/Add-RegistryAccess-for-managing-Registries.patch b/patches/server/Add-RegistryAccess-for-managing-Registries.patch index 05313f833..6f2900e64 100644 --- a/patches/server/Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/Add-RegistryAccess-for-managing-Registries.patch @@ -28,15 +28,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; ++import org.bukkit.Fluid; +import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; +import org.bukkit.Keyed; +import org.bukkit.MusicInstrument; ++import org.bukkit.attribute.Attribute; ++import org.bukkit.block.Biome; +import org.bukkit.block.BlockType; +import org.bukkit.block.banner.PatternType; ++import org.bukkit.craftbukkit.CraftFluid; +import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftJukeboxSong; +import org.bukkit.craftbukkit.CraftMusicInstrument; ++import org.bukkit.craftbukkit.attribute.CraftAttribute; ++import org.bukkit.craftbukkit.block.CraftBiome; +import org.bukkit.craftbukkit.block.CraftBlockType; +import org.bukkit.craftbukkit.block.banner.CraftPatternType; +import org.bukkit.craftbukkit.damage.CraftDamageType; @@ -98,6 +104,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entry(Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, Villager.Type.class, CraftVillager.CraftType::new), + entry(Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, CraftMapCursor.CraftType::new), + entry(Registries.MENU, RegistryKey.MENU, MenuType.class, CraftMenuType::new), ++ entry(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, Attribute.class, CraftAttribute::new), ++ entry(Registries.FLUID, RegistryKey.FLUID, Fluid.class, CraftFluid::new), + + // data-drivens + entry(Registries.STRUCTURE, RegistryKey.STRUCTURE, Structure.class, CraftStructure::new).delayed(), @@ -108,17 +116,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(), + entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(), + entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(), ++ entry(Registries.BIOME, RegistryKey.BIOME, Biome.class, CraftBiome::new).delayed(), + + // api-only -+ apiOnly(Registries.BIOME, RegistryKey.BIOME, () -> org.bukkit.Registry.BIOME), + apiOnly(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, () -> org.bukkit.Registry.ART), -+ apiOnly(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, () -> org.bukkit.Registry.ATTRIBUTE), + apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, () -> org.bukkit.Registry.ENTITY_TYPE), + apiOnly(Registries.PARTICLE_TYPE, RegistryKey.PARTICLE_TYPE, () -> org.bukkit.Registry.PARTICLE_TYPE), + apiOnly(Registries.POTION, RegistryKey.POTION, () -> org.bukkit.Registry.POTION), + apiOnly(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, () -> org.bukkit.Registry.SOUNDS), -+ apiOnly(Registries.MEMORY_MODULE_TYPE, RegistryKey.MEMORY_MODULE_TYPE, () -> (org.bukkit.Registry>) (org.bukkit.Registry) org.bukkit.Registry.MEMORY_MODULE_TYPE), -+ apiOnly(Registries.FLUID, RegistryKey.FLUID, () -> org.bukkit.Registry.FLUID) ++ apiOnly(Registries.MEMORY_MODULE_TYPE, RegistryKey.MEMORY_MODULE_TYPE, () -> (org.bukkit.Registry>) (org.bukkit.Registry) org.bukkit.Registry.MEMORY_MODULE_TYPE) + ); + final Map, RegistryEntry> byRegistryKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size()); + final Map, RegistryEntry> byResourceKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size()); @@ -758,9 +764,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - * @return the bukkit registry of the provided class - */ - public static Registry createRegistry(Class bukkitClass, RegistryAccess registryHolder) { +- if (bukkitClass == Attribute.class) { +- return new CraftRegistry<>(Attribute.class, registryHolder.lookupOrThrow(Registries.ATTRIBUTE), CraftAttribute::new, FieldRename.ATTRIBUTE_RENAME); +- } +- if (bukkitClass == Biome.class) { +- return new CraftRegistry<>(Biome.class, registryHolder.lookupOrThrow(Registries.BIOME), CraftBiome::new, FieldRename.BIOME_RENAME); +- } - if (bukkitClass == Enchantment.class) { - return new CraftRegistry<>(Enchantment.class, registryHolder.lookupOrThrow(Registries.ENCHANTMENT), CraftEnchantment::new, FieldRename.ENCHANTMENT_RENAME); - } +- if (bukkitClass == Fluid.class) { +- return new CraftRegistry<>(Fluid.class, registryHolder.lookupOrThrow(Registries.FLUID), CraftFluid::new, FieldRename.NONE); +- } - if (bukkitClass == GameEvent.class) { - return new CraftRegistry<>(GameEvent.class, registryHolder.lookupOrThrow(Registries.GAME_EVENT), CraftGameEvent::new, FieldRename.NONE); - } @@ -1260,7 +1275,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 static { - // Order: Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class +- register(Attribute.class, Registries.ATTRIBUTE, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); +- register(Biome.class, Registries.BIOME, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); - register(Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); +- register(Fluid.class, Registries.FLUID, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); - register(GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); - register(MusicInstrument.class, Registries.INSTRUMENT, CraftMusicInstrument.class, Instrument.class); - register(MenuType.class, Registries.MENU, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); @@ -1282,7 +1300,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - register(PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class); - + // Order: RegistryKey, Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class ++ register(RegistryKey.ATTRIBUTE, Attribute.class, Registries.ATTRIBUTE, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); ++ register(RegistryKey.BIOME, Biome.class, Registries.BIOME, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); + register(RegistryKey.ENCHANTMENT, Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); ++ register(RegistryKey.FLUID, Fluid.class, Registries.FLUID, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); + register(RegistryKey.GAME_EVENT, GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); + register(RegistryKey.INSTRUMENT, MusicInstrument.class, Registries.INSTRUMENT, CraftMusicInstrument.class, Instrument.class); + register(RegistryKey.MOB_EFFECT, PotionEffectType.class, Registries.MOB_EFFECT, CraftPotionEffectType.class, MobEffect.class); diff --git a/patches/server/Add-methods-to-get-translation-keys.patch b/patches/server/Add-methods-to-get-translation-keys.patch index 4cc6306cb..f29e4836e 100644 --- a/patches/server/Add-methods-to-get-translation-keys.patch +++ b/patches/server/Add-methods-to-get-translation-keys.patch @@ -10,6 +10,22 @@ public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/Fir Co-authored-by: MeFisto94 +diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java ++++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java +@@ -0,0 +0,0 @@ public class CraftAttribute implements Attribute, Handleable> entityTypes, boolean j - // CraftBukkit start - world.strikeLightning(entity1, (context.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT); - } else { -- world.addFreshEntityWithPassengers(user, CreatureSpawnEvent.SpawnReason.ENCHANTMENT); -+ world.addFreshEntityWithPassengers(entity1, CreatureSpawnEvent.SpawnReason.ENCHANTMENT); // Paper - Fix typo when adding summoned entity - // CraftBukkit end - } - diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java diff --git a/patches/server/Cache-resource-keys-and-optimize-reference-Holder-ta.patch b/patches/server/Cache-resource-keys-and-optimize-reference-Holder-ta.patch index 7feb0672f..35f04d82f 100644 --- a/patches/server/Cache-resource-keys-and-optimize-reference-Holder-ta.patch +++ b/patches/server/Cache-resource-keys-and-optimize-reference-Holder-ta.patch @@ -18,34 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java -@@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.block; - import com.google.common.base.Preconditions; - import net.minecraft.core.Holder; - import net.minecraft.core.registries.Registries; -+import net.minecraft.resources.ResourceKey; - import org.bukkit.Registry; - import org.bukkit.block.Biome; - import org.bukkit.craftbukkit.CraftRegistry; -@@ -0,0 +0,0 @@ public class CraftBiome { - return CraftBiome.minecraftToBukkit(minecraft.value()); - } - -+ private static final java.util.Map> BIOME_KEY_CACHE = java.util.Collections.synchronizedMap(new java.util.EnumMap<>(Biome.class)); // Paper - public static net.minecraft.world.level.biome.Biome bukkitToMinecraft(Biome bukkit) { - if (bukkit == null || bukkit == Biome.CUSTOM) { - return null; - } - - return CraftRegistry.getMinecraftRegistry(Registries.BIOME) -- .getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow(); -+ .getOptional(BIOME_KEY_CACHE.computeIfAbsent(bukkit, b -> ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(b.getKey())))).orElseThrow(); - } - - public static Holder bukkitToMinecraftHolder(Biome bukkit) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java diff --git a/patches/server/Expose-server-build-information.patch b/patches/server/Expose-server-build-information.patch index 478f0836c..fcea6472d 100644 --- a/patches/server/Expose-server-build-information.patch +++ b/patches/server/Expose-server-build-information.patch @@ -696,7 +696,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - return CraftRegistry.get(registry, namespacedKey, ApiVersion.CURRENT); + return this.customBiome; } + // Paper start diff --git a/patches/server/Fix-custom-statistic-criteria-creation.patch b/patches/server/Fix-custom-statistic-criteria-creation.patch index 840bf593c..ebd21f1b8 100644 --- a/patches/server/Fix-custom-statistic-criteria-creation.patch +++ b/patches/server/Fix-custom-statistic-criteria-creation.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - net.minecraft.core.Holder biomeBase = cra.getHandle().registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME).getOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey))); - cra.setBiome(x, y, z, biomeBase); + public void setBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z, org.bukkit.NamespacedKey biomeKey) { + accessor.setBiome(x, y, z, org.bukkit.Registry.BIOME.getOrThrow(biomeKey)); } + + @Override diff --git a/patches/server/Fixup-NamespacedKey-handling.patch b/patches/server/Fixup-NamespacedKey-handling.patch index 0786dc0c2..76e2ddd23 100644 --- a/patches/server/Fixup-NamespacedKey-handling.patch +++ b/patches/server/Fixup-NamespacedKey-handling.patch @@ -42,7 +42,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java -@@ -0,0 +0,0 @@ public class CraftAttribute { +@@ -0,0 +0,0 @@ public class CraftAttribute implements Attribute, Handleable attributable.registerAttribute(Attribute.GENERIC_ATTACK_DAMAGE)); -+ AttributeInstance instance = attributable.getAttribute(Attribute.GENERIC_FOLLOW_RANGE); ++ assertThrows(UnsupportedOperationException.class, () -> attributable.registerAttribute(Attribute.ATTACK_DAMAGE)); ++ AttributeInstance instance = attributable.getAttribute(Attribute.FOLLOW_RANGE); + assertNotNull(instance); + assertThrows(UnsupportedOperationException.class, () -> instance.addModifier(new AttributeModifier("test", 3, AttributeModifier.Operation.ADD_NUMBER))); + assertThrows(UnsupportedOperationException.class, () -> instance.setBaseValue(3.2)); diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 57a461299..beefb52fa 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -481,7 +481,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - helper methods for making death event cancellable + // Add information to death event + private static void populateFields(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) { -+ event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue()); ++ event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.MAX_HEALTH).getValue()); + event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent()); + net.minecraft.sounds.SoundEvent soundEffect = victim.getDeathSound(); + event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(soundEffect) : null); diff --git a/patches/server/Properly-track-the-changed-item-from-dispense-events.patch b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch index 7ff4ec03f..fbe3b65e4 100644 --- a/patches/server/Properly-track-the-changed-item-from-dispense-events.patch +++ b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch @@ -76,14 +76,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java @@ -0,0 +0,0 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { - } - } -- Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, stack, enumdirection), worldserver, stack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); -+ Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, CraftItemStack.unwrap(event.getItem()), enumdirection), worldserver, stack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // Paper - track changed items in the dispense event; unwrap is safe here because all uses of the stack make their own copies - ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); + // SPIGOT-7923: Avoid create projectiles with empty item + if (!itemstack1.isEmpty()) { +- Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack1, enumdirection), worldserver, itemstack1, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); ++ Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, CraftItemStack.unwrap(event.getItem()), enumdirection), worldserver, itemstack1, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // Paper - track changed items in the dispense event; unwrap is safe here because all uses of the stack make their own copies + iprojectile.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); + } // itemstack.shrink(1); // CraftBukkit - Handled during event processing - // CraftBukkit end diff --git a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java diff --git a/work/Bukkit b/work/Bukkit index 553558256..97c592614 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 553558256cab26217919a0809cc26f7aad22995d +Subproject commit 97c5926140420c7b9e8a06b2b8348b1816f2a6bd diff --git a/work/CraftBukkit b/work/CraftBukkit index 18b8ae183..7235ad7b0 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 18b8ae18390763d48ea292435b75c1eabf5dbff7 +Subproject commit 7235ad7b04542ce214869eb1ec1966bb392aedc7