From 98853ee5486c776d793cdfaf8bbec8f8d7f3f755 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Thu, 23 May 2024 10:32:02 -0700 Subject: [PATCH] [ci skip] Move logic in our patches to ItemType/BlockType (#10772) --- .../api/Add-NamespacedKey-biome-methods.patch | 7 +- ...Add-api-for-spawn-egg-texture-colors.patch | 4 +- ...Collision-methods-to-various-places.patch} | 56 ++++++++------- .../Add-methods-to-get-translation-keys.patch | 70 +++++++++++++++++-- .../Attributes-API-for-item-defaults.patch | 12 ++-- ...x-custom-statistic-criteria-creation.patch | 5 +- patches/api/Improve-Item-Rarity-API.patch | 12 ++-- .../Add-NamespacedKey-biome-methods.patch | 12 ++-- ...Collision-methods-to-various-places.patch} | 25 ++++--- .../Add-methods-to-get-translation-keys.patch | 32 +++++++++ ...x-custom-statistic-criteria-creation.patch | 12 ++-- patches/server/ItemStack-Tooltip-API.patch | 7 +- 12 files changed, 177 insertions(+), 77 deletions(-) rename patches/api/{Add-isCollidable-methods-to-various-places.patch => Add-hasCollision-methods-to-various-places.patch} (64%) rename patches/server/{Add-isCollidable-methods-to-various-places.patch => Add-hasCollision-methods-to-various-places.patch} (62%) diff --git a/patches/api/Add-NamespacedKey-biome-methods.patch b/patches/api/Add-NamespacedKey-biome-methods.patch index 6292ae252e..b03bd574c7 100644 --- a/patches/api/Add-NamespacedKey-biome-methods.patch +++ b/patches/api/Add-NamespacedKey-biome-methods.patch @@ -10,10 +10,11 @@ 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 { - * @throws IllegalArgumentException if {@link Material#isBlock()} is false */ - boolean isCollidable(@org.jetbrains.annotations.NotNull Material material); + @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); + // Paper end + ++ // Paper start - namespaced key biome methods + /** + * Gets the {@link NamespacedKey} for the biome at the given location. + * @@ -40,5 +41,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalStateException if no biome by the given key is registered. + */ + void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey); - // Paper end ++ // Paper end - namespaced key biome methods } diff --git a/patches/api/Add-api-for-spawn-egg-texture-colors.patch b/patches/api/Add-api-for-spawn-egg-texture-colors.patch index 57c9aca5cf..54659d3930 100644 --- a/patches/api/Add-api-for-spawn-egg-texture-colors.patch +++ b/patches/api/Add-api-for-spawn-egg-texture-colors.patch @@ -9,9 +9,9 @@ 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 { + // Paper end - namespaced key biome methods - String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); - // Paper end + String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); // Paper - fix custom stats criteria creation + + // Paper start - spawn egg color visibility + /** diff --git a/patches/api/Add-isCollidable-methods-to-various-places.patch b/patches/api/Add-hasCollision-methods-to-various-places.patch similarity index 64% rename from patches/api/Add-isCollidable-methods-to-various-places.patch rename to patches/api/Add-hasCollision-methods-to-various-places.patch index 54416c2773..7b3778f389 100644 --- a/patches/api/Add-isCollidable-methods-to-various-places.patch +++ b/patches/api/Add-hasCollision-methods-to-various-places.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Thu, 4 Nov 2021 11:50:35 -0700 -Subject: [PATCH] Add isCollidable methods to various places +Subject: [PATCH] Add hasCollision methods to various places diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java @@ -9,10 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla - public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) { - return this.getDefaultAttributeModifiers(equipmentSlot); } -+ + // Paper end - item default attributes API + ++ // Paper start - isCollidable API + /** + * Checks if this material is collidable. + * @@ -20,30 +20,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException if {@link #isBlock()} is false + */ + public boolean isCollidable() { -+ return Bukkit.getUnsafe().isCollidable(this); ++ if (this.isBlock()) { ++ return this.asBlockType().hasCollision(); ++ } ++ throw new IllegalArgumentException(this + " isn't a block type"); + } - // Paper end - - /** -diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/UnsafeValues.java -+++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -0,0 +0,0 @@ public interface UnsafeValues { - * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first) - */ - @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); ++ // Paper end - isCollidable API + -+ /** -+ * Checks if this material is collidable. -+ * -+ * @param material the material to check -+ * @return true if collidable -+ * @throws IllegalArgumentException if {@link Material#isBlock()} is false -+ */ -+ boolean isCollidable(@org.jetbrains.annotations.NotNull Material material); - // Paper end - } + /** + * Do not use for any reason. + * diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Block.java @@ -80,3 +66,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean isCollidable(); + // Paper end } +diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/BlockType.java ++++ b/src/main/java/org/bukkit/block/BlockType.java +@@ -0,0 +0,0 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran + @Override + @NotNull String getTranslationKey(); + // Paper end - add Translatable ++ ++ // Paper start - hasCollision API ++ /** ++ * Checks if this block type has collision. ++ * <p> ++ * @return false if this block never has collision, true if it <b>might</b> have collision ++ */ ++ boolean hasCollision(); ++ // Paper end - hasCollision API + } diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch index 89bc88a36c..2035f9feb4 100644 --- a/patches/api/Add-methods-to-get-translation-keys.patch +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -157,21 +157,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 AIR(9648, 0), STONE(22948), @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable { - } - return false; } -+ + // Paper end + ++ // Paper start - add Translatable + @Override + public @NotNull String translationKey() { + if (this.isItem()) { -+ return Bukkit.getUnsafe().getItemTranslationKey(this); ++ return java.util.Objects.requireNonNull(this.asItemType()).translationKey(); + } else { -+ return Bukkit.getUnsafe().getBlockTranslationKey(this); ++ return java.util.Objects.requireNonNull(this.asBlockType()).translationKey(); + } + } - // Paper end - ++ // Paper end - add Translatable ++ /** + * Do not use for any reason. + * @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable { * material * @see #getBlockTranslationKey() @@ -309,6 +311,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + String getTranslationKey(); // Paper end } +diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/BlockType.java ++++ b/src/main/java/org/bukkit/block/BlockType.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * changes may occur. Do not use this API in plugins. + */ + @ApiStatus.Internal +-public interface BlockType extends Keyed, Translatable { ++public interface BlockType extends Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - add translatable + + /** + * Typed represents a subtype of {@link BlockType}s that have a known block +@@ -0,0 +0,0 @@ public interface BlockType extends Keyed, Translatable { + @Nullable + @Deprecated + Material asMaterial(); ++ ++ // Paper start - add Translatable ++ /** ++ * @deprecated use {@link #translationKey()} and {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)} ++ */ ++ @Deprecated(forRemoval = true) ++ @Override ++ @NotNull String getTranslationKey(); ++ // Paper end - add Translatable + } diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -517,3 +546,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper end } +diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ItemType.java ++++ b/src/main/java/org/bukkit/inventory/ItemType.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * changes may occur. Do not use this API in plugins. + */ + @ApiStatus.Internal +-public interface ItemType extends Keyed, Translatable { ++public interface ItemType extends Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - add Translatable + + /** + * Typed represents a subtype of {@link ItemType}s that have a known item meta type +@@ -0,0 +0,0 @@ public interface ItemType extends Keyed, Translatable { + @Nullable + @Deprecated + Material asMaterial(); ++ ++ // Paper start - add Translatable ++ /** ++ * @deprecated use {@link #translationKey()} and {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)} ++ */ ++ @Deprecated(forRemoval = true) ++ @Override ++ @NotNull String getTranslationKey(); ++ // Paper end - add Translatable + } diff --git a/patches/api/Attributes-API-for-item-defaults.patch b/patches/api/Attributes-API-for-item-defaults.patch index db14ecbee2..af19eb5dcf 100644 --- a/patches/api/Attributes-API-for-item-defaults.patch +++ b/patches/api/Attributes-API-for-item-defaults.patch @@ -10,10 +10,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla - public io.papermc.paper.inventory.ItemRarity getItemRarity() { - return new org.bukkit.inventory.ItemStack(this).getRarity(); } -+ + // Paper end - item rarity API + ++ // Paper start - item default attributes API + /** + * Returns an immutable multimap of attributes for the slot. + * {@link #isItem()} must be true for this material. @@ -28,6 +28,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) { + return this.getDefaultAttributeModifiers(equipmentSlot); + } - // Paper end - ++ // Paper end - item default attributes API ++ /** + * Do not use for any reason. + * diff --git a/patches/api/Fix-custom-statistic-criteria-creation.patch b/patches/api/Fix-custom-statistic-criteria-creation.patch index d521c32cfa..7d4a07dff5 100644 --- a/patches/api/Fix-custom-statistic-criteria-creation.patch +++ b/patches/api/Fix-custom-statistic-criteria-creation.patch @@ -9,12 +9,11 @@ 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 { - * @throws IllegalStateException if no biome by the given key is registered. */ void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey); + // Paper end - namespaced key biome methods + -+ String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); - // Paper end ++ String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); // Paper - fix custom stats criteria creation } diff --git a/src/main/java/org/bukkit/scoreboard/Criteria.java b/src/main/java/org/bukkit/scoreboard/Criteria.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/api/Improve-Item-Rarity-API.patch b/patches/api/Improve-Item-Rarity-API.patch index c597412161..10708a5de3 100644 --- a/patches/api/Improve-Item-Rarity-API.patch +++ b/patches/api/Improve-Item-Rarity-API.patch @@ -47,10 +47,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla - return Bukkit.getUnsafe().getBlockTranslationKey(this); - } } -+ + // Paper end - add Translatable + ++ // Paper start - item rarity API + /** + * Returns the item rarity for the item. The Material <b>MUST</b> be an Item not a block. + * Use {@link #isItem()} before this. @@ -63,9 +63,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public io.papermc.paper.inventory.ItemRarity getItemRarity() { + return new org.bukkit.inventory.ItemStack(this).getRarity(); + } - // Paper end - ++ // Paper end - item rarity API ++ /** + * Do not use for any reason. + * diff --git a/src/main/java/org/bukkit/inventory/ItemRarity.java b/src/main/java/org/bukkit/inventory/ItemRarity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemRarity.java diff --git a/patches/server/Add-NamespacedKey-biome-methods.patch b/patches/server/Add-NamespacedKey-biome-methods.patch index eefb61dc8a..50b183f5a8 100644 --- a/patches/server/Add-NamespacedKey-biome-methods.patch +++ b/patches/server/Add-NamespacedKey-biome-methods.patch @@ -10,10 +10,10 @@ 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 { - Preconditions.checkArgument(material.isBlock(), material + " is not a block"); - return getBlock(material).hasCollision; } -+ + // Paper end + ++ // Paper start - namespaced key biome methods + @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; @@ -26,6 +26,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeBase = cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey))); + cra.setBiome(x, y, z, biomeBase); + } - // Paper end - ++ // Paper end - namespaced key biome methods ++ @Override + public String get(Class<?> aClass, String s) { + if (aClass == Enchantment.class) { diff --git a/patches/server/Add-isCollidable-methods-to-various-places.patch b/patches/server/Add-hasCollision-methods-to-various-places.patch similarity index 62% rename from patches/server/Add-isCollidable-methods-to-various-places.patch rename to patches/server/Add-hasCollision-methods-to-various-places.patch index fcca7d6d87..5004315aa2 100644 --- a/patches/server/Add-isCollidable-methods-to-various-places.patch +++ b/patches/server/Add-hasCollision-methods-to-various-places.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Thu, 4 Nov 2021 11:50:40 -0700 -Subject: [PATCH] Add isCollidable methods to various places +Subject: [PATCH] Add hasCollision methods to various places == AT == public net.minecraft.world.level.block.state.BlockBehaviour hasCollision @@ -38,20 +38,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java 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 @@ public final class CraftMagicNumbers implements UnsafeValues { - var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey))); - return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier); +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java +@@ -0,0 +0,0 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>, + return this.block.getDescriptionId(); } + // Paper end - add Translatable + ++ // Paper start - hasCollision API + @Override -+ public boolean isCollidable(Material material) { -+ Preconditions.checkArgument(material.isBlock(), material + " is not a block"); -+ return getBlock(material).hasCollision; ++ public boolean hasCollision() { ++ return this.block.hasCollision; + } - // Paper end - - @Override ++ // Paper end - hasCollision API + } diff --git a/patches/server/Add-methods-to-get-translation-keys.patch b/patches/server/Add-methods-to-get-translation-keys.patch index abe2590391..47b91c03cf 100644 --- a/patches/server/Add-methods-to-get-translation-keys.patch +++ b/patches/server/Add-methods-to-get-translation-keys.patch @@ -25,6 +25,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper end } +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java +@@ -0,0 +0,0 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>, + public Material asMaterial() { + return Registry.MATERIAL.get(this.key); + } ++ ++ // Paper start - add Translatable ++ @Override ++ public String translationKey() { ++ return this.block.getDescriptionId(); ++ } ++ // Paper end - add Translatable + } diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -41,6 +57,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java +@@ -0,0 +0,0 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han + public Material asMaterial() { + return Registry.MATERIAL.get(this.key); + } ++ ++ // Paper start - add Translatable ++ @Override ++ public String translationKey() { ++ return this.item.getDescriptionId(); ++ } ++ // Paper end - add Translatable + } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java diff --git a/patches/server/Fix-custom-statistic-criteria-creation.patch b/patches/server/Fix-custom-statistic-criteria-creation.patch index 50b78df47e..523bc264e6 100644 --- a/patches/server/Fix-custom-statistic-criteria-creation.patch +++ b/patches/server/Fix-custom-statistic-criteria-creation.patch @@ -9,15 +9,17 @@ 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<net.minecraft.world.level.biome.Biome> biomeBase = cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey))); - cra.setBiome(x, y, z, biomeBase); } -+ + // Paper end - namespaced key biome methods + ++ // Paper start - fix custom stats criteria creation + @Override + public String getStatisticCriteriaKey(org.bukkit.Statistic statistic) { + if (statistic.getType() != org.bukkit.Statistic.Type.UNTYPED) return "minecraft.custom:minecraft." + statistic.getKey().getKey(); + return org.bukkit.craftbukkit.CraftStatistic.getNMSStatistic(statistic).getName(); + } - // Paper end - ++ // Paper end - fix custom stats criteria creation ++ @Override + public String get(Class<?> aClass, String s) { + if (aClass == Enchantment.class) { diff --git a/patches/server/ItemStack-Tooltip-API.patch b/patches/server/ItemStack-Tooltip-API.patch index f7b32a0299..59cb40649f 100644 --- a/patches/server/ItemStack-Tooltip-API.patch +++ b/patches/server/ItemStack-Tooltip-API.patch @@ -9,9 +9,9 @@ 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 org.bukkit.craftbukkit.CraftStatistic.getNMSStatistic(statistic).getName(); } - // Paper end + // Paper end - fix custom stats criteria creation + + // Paper start - expose itemstack tooltip lines + @Override + public java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(final ItemStack itemStack, final io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.Player player) { @@ -26,6 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList(); + } + // Paper end - expose itemstack tooltip lines - ++ @Override public String get(Class<?> aClass, String s) { + if (aClass == Enchantment.class) {