diff options
author | Owen1212055 <[email protected]> | 2024-08-09 23:28:11 -0400 |
---|---|---|
committer | Owen1212055 <[email protected]> | 2024-11-18 14:50:38 -0500 |
commit | 389d948efb1e56fb7b145c28aed3140a67210556 (patch) | |
tree | 354603a40428db31590cd37935de1be8095b22e9 | |
parent | 2070844f8db410c151c1c1d5dec5d5057eb1b8f7 (diff) | |
download | Paper-389d948efb1e56fb7b145c28aed3140a67210556.tar.gz Paper-389d948efb1e56fb7b145c28aed3140a67210556.zip |
Add ItemStack#matchesWithoutData, Remove most singletons, implement suggestions, fix tests
-rw-r--r-- | patches/api/0482-WIP-DataComponent-API.patch (renamed from patches/api/0480-WIP-DataComponent-API.patch) | 494 | ||||
-rw-r--r-- | patches/server/1044-WIP-DataComponent-API.patch (renamed from patches/server/1026-WIP-DataComponent-API.patch) | 455 |
2 files changed, 449 insertions, 500 deletions
diff --git a/patches/api/0480-WIP-DataComponent-API.patch b/patches/api/0482-WIP-DataComponent-API.patch index 7c691c939b..62c5423e6f 100644 --- a/patches/api/0480-WIP-DataComponent-API.patch +++ b/patches/api/0482-WIP-DataComponent-API.patch @@ -64,12 +64,12 @@ index 0000000000000000000000000000000000000000..3e4feb334ba3e2b5895b2db4dc294083 + @NotNull BlockPredicate build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/ComponentBuilder.java b/src/main/java/io/papermc/paper/datacomponent/ComponentBuilder.java +diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java new file mode 100644 -index 0000000000000000000000000000000000000000..6eb69eb0f220a3a5e63d8315802b4966dceda839 +index 0000000000000000000000000000000000000000..e56c3b74bc22c382e7cf987e95c2f8e6bbe5611b --- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/ComponentBuilder.java -@@ -0,0 +1,22 @@ ++++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentBuilder.java +@@ -0,0 +1,23 @@ +package io.papermc.paper.datacomponent; + +import org.checkerframework.checker.nullness.qual.NonNull; @@ -81,8 +81,9 @@ index 0000000000000000000000000000000000000000..6eb69eb0f220a3a5e63d8315802b4966 + * + * @param <C> built component type + */ -+public interface ComponentBuilder<C> { ++public interface DataComponentBuilder<C> { + + /** + * Builds the immutable component value. @@ -94,15 +95,16 @@ index 0000000000000000000000000000000000000000..6eb69eb0f220a3a5e63d8315802b4966 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java new file mode 100644 -index 0000000000000000000000000000000000000000..798bbc5cd4ba5c04d4952ac5ec8815918d1ce9fd +index 0000000000000000000000000000000000000000..3a0bca9f95d6f1ad2e160620bb47f7023cb40e3d --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentType.java -@@ -0,0 +1,27 @@ +@@ -0,0 +1,28 @@ +package io.papermc.paper.datacomponent; + +import org.bukkit.Keyed; +import org.jetbrains.annotations.ApiStatus; + +public interface DataComponentType extends Keyed { + @@ -127,17 +129,16 @@ index 0000000000000000000000000000000000000000..798bbc5cd4ba5c04d4952ac5ec881591 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java new file mode 100644 -index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fade4ffe889 +index 0000000000000000000000000000000000000000..c3f53e5afe92c39dfce7075153d419f1b03020ac --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java -@@ -0,0 +1,322 @@ +@@ -0,0 +1,321 @@ +package io.papermc.paper.datacomponent; + +import io.papermc.paper.datacomponent.item.BannerPatternLayers; +import io.papermc.paper.datacomponent.item.BlockItemDataProperties; +import io.papermc.paper.datacomponent.item.BundleContents; +import io.papermc.paper.datacomponent.item.ChargedProjectiles; -+import io.papermc.paper.datacomponent.item.CustomModelData; +import io.papermc.paper.datacomponent.item.DyedItemColor; +import io.papermc.paper.datacomponent.item.Fireworks; +import io.papermc.paper.datacomponent.item.FoodProperties; @@ -148,10 +149,8 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad +import io.papermc.paper.datacomponent.item.ItemEnchantments; +import io.papermc.paper.datacomponent.item.ItemLore; +import io.papermc.paper.datacomponent.item.JukeboxPlayable; -+import io.papermc.paper.datacomponent.item.LockCode; +import io.papermc.paper.datacomponent.item.LodestoneTracker; +import io.papermc.paper.datacomponent.item.MapDecorations; -+import io.papermc.paper.datacomponent.item.MapId; +import io.papermc.paper.datacomponent.item.MapItemColor; +import io.papermc.paper.item.MapPostProcessing; +import io.papermc.paper.datacomponent.item.PotDecorations; @@ -175,6 +174,7 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.index.qual.Positive; +import org.checkerframework.common.value.qual.IntRange; ++import org.jetbrains.annotations.ApiStatus; + +import static java.util.Objects.requireNonNull; + @@ -182,6 +182,7 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad + * All the different types of data that {@link org.bukkit.inventory.ItemStack ItemStacks} + * and {@link org.bukkit.inventory.ItemType ItemTypes} can have. + */ +public final class DataComponentTypes { + + // public static final DataComponentType.Valued<BinaryTagHolder> CUSTOM_DATA = valued("custom_data"); @@ -264,7 +265,7 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad + /** + * Controls the minecraft:custom_model_data property in the item model. + */ -+ public static final DataComponentType.Valued<CustomModelData> CUSTOM_MODEL_DATA = valued("custom_model_data"); ++ public static final DataComponentType.Valued<Integer> CUSTOM_MODEL_DATA = valued("custom_model_data"); + /** + * If set, disables 'additional' tooltip part which comes from the item type + * (e.g. content of a shulker). @@ -330,7 +331,7 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad + /** + * References the shared map state holding map contents and markers for a Filled Map. + */ -+ public static final DataComponentType.Valued<MapId> MAP_ID = valued("map_id"); ++ public static final DataComponentType.Valued<Integer> MAP_ID = valued("map_id"); + /** + * Holds a list of markers to be placed on a Filled Map (used for Explorer Maps). + */ @@ -435,7 +436,7 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad + * An item with a custom name of the same value must be used + * to open this container. + */ -+ public static final DataComponentType.Valued<LockCode> LOCK = valued("lock"); ++ public static final DataComponentType.Valued<String> LOCK = valued("lock"); + /** + * Holds the unresolved loot table and seed of a container-like block. + */ @@ -455,13 +456,13 @@ index 0000000000000000000000000000000000000000..9f4e76e44ed34c57132494cad46b2fad +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java new file mode 100644 -index 0000000000000000000000000000000000000000..c628b5aed20c4d8781e0ad19fdbc4a926fcfc0fa +index 0000000000000000000000000000000000000000..aed2b74e5c88c5afe9b51ff0952b1adc5c230283 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java -@@ -0,0 +1,42 @@ +@@ -0,0 +1,44 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Arrays; +import java.util.List; +import org.bukkit.block.banner.Pattern; @@ -470,6 +471,7 @@ index 0000000000000000000000000000000000000000..c628b5aed20c4d8781e0ad19fdbc4a92 +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +public interface BannerPatternLayers { + @@ -491,8 +493,9 @@ index 0000000000000000000000000000000000000000..c628b5aed20c4d8781e0ad19fdbc4a92 + @Contract(pure = true) + @NonNull @Unmodifiable List<Pattern> patterns(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<BannerPatternLayers> { ++ interface Builder extends DataComponentBuilder<BannerPatternLayers> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder add(@NonNull Pattern pattern); @@ -503,19 +506,21 @@ index 0000000000000000000000000000000000000000..c628b5aed20c4d8781e0ad19fdbc4a92 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java new file mode 100644 -index 0000000000000000000000000000000000000000..270f98e95b1d0322a42bad52d492fa0018f43bc1 +index 0000000000000000000000000000000000000000..d658f4b06abe507bea705525fa4b17da018c46b8 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/BlockItemDataProperties.java -@@ -0,0 +1,28 @@ +@@ -0,0 +1,31 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.Material; ++import org.bukkit.block.BlockType; +import org.bukkit.block.data.BlockData; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +public interface BlockItemDataProperties { + @@ -525,25 +530,26 @@ index 0000000000000000000000000000000000000000..270f98e95b1d0322a42bad52d492fa00 + } + + @Contract(pure = true) -+ @NonNull BlockData createBlockData(@NonNull Material blockType); ++ @NonNull BlockData createBlockData(@NonNull BlockType blockType); + + @Contract(pure = true) + @NonNull BlockData applyToBlockData(@NonNull BlockData blockData); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<BlockItemDataProperties> { ++ interface Builder extends DataComponentBuilder<BlockItemDataProperties> { + // building this requires BlockProperty API, so an empty builder for now (essentially read-only) + } +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..d5b1718ae01d6ea73f75446240d169ba9f0d7778 +index 0000000000000000000000000000000000000000..7eba2596f12b369e8a8ad96b78198f1f92f0392a --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java -@@ -0,0 +1,62 @@ +@@ -0,0 +1,64 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Arrays; +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -555,6 +561,7 @@ index 0000000000000000000000000000000000000000..d5b1718ae01d6ea73f75446240d169ba +/** + * Holds all items stored inside of a Bundle. + */ +public interface BundleContents { + @@ -581,8 +588,9 @@ index 0000000000000000000000000000000000000000..d5b1718ae01d6ea73f75446240d169ba + @Contract(value = "-> new", pure = true) + @NonNull @Unmodifiable List<@NonNull ItemStack> contents(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<BundleContents> { ++ interface Builder extends DataComponentBuilder<BundleContents> { + + /** + * Adds an item to this builder. @@ -605,13 +613,13 @@ index 0000000000000000000000000000000000000000..d5b1718ae01d6ea73f75446240d169ba +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java new file mode 100644 -index 0000000000000000000000000000000000000000..b8eea6dd890bfed0462cffb0aac48ee8010636f1 +index 0000000000000000000000000000000000000000..dd34facf9f9ea1d674f65ff2e5f56386c346fd62 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java -@@ -0,0 +1,62 @@ +@@ -0,0 +1,64 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Arrays; +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -623,6 +631,7 @@ index 0000000000000000000000000000000000000000..b8eea6dd890bfed0462cffb0aac48ee8 +/** + * Holds all projectiles that have been loaded into a Crossbow. + */ +public interface ChargedProjectiles { + @@ -649,8 +658,9 @@ index 0000000000000000000000000000000000000000..b8eea6dd890bfed0462cffb0aac48ee8 + @Contract(value = "-> new", pure = true) + @NonNull @Unmodifiable List<@NonNull ItemStack> projectiles(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<ChargedProjectiles> { ++ interface Builder extends DataComponentBuilder<ChargedProjectiles> { + + /** + * Adds a projectile to be loaded in this builder. @@ -673,10 +683,10 @@ index 0000000000000000000000000000000000000000..b8eea6dd890bfed0462cffb0aac48ee8 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java new file mode 100644 -index 0000000000000000000000000000000000000000..7412a4259140707fbf7545f7c8a3da0ba76bab66 +index 0000000000000000000000000000000000000000..d061ed57d046f9e42b116e55e392a1a9ecc9d655 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridge.java -@@ -0,0 +1,92 @@ +@@ -0,0 +1,87 @@ +package io.papermc.paper.datacomponent.item; + +import com.destroystokyo.paper.profile.PlayerProfile; @@ -725,13 +735,10 @@ index 0000000000000000000000000000000000000000..7412a4259140707fbf7545f7c8a3da0b + + BundleContents.Builder bundleContents(); + -+ CustomModelData.Builder customModelData(); -+ + SuspiciousStewEffects.Builder suspiciousStewEffects(); + + MapItemColor.Builder mapItemColor(); + -+ MapId.Builder mapId(); + + MapDecorations.Builder mapDecorations(); + @@ -757,8 +764,6 @@ index 0000000000000000000000000000000000000000..7412a4259140707fbf7545f7c8a3da0b + + BlockItemDataProperties.Builder blockItemStateProperties(); + -+ LockCode.Builder lockCode(); -+ + ItemContainerContents.Builder itemContainerContents(); + + JukeboxPlayable.Builder jukeboxPlayable(JukeboxSong song); @@ -769,46 +774,15 @@ index 0000000000000000000000000000000000000000..7412a4259140707fbf7545f7c8a3da0b + + ItemAdventurePredicate.Builder itemAdventurePredicate(); +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java -new file mode 100644 -index 0000000000000000000000000000000000000000..fec24c86091ddd752ea8449de2da97c4889fdd76 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java -@@ -0,0 +1,25 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import io.papermc.paper.datacomponent.ComponentBuilder; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.Contract; -+ -+public interface CustomModelData { -+ -+ @Contract(value = "-> new", pure = true) -+ static CustomModelData.@NonNull Builder customModelData() { -+ return ComponentTypesBridge.bridge().customModelData(); -+ } -+ -+ @Contract(pure = true) -+ int data(); -+ -+ @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<CustomModelData> { -+ -+ @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder data(int data); -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..93f419b8e4d9c87b3ad4fa570d3bfad484deec2c +index 0000000000000000000000000000000000000000..79e22b97608119b51194622589198070ffeb8993 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java -@@ -0,0 +1,45 @@ +@@ -0,0 +1,47 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.Color; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -817,6 +791,7 @@ index 0000000000000000000000000000000000000000..93f419b8e4d9c87b3ad4fa570d3bfad4 +/** + * Represents a color applied to a dyeable item. + */ +public interface DyedItemColor extends ShownInTooltip<DyedItemColor> { + @@ -838,8 +813,9 @@ index 0000000000000000000000000000000000000000..93f419b8e4d9c87b3ad4fa570d3bfad4 + @Contract(value = "-> new", pure = true) + @NonNull Color color(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<DyedItemColor> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<DyedItemColor> { + + /** + * Sets the color of this builder. @@ -853,13 +829,13 @@ index 0000000000000000000000000000000000000000..93f419b8e4d9c87b3ad4fa570d3bfad4 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java b/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java new file mode 100644 -index 0000000000000000000000000000000000000000..feebbbb24190f70ef211aacdc659864a8e805060 +index 0000000000000000000000000000000000000000..d8974a1f984a300cfb9b2356f7f0dbf5ce6e9125 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/Fireworks.java -@@ -0,0 +1,74 @@ +@@ -0,0 +1,76 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.List; +import org.bukkit.FireworkEffect; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -871,6 +847,7 @@ index 0000000000000000000000000000000000000000..feebbbb24190f70ef211aacdc659864a +/** + * Stores all explosions crafted into a Firework Rocket, as well as flight duration. + */ +public interface Fireworks { + @@ -900,8 +877,9 @@ index 0000000000000000000000000000000000000000..feebbbb24190f70ef211aacdc659864a + @Contract(pure = true) + @IntRange(from = 0, to = 255) int flightDuration(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<Fireworks> { ++ interface Builder extends DataComponentBuilder<Fireworks> { + + /** + * Sets the number of gunpowder used in this builder. @@ -933,13 +911,13 @@ index 0000000000000000000000000000000000000000..feebbbb24190f70ef211aacdc659864a +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java new file mode 100644 -index 0000000000000000000000000000000000000000..a3efb2ba81889a0df0a383cd0a17567bef161984 +index 0000000000000000000000000000000000000000..356591941d4c945bba0c510682b7805add52ded4 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java -@@ -0,0 +1,114 @@ +@@ -0,0 +1,116 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Collection; +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -951,6 +929,7 @@ index 0000000000000000000000000000000000000000..a3efb2ba81889a0df0a383cd0a17567b +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +public interface FoodProperties { + @@ -1026,8 +1005,9 @@ index 0000000000000000000000000000000000000000..a3efb2ba81889a0df0a383cd0a17567b + float probability(); + } + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<FoodProperties> { ++ interface Builder extends DataComponentBuilder<FoodProperties> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder canAlwaysEat(boolean canAlwaysEat); @@ -1053,14 +1033,14 @@ index 0000000000000000000000000000000000000000..a3efb2ba81889a0df0a383cd0a17567b +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java new file mode 100644 -index 0000000000000000000000000000000000000000..000b681492032047287a8a412142268d29e63f3a +index 0000000000000000000000000000000000000000..3ae320efec03ebb69bffd70a851c5e9f97002d02 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java -@@ -0,0 +1,42 @@ +@@ -0,0 +1,44 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.block.BlockPredicate; -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.List; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -1070,6 +1050,7 @@ index 0000000000000000000000000000000000000000..000b681492032047287a8a412142268d +/** + * Controls which blocks a player in Adventure mode can do a certain action with this item. + */ +public interface ItemAdventurePredicate extends ShownInTooltip<ItemAdventurePredicate> { + @@ -1086,8 +1067,9 @@ index 0000000000000000000000000000000000000000..000b681492032047287a8a412142268d + @Contract(pure = true) + @NonNull @Unmodifiable List<@NonNull BlockPredicate> predicates(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<ItemAdventurePredicate> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAdventurePredicate> { + /** + * Adds a block predicate to this builder. + * @@ -1101,13 +1083,13 @@ index 0000000000000000000000000000000000000000..000b681492032047287a8a412142268d +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java new file mode 100644 -index 0000000000000000000000000000000000000000..e874f024a6a5493aad08db4a94dbfa58af78cfd4 +index 0000000000000000000000000000000000000000..0ec21a541f9a817ffe23ecab5cf968f245a50ea4 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java -@@ -0,0 +1,45 @@ +@@ -0,0 +1,46 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.inventory.meta.trim.ArmorTrim; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -1137,8 +1119,9 @@ index 0000000000000000000000000000000000000000..e874f024a6a5493aad08db4a94dbfa58 + @Contract(pure = true) + @NonNull ArmorTrim armorTrim(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<ItemArmorTrim> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemArmorTrim> { + + /** + * Sets the armor trim for this builder. @@ -1152,13 +1135,13 @@ index 0000000000000000000000000000000000000000..e874f024a6a5493aad08db4a94dbfa58 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java new file mode 100644 -index 0000000000000000000000000000000000000000..633e9ea540cfff0bd270dc4ec4291ce930c40612 +index 0000000000000000000000000000000000000000..4bad7a6226dc8d3dc9301084f35945b771da2279 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java -@@ -0,0 +1,57 @@ +@@ -0,0 +1,58 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.List; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; @@ -1199,8 +1182,9 @@ index 0000000000000000000000000000000000000000..633e9ea540cfff0bd270dc4ec4291ce9 + @NonNull AttributeModifier modifier(); + } + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<ItemAttributeModifiers> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAttributeModifiers> { + + /** + * Adds a modifier to this builder. @@ -1215,13 +1199,13 @@ index 0000000000000000000000000000000000000000..633e9ea540cfff0bd270dc4ec4291ce9 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..72426d41b62e88e512d73e17912a3046e4ad0682 +index 0000000000000000000000000000000000000000..edbb7c23ca82465069d50f82b45910cea8b9abaf --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java -@@ -0,0 +1,42 @@ +@@ -0,0 +1,44 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Arrays; +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -1230,6 +1214,7 @@ index 0000000000000000000000000000000000000000..72426d41b62e88e512d73e17912a3046 +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +public interface ItemContainerContents { + @@ -1251,8 +1236,9 @@ index 0000000000000000000000000000000000000000..72426d41b62e88e512d73e17912a3046 + @Contract(value = "-> new", pure = true) + @NonNull @Unmodifiable List<@NonNull ItemStack> contents(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<ItemContainerContents> { ++ interface Builder extends DataComponentBuilder<ItemContainerContents> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder add(@NonNull ItemStack stack); @@ -1263,13 +1249,13 @@ index 0000000000000000000000000000000000000000..72426d41b62e88e512d73e17912a3046 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java new file mode 100644 -index 0000000000000000000000000000000000000000..68ebd664bb9d78bb865b1ff9e6c2b5a1c03bbcf7 +index 0000000000000000000000000000000000000000..b547927dd2093ade5d598d6aa1856d10c439ec34 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java -@@ -0,0 +1,58 @@ +@@ -0,0 +1,60 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Map; +import org.bukkit.enchantments.Enchantment; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -1281,6 +1267,7 @@ index 0000000000000000000000000000000000000000..68ebd664bb9d78bb865b1ff9e6c2b5a1 +/** + * Stores a list of enchantments and their levels on an item. + */ +public interface ItemEnchantments extends ShownInTooltip<ItemEnchantments> { + @@ -1302,8 +1289,9 @@ index 0000000000000000000000000000000000000000..68ebd664bb9d78bb865b1ff9e6c2b5a1 + @Contract(pure = true) + @NonNull @Unmodifiable Map<@NonNull Enchantment, @NonNull @IntRange(from = 0, to = 255) Integer> enchantments(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<ItemEnchantments> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemEnchantments> { + + /** + * Adds an enchantment with the given level to this component. @@ -1327,13 +1315,13 @@ index 0000000000000000000000000000000000000000..68ebd664bb9d78bb865b1ff9e6c2b5a1 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java new file mode 100644 -index 0000000000000000000000000000000000000000..e1689b544c031a94db9d10e1bba7a7052dae5a40 +index 0000000000000000000000000000000000000000..2ca8673bb89c58f76d6ed2e38d6bcf7cc65765e8 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemLore.java -@@ -0,0 +1,74 @@ +@@ -0,0 +1,76 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.List; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.ComponentLike; @@ -1345,6 +1333,7 @@ index 0000000000000000000000000000000000000000..e1689b544c031a94db9d10e1bba7a705 +/** + * Additional lines to include in an item's tooltip. + */ +public interface ItemLore { + @@ -1374,8 +1363,9 @@ index 0000000000000000000000000000000000000000..e1689b544c031a94db9d10e1bba7a705 + @Contract(pure = true) + @NonNull @Unmodifiable List<@NonNull Component> styledLines(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<ItemLore> { ++ interface Builder extends DataComponentBuilder<ItemLore> { + + /** + * Sets the components of this lore. @@ -1407,18 +1397,19 @@ index 0000000000000000000000000000000000000000..e1689b544c031a94db9d10e1bba7a705 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java b/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java new file mode 100644 -index 0000000000000000000000000000000000000000..1d2276a6522044f06713db5ab8495d8aad863faf +index 0000000000000000000000000000000000000000..5beb84a0c5c2275e721cab21483e29c366e20b32 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java -@@ -0,0 +1,26 @@ +@@ -0,0 +1,28 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.JukeboxSong; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +public interface JukeboxPlayable extends ShownInTooltip<JukeboxPlayable> { + @@ -1430,53 +1421,23 @@ index 0000000000000000000000000000000000000000..1d2276a6522044f06713db5ab8495d8a + @Contract(pure = true) + @NonNull JukeboxSong jukeboxSong(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<JukeboxPlayable.Builder>, ComponentBuilder<JukeboxPlayable> { ++ interface Builder extends ShownInTooltip.Builder<JukeboxPlayable.Builder>, DataComponentBuilder<JukeboxPlayable> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder jukeboxSong(@NonNull JukeboxSong song); + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/LockCode.java b/src/main/java/io/papermc/paper/datacomponent/item/LockCode.java -new file mode 100644 -index 0000000000000000000000000000000000000000..6e7e05811a3e325757a7e44b2d6180c882ebb421 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/LockCode.java -@@ -0,0 +1,25 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import io.papermc.paper.datacomponent.ComponentBuilder; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.Contract; -+ -+public interface LockCode { -+ -+ @Contract(value = "-> new", pure = true) -+ static LockCode.@NonNull Builder lockCode() { -+ return ComponentTypesBridge.bridge().lockCode(); -+ } -+ -+ @Contract(pure = true) -+ @NonNull String key(); -+ -+ @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<LockCode> { -+ -+ @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder key(@NonNull String key); -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java b/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java new file mode 100644 -index 0000000000000000000000000000000000000000..7b195f3cea91446fa75c1c0982b0ac7070edb9e5 +index 0000000000000000000000000000000000000000..749249dca2fcdaf506820ea95a05720b980e25cc --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/LodestoneTracker.java -@@ -0,0 +1,63 @@ +@@ -0,0 +1,65 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.Location; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; @@ -1486,6 +1447,7 @@ index 0000000000000000000000000000000000000000..7b195f3cea91446fa75c1c0982b0ac70 +/** + * If present, specifies the target Lodestone that a Compass should point towards. + */ +public interface LodestoneTracker { + @@ -1515,8 +1477,9 @@ index 0000000000000000000000000000000000000000..7b195f3cea91446fa75c1c0982b0ac70 + @Contract(pure = true) + boolean tracked(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<LodestoneTracker> { ++ interface Builder extends DataComponentBuilder<LodestoneTracker> { + + /** + * Sets the location to point towards for this builder. @@ -1539,13 +1502,13 @@ index 0000000000000000000000000000000000000000..7b195f3cea91446fa75c1c0982b0ac70 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..d3702f5772bc05d91bc0d4ed2debd4b8f51e5c70 +index 0000000000000000000000000000000000000000..571b97d22f7a6360c8fa0bde22914f7f8ec71014 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/MapDecorations.java -@@ -0,0 +1,111 @@ +@@ -0,0 +1,113 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Map; +import org.bukkit.map.MapCursor; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -1557,6 +1520,7 @@ index 0000000000000000000000000000000000000000..d3702f5772bc05d91bc0d4ed2debd4b8 +/** + * Holds a list of markers to be placed on a Filled Map (used for Explorer Maps). + */ +public interface MapDecorations { + @@ -1590,6 +1554,7 @@ index 0000000000000000000000000000000000000000..d3702f5772bc05d91bc0d4ed2debd4b8 + /** + * Decoration present on the map. + */ ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface DecorationEntry { + @@ -1632,7 +1597,7 @@ index 0000000000000000000000000000000000000000..d3702f5772bc05d91bc0d4ed2debd4b8 + } + + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<MapDecorations> { ++ interface Builder extends DataComponentBuilder<MapDecorations> { + + /** + * Puts the decoration with the given id in this builder. @@ -1654,60 +1619,15 @@ index 0000000000000000000000000000000000000000..d3702f5772bc05d91bc0d4ed2debd4b8 + MapDecorations.@NonNull Builder putAll(@NonNull Map<@NonNull String, @NonNull DecorationEntry> entries); + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/MapId.java b/src/main/java/io/papermc/paper/datacomponent/item/MapId.java -new file mode 100644 -index 0000000000000000000000000000000000000000..a380ccfccf87e8ebf0bc40d93b375b406a6c2eb1 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/MapId.java -@@ -0,0 +1,39 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import io.papermc.paper.datacomponent.ComponentBuilder; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.Contract; -+ -+/** -+ * References the shared map state holding map contents and markers for a Filled Map. -+ */ -+public interface MapId { -+ -+ @Contract(value = "-> new", pure = true) -+ static MapId.@NonNull Builder mapId() { -+ return ComponentTypesBridge.bridge().mapId(); -+ } -+ -+ /** -+ * The map id. -+ * -+ * @return id -+ */ -+ @Contract(pure = true) -+ int id(); -+ -+ @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<MapId> { -+ -+ /** -+ * Sets the map id of this builder. -+ * -+ * @param id id -+ * @return the builder for chaining -+ */ -+ @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder id(int id); -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..40268f83d0330cd1af2e5aa028d14af83f8088e1 +index 0000000000000000000000000000000000000000..2bcd83438547417cfc6b382887d04e7d47d0d6c2 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/MapItemColor.java @@ -0,0 +1,39 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.Color; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -1732,7 +1652,7 @@ index 0000000000000000000000000000000000000000..40268f83d0330cd1af2e5aa028d14af8 + @NonNull Color color(); + + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<MapItemColor> { ++ interface Builder extends DataComponentBuilder<MapItemColor> { + + /** + * Sets the tint color of this map. @@ -1746,24 +1666,27 @@ index 0000000000000000000000000000000000000000..40268f83d0330cd1af2e5aa028d14af8 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..2f479feab1d5b0774a9388382eb8310c031fe4e2 +index 0000000000000000000000000000000000000000..f5d2bceb3baa51652274dc890eefd3ec15464b37 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java -@@ -0,0 +1,50 @@ +@@ -0,0 +1,54 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.bukkit.Material; ++import org.bukkit.inventory.ItemType; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + ++// CONTRIBUTORS: LEAVE THIS AS ITEM TYPE!!! +public interface PotDecorations { + + @Contract(value = "_, _, _, _ -> new", pure = true) -+ static @NonNull PotDecorations potDecorations(final @Nullable Material back, final @Nullable Material left, final @Nullable Material right, final @Nullable Material front) { ++ static @NonNull PotDecorations potDecorations(final @Nullable ItemType back, final @Nullable ItemType left, final @Nullable ItemType right, final @Nullable ItemType front) { + return potDecorations().back(back).left(left).right(right).front(front).build(); + } + @@ -1773,42 +1696,43 @@ index 0000000000000000000000000000000000000000..2f479feab1d5b0774a9388382eb8310c + } + + @Contract(pure = true) -+ @Nullable Material back(); ++ @Nullable ItemType back(); + + @Contract(pure = true) -+ @Nullable Material left(); ++ @Nullable ItemType left(); + + @Contract(pure = true) -+ @Nullable Material right(); ++ @Nullable ItemType right(); + + @Contract(pure = true) -+ @Nullable Material front(); ++ @Nullable ItemType front(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<PotDecorations> { ++ interface Builder extends DataComponentBuilder<PotDecorations> { + + @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder back(@Nullable Material back); ++ @NonNull Builder back(@Nullable ItemType back); + + @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder left(@Nullable Material left); ++ @NonNull Builder left(@Nullable ItemType left); + + @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder right(@Nullable Material right); ++ @NonNull Builder right(@Nullable ItemType right); + + @Contract(value = "_ -> this", mutates = "this") -+ @NonNull Builder front(@Nullable Material font); ++ @NonNull Builder front(@Nullable ItemType font); + } +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..26fbd67366c9cf02991eb6a8ce2d278419aa91c2 +index 0000000000000000000000000000000000000000..6f924f3fd13da1de3b7da921d0d2a96a56ca69b3 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java -@@ -0,0 +1,96 @@ +@@ -0,0 +1,98 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.List; +import org.bukkit.Color; +import org.bukkit.potion.PotionEffect; @@ -1822,6 +1746,7 @@ index 0000000000000000000000000000000000000000..26fbd67366c9cf02991eb6a8ce2d2784 +/** + * Holds the contents of a potion (Potion, Splash Potion, Lingering Potion), or potion applied to a Tipped Arrow. + */ +public interface PotionContents { + @@ -1856,8 +1781,9 @@ index 0000000000000000000000000000000000000000..26fbd67366c9cf02991eb6a8ce2d2784 + @Contract(pure = true) + @NonNull @Unmodifiable List<@NonNull PotionEffect> customEffects(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<PotionContents> { ++ interface Builder extends DataComponentBuilder<PotionContents> { + + /** + * Sets the potion type for this builder. @@ -1904,15 +1830,15 @@ index 0000000000000000000000000000000000000000..26fbd67366c9cf02991eb6a8ce2d2784 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java b/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java new file mode 100644 -index 0000000000000000000000000000000000000000..a776b230b9b80debafd41c7700dfdf39db2a2481 +index 0000000000000000000000000000000000000000..d776e0e93671963fdc0d5a7bc082e7be30ec66d7 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ResolvableProfile.java -@@ -0,0 +1,55 @@ +@@ -0,0 +1,57 @@ +package io.papermc.paper.datacomponent.item; + +import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.ProfileProperty; -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Collection; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; @@ -1922,6 +1848,7 @@ index 0000000000000000000000000000000000000000..a776b230b9b80debafd41c7700dfdf39 +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +public interface ResolvableProfile { + @@ -1947,8 +1874,9 @@ index 0000000000000000000000000000000000000000..a776b230b9b80debafd41c7700dfdf39 + @Contract(pure = true) + @NonNull CompletableFuture<@NonNull PlayerProfile> resolve(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<ResolvableProfile> { ++ interface Builder extends DataComponentBuilder<ResolvableProfile> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder name(@Nullable String name); @@ -1965,18 +1893,19 @@ index 0000000000000000000000000000000000000000..a776b230b9b80debafd41c7700dfdf39 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java b/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java new file mode 100644 -index 0000000000000000000000000000000000000000..d3794500fcbfbcd850aa591d71504002cc096a47 +index 0000000000000000000000000000000000000000..481c34440c70270d44d1e039c179eca05ce02428 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/SeededContainerLoot.java -@@ -0,0 +1,37 @@ +@@ -0,0 +1,39 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +public interface SeededContainerLoot { + @@ -1996,8 +1925,9 @@ index 0000000000000000000000000000000000000000..d3794500fcbfbcd850aa591d71504002 + @Contract(pure = true) + long seed(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<SeededContainerLoot> { ++ interface Builder extends DataComponentBuilder<SeededContainerLoot> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder lootTable(@NonNull Key key); @@ -2008,16 +1938,17 @@ index 0000000000000000000000000000000000000000..d3794500fcbfbcd850aa591d71504002 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java new file mode 100644 -index 0000000000000000000000000000000000000000..1e39fc6779e324030fb2890a4568376ffe3e5fab +index 0000000000000000000000000000000000000000..ab642ececb579b86e8c6eab6b968e4980f782395 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java -@@ -0,0 +1,21 @@ +@@ -0,0 +1,23 @@ +package io.papermc.paper.datacomponent.item; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +public interface ShownInTooltip<T> { + @@ -2027,6 +1958,7 @@ index 0000000000000000000000000000000000000000..1e39fc6779e324030fb2890a4568376f + @Contract(value = "_ -> new", pure = true) + @NonNull T showInTooltip(boolean showInTooltip); + ++ @ApiStatus.Experimental + interface Builder<B> { + + @Contract(value = "_ -> this", mutates = "this") @@ -2035,13 +1967,13 @@ index 0000000000000000000000000000000000000000..1e39fc6779e324030fb2890a4568376f +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java new file mode 100644 -index 0000000000000000000000000000000000000000..2c8c9aaac9326fc47f963651def7642a12341189 +index 0000000000000000000000000000000000000000..e3cefefcc7105e1c6fbcb2bbb5c2ea75f2ce9a07 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java -@@ -0,0 +1,63 @@ +@@ -0,0 +1,65 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import io.papermc.paper.potion.SuspiciousEffectEntry; +import java.util.Arrays; +import java.util.Collection; @@ -2054,6 +1986,7 @@ index 0000000000000000000000000000000000000000..2c8c9aaac9326fc47f963651def7642a +/** + * Holds the effects that will be applied when consuming Suspicious Stew. + */ +public interface SuspiciousStewEffects { + @@ -2080,8 +2013,9 @@ index 0000000000000000000000000000000000000000..2c8c9aaac9326fc47f963651def7642a + @Contract(pure = true) + @NonNull @Unmodifiable List<@NonNull SuspiciousEffectEntry> effects(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<SuspiciousStewEffects> { ++ interface Builder extends DataComponentBuilder<SuspiciousStewEffects> { + + /** + * Adds an effect applied to this builder. @@ -2104,13 +2038,13 @@ index 0000000000000000000000000000000000000000..2c8c9aaac9326fc47f963651def7642a +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Tool.java b/src/main/java/io/papermc/paper/datacomponent/item/Tool.java new file mode 100644 -index 0000000000000000000000000000000000000000..aeee3c4338dbf17e3c7623ab4276fe43ad79e0d0 +index 0000000000000000000000000000000000000000..ed67a747acc88099a6aac0d88d82a709c5d12f66 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/Tool.java -@@ -0,0 +1,133 @@ +@@ -0,0 +1,135 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import java.util.Collection; +import java.util.List; +import io.papermc.paper.registry.set.RegistryKeySet; @@ -2126,6 +2060,7 @@ index 0000000000000000000000000000000000000000..aeee3c4338dbf17e3c7623ab4276fe43 +/** + * Controls the behavior of the item as a tool. + */ +public interface Tool { + @@ -2158,6 +2093,7 @@ index 0000000000000000000000000000000000000000..aeee3c4338dbf17e3c7623ab4276fe43 + @Contract(pure = true) + @NonNull @Unmodifiable List<Tool.@NonNull Rule> rules(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Rule { + @@ -2202,7 +2138,7 @@ index 0000000000000000000000000000000000000000..aeee3c4338dbf17e3c7623ab4276fe43 + } + + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<Tool> { ++ interface Builder extends DataComponentBuilder<Tool> { + + /** + * Controls the amount of durability to remove each time a block is mined with this tool. @@ -2243,13 +2179,13 @@ index 0000000000000000000000000000000000000000..aeee3c4338dbf17e3c7623ab4276fe43 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java b/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java new file mode 100644 -index 0000000000000000000000000000000000000000..ecd1130152d0bac324cfd1feeb38b86e9e9a5893 +index 0000000000000000000000000000000000000000..3f34723f51968d83735ed8f95b5d2ef12fe480a2 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java -@@ -0,0 +1,27 @@ +@@ -0,0 +1,29 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; @@ -2257,6 +2193,7 @@ index 0000000000000000000000000000000000000000..ecd1130152d0bac324cfd1feeb38b86e +/** + * If set, the item will not lose any durability when used. + */ +public interface Unbreakable extends ShownInTooltip<Unbreakable> { + @@ -2270,19 +2207,20 @@ index 0000000000000000000000000000000000000000..ecd1130152d0bac324cfd1feeb38b86e + return ComponentTypesBridge.bridge().unbreakable(); + } + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ShownInTooltip.Builder<Builder>, ComponentBuilder<Unbreakable> { ++ interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<Unbreakable> { + } +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java new file mode 100644 -index 0000000000000000000000000000000000000000..9e448331e8855143ebdad2ea6419bcf2bc61389c +index 0000000000000000000000000000000000000000..d000ccc120808b74aa1d0fa3f578565da40d2388 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java -@@ -0,0 +1,67 @@ +@@ -0,0 +1,69 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import io.papermc.paper.util.Filtered; +import java.util.Collection; +import java.util.List; @@ -2291,6 +2229,7 @@ index 0000000000000000000000000000000000000000..9e448331e8855143ebdad2ea6419bcf2 +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +public interface WritableBookContent { + @@ -2307,8 +2246,9 @@ index 0000000000000000000000000000000000000000..9e448331e8855143ebdad2ea6419bcf2 + @Contract(pure = true) + @NonNull @Unmodifiable List<@NonNull Filtered<String>> pages(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<WritableBookContent> { ++ interface Builder extends DataComponentBuilder<WritableBookContent> { + + /** + * Adds a page that can be written to for this builder. @@ -2349,13 +2289,13 @@ index 0000000000000000000000000000000000000000..9e448331e8855143ebdad2ea6419bcf2 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java new file mode 100644 -index 0000000000000000000000000000000000000000..2b543a336ed2f53861d67470005373de0972ea5e +index 0000000000000000000000000000000000000000..6a3f6daae76e109b6c754752408fda73decc0335 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java -@@ -0,0 +1,97 @@ +@@ -0,0 +1,99 @@ +package io.papermc.paper.datacomponent.item; + -+import io.papermc.paper.datacomponent.ComponentBuilder; ++import io.papermc.paper.datacomponent.DataComponentBuilder; +import io.papermc.paper.util.Filtered; +import java.util.Collection; +import java.util.List; @@ -2370,12 +2310,13 @@ index 0000000000000000000000000000000000000000..2b543a336ed2f53861d67470005373de +/** + * Holds the contents and metadata of a Written Book. + */ +public interface WrittenBookContent { + + @Contract(value = "_, _ -> new", pure = true) + static WrittenBookContent.@NonNull Builder writtenBookContent(final @NonNull String title, final @NonNull String author) { -+ return writtenBookContent(Filtered.create(title, null), author); ++ return writtenBookContent(Filtered.of(title, null), author); + } + + @Contract(value = "_, _ -> new", pure = true) @@ -2419,8 +2360,9 @@ index 0000000000000000000000000000000000000000..2b543a336ed2f53861d67470005373de + @Contract(pure = true) + boolean resolved(); + ++ @ApiStatus.Experimental + @ApiStatus.NonExtendable -+ interface Builder extends ComponentBuilder<WrittenBookContent> { ++ interface Builder extends DataComponentBuilder<WrittenBookContent> { + + @Contract(value = "_ -> this", mutates = "this") + @NonNull Builder title(@NonNull String title); @@ -2497,7 +2439,7 @@ index 2945dde566682f977e84fde5d473a6c69be24df1..530cbadc8b4871113dc9ebb24bc565a9 /* ********************** * diff --git a/src/main/java/io/papermc/paper/util/Filtered.java b/src/main/java/io/papermc/paper/util/Filtered.java new file mode 100644 -index 0000000000000000000000000000000000000000..5c8cdf46bc12501e1f284b4760c48e79233d05ff +index 0000000000000000000000000000000000000000..6919f01a18bc0ab375d2e0541206524304243d19 --- /dev/null +++ b/src/main/java/io/papermc/paper/util/Filtered.java @@ -0,0 +1,30 @@ @@ -2518,7 +2460,7 @@ index 0000000000000000000000000000000000000000..5c8cdf46bc12501e1f284b4760c48e79 +public interface Filtered<T> { + + @Contract(value = "_, _ -> new", pure = true) -+ static <T> @NonNull Filtered<T> create(final @NonNull T raw, final @Nullable T filtered) { ++ static <T> @NonNull Filtered<T> of(final @NonNull T raw, final @Nullable T filtered) { + @ApiStatus.Internal + record Instance<T>(T raw, T filtered) implements Filtered<T> {} + @@ -2605,10 +2547,10 @@ index 54704da43cf9c429f3914f0580246dde99aa93c0..87bc4ce78350d95b9337262ba585b44c + // Paper end - data component API } diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index 9725580b6458e5d37fbc6059869604f9883bd6d1..966bbc686280a1b7f479a2ff755e477662f4bcd2 100644 +index 20015393f91af405c99db2635a471fb6ff19e4bf..7ab29c3d0471d5eb2152ff749efc15ac9d24acf8 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -348,6 +348,8 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -349,6 +349,8 @@ public interface Registry<T extends Keyed> extends Iterable<T> { return StreamSupport.stream(this.spliterator(), false); } }; @@ -2618,10 +2560,22 @@ index 9725580b6458e5d37fbc6059869604f9883bd6d1..966bbc686280a1b7f479a2ff755e4776 /** * Get the object by its key. diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index f603b5b6ba80af919f415322583a8345a5b1358a..2aa473fe063d53373c47a968735afb86f38044f7 100644 +index b3abe3bde05d4a360e31e490bff8a859dc2bd4a6..794b3cf36f6ce4fb2c7957a4b259f8adf63090f3 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1031,4 +1031,124 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1,10 +1,10 @@ + package org.bukkit.inventory; + + import com.google.common.base.Preconditions; +-import com.google.common.collect.ImmutableMap; + import java.util.LinkedHashMap; + import java.util.Locale; + import java.util.Map; ++import io.papermc.paper.datacomponent.DataComponentBuilder; + import org.bukkit.Bukkit; + import org.bukkit.Material; + import org.bukkit.NamespacedKey; +@@ -1033,4 +1033,149 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player); } // Paper end - expose itemstack tooltip lines @@ -2688,7 +2642,7 @@ index f603b5b6ba80af919f415322583a8345a5b1358a..2aa473fe063d53373c47a968735afb86 + * @param <T> value type + */ + @Utility -+ public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final io.papermc.paper.datacomponent.@NotNull ComponentBuilder<T> valueBuilder) { ++ public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final @NotNull DataComponentBuilder<T> valueBuilder) { + this.setData(type, valueBuilder.build()); + } + @@ -2744,17 +2698,41 @@ index f603b5b6ba80af919f415322583a8345a5b1358a..2aa473fe063d53373c47a968735afb86 + public boolean isOverridden(final io.papermc.paper.datacomponent.@NotNull DataComponentType type) { + return this.craftDelegate.isOverridden(type); + } ++ ++ /** ++ * Checks if this itemstack matches another given itemstack excluding the provided components. ++ * This is useful if you are wanting to ignore certain properties of itemstacks, such as durability. ++ * ++ * @param item the item to compare ++ * @param exclude the data component types to ignore ++ * @return {@code true} if the provided item is equal, ignoring the provided components ++ */ ++ public boolean matchesWithoutData(final @NotNull ItemStack item, final @NotNull java.util.Collection<io.papermc.paper.datacomponent.@NotNull DataComponentType> exclude) { ++ return this.matchesWithoutData(item, exclude, false); ++ } ++ ++ /** ++ * Checks if this itemstack matches another given itemstack excluding the provided components. ++ * This is useful if you are wanting to ignore certain properties of itemstacks, such as durability. ++ * ++ * @param item the item to compare ++ * @param exclude the data component types to ignore ++ * @param ignoreCount ignore the count of the item ++ * @return {@code true} if the provided item is equal, ignoring the provided components ++ */ ++ public boolean matchesWithoutData(final @NotNull ItemStack item, final @NotNull java.util.Collection<io.papermc.paper.datacomponent.@NotNull DataComponentType> exclude, final boolean ignoreCount) { ++ return this.craftDelegate.matchesWithoutData(item, exclude, ignoreCount); ++ } + // Paper end - data component API } diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java -index 6bc1853ada3ea38bc36cb31fbb5ce246347fe5d4..e77b4aa901363bbe6e01579af6d830dfa91942c1 100644 +index 0168f0a14a3e899e84c5e36963ff79950ab580fb..6d0466a8a54531eaf51521b10047a27ef83d47b7 100644 --- a/src/main/java/org/bukkit/inventory/ItemType.java +++ b/src/main/java/org/bukkit/inventory/ItemType.java -@@ -2326,4 +2326,31 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans - @Override - @NotNull String getTranslationKey(); - // Paper end - add Translatable -+ +@@ -2336,4 +2336,30 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans + */ + @Nullable ItemRarity getItemRarity(); + // Paper end - expand ItemRarity API + // Paper start - data component API + /** + * Gets the default value of the data component type for this item type. diff --git a/patches/server/1026-WIP-DataComponent-API.patch b/patches/server/1044-WIP-DataComponent-API.patch index 5d8c05fec4..7195099623 100644 --- a/patches/server/1026-WIP-DataComponent-API.patch +++ b/patches/server/1044-WIP-DataComponent-API.patch @@ -66,10 +66,10 @@ index 0000000000000000000000000000000000000000..08c717590a34584c359408c49c69379c +} diff --git a/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java b/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java new file mode 100644 -index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d430461205c9b +index 0000000000000000000000000000000000000000..7ae8148930197339b976366eaaca850b49af1993 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java -@@ -0,0 +1,167 @@ +@@ -0,0 +1,169 @@ +package io.papermc.paper.datacomponent; + +import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -78,7 +78,6 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 +import io.papermc.paper.datacomponent.item.PaperBlockItemDataProperties; +import io.papermc.paper.datacomponent.item.PaperBundleContents; +import io.papermc.paper.datacomponent.item.PaperChargedProjectiles; -+import io.papermc.paper.datacomponent.item.PaperCustomModelData; +import io.papermc.paper.datacomponent.item.PaperDyedItemColor; +import io.papermc.paper.datacomponent.item.PaperFireworks; +import io.papermc.paper.datacomponent.item.PaperFoodProperties; @@ -90,10 +89,8 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 +import io.papermc.paper.datacomponent.item.PaperItemLore; +import io.papermc.paper.datacomponent.item.PaperItemTool; +import io.papermc.paper.datacomponent.item.PaperJukeboxPlayable; -+import io.papermc.paper.datacomponent.item.PaperLockCode; +import io.papermc.paper.datacomponent.item.PaperLodestoneTracker; +import io.papermc.paper.datacomponent.item.PaperMapDecorations; -+import io.papermc.paper.datacomponent.item.PaperMapId; +import io.papermc.paper.datacomponent.item.PaperMapItemColor; +import io.papermc.paper.datacomponent.item.PaperPotDecorations; +import io.papermc.paper.datacomponent.item.PaperPotionContents; @@ -113,9 +110,14 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Unit; ++import net.minecraft.world.LockCode; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.component.CustomData; ++import net.minecraft.world.item.component.CustomModelData; ++import net.minecraft.world.item.component.MapItemColor; +import net.minecraft.world.item.component.MapPostProcessing; ++import net.minecraft.world.level.saveddata.maps.MapId; ++import org.bukkit.Color; +import org.bukkit.DyeColor; +import org.bukkit.craftbukkit.CraftMusicInstrument; +import org.bukkit.craftbukkit.inventory.CraftMetaFirework; @@ -160,7 +162,7 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 + register(DataComponents.CAN_PLACE_ON, PaperItemAdventurePredicate::new); + register(DataComponents.CAN_BREAK, PaperItemAdventurePredicate::new); + register(DataComponents.ATTRIBUTE_MODIFIERS, PaperItemAttributeModifiers::new); -+ register(DataComponents.CUSTOM_MODEL_DATA, PaperCustomModelData::new); ++ register(DataComponents.CUSTOM_MODEL_DATA, CustomModelData::value, CustomModelData::new); + registerUntyped(DataComponents.HIDE_ADDITIONAL_TOOLTIP); + registerUntyped(DataComponents.HIDE_TOOLTIP); + registerIdentity(DataComponents.REPAIR_COST); @@ -173,7 +175,7 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 + register(DataComponents.STORED_ENCHANTMENTS, PaperItemEnchantments::new); + register(DataComponents.DYED_COLOR, PaperDyedItemColor::new); + register(DataComponents.MAP_COLOR, PaperMapItemColor::new); -+ register(DataComponents.MAP_ID, PaperMapId::new); ++ register(DataComponents.MAP_ID, MapId::id, MapId::new); + register(DataComponents.MAP_DECORATIONS, PaperMapDecorations::new); + register(DataComponents.MAP_POST_PROCESSING, nms -> io.papermc.paper.item.MapPostProcessing.valueOf(nms.name()), api -> MapPostProcessing.valueOf(api.name())); + register(DataComponents.CHARGED_PROJECTILES, PaperChargedProjectiles::new); @@ -202,7 +204,7 @@ index 0000000000000000000000000000000000000000..cfec3010fa978aef047ce619315d4304 + register(DataComponents.CONTAINER, PaperItemContainerContents::new); + register(DataComponents.BLOCK_STATE, PaperBlockItemDataProperties::new); + // bees -+ register(DataComponents.LOCK, PaperLockCode::new); ++ register(DataComponents.LOCK, LockCode::key, LockCode::new); + register(DataComponents.CONTAINER_LOOT, PaperSeededContainerLoot::new); + + // TODO: REMOVE THIS... we want to build the PR... so lets just make things UNTYPED! @@ -394,10 +396,10 @@ index 0000000000000000000000000000000000000000..74e883d50477b3b4dabdcb674d95e92e +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridgesImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..9025c842daaf93f436b70c44494ff3875e56fd73 +index 0000000000000000000000000000000000000000..3efab440526a1bb715d786bb41d6ecc133119c6a --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/ComponentTypesBridgesImpl.java -@@ -0,0 +1,184 @@ +@@ -0,0 +1,170 @@ +package io.papermc.paper.datacomponent.item; + +import com.destroystokyo.paper.profile.PlayerProfile; @@ -473,11 +475,6 @@ index 0000000000000000000000000000000000000000..9025c842daaf93f436b70c44494ff387 + } + + @Override -+ public CustomModelData.Builder customModelData() { -+ return new PaperCustomModelData.BuilderImpl(); -+ } -+ -+ @Override + public SuspiciousStewEffects.Builder suspiciousStewEffects() { + return new PaperSuspiciousStewEffects.BuilderImpl(); + } @@ -488,11 +485,6 @@ index 0000000000000000000000000000000000000000..9025c842daaf93f436b70c44494ff387 + } + + @Override -+ public MapId.Builder mapId() { -+ return new PaperMapId.BuilderImpl(); -+ } -+ -+ @Override + public MapDecorations.Builder mapDecorations() { + return new PaperMapDecorations.BuilderImpl(); + } @@ -577,10 +569,6 @@ index 0000000000000000000000000000000000000000..9025c842daaf93f436b70c44494ff387 + return new PaperBlockItemDataProperties.BuilderImpl(); + } + -+ @Override -+ public LockCode.Builder lockCode() { -+ return new PaperLockCode.BuilderImpl(); -+ } +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperBannerPatternLayers.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperBannerPatternLayers.java new file mode 100644 @@ -652,10 +640,10 @@ index 0000000000000000000000000000000000000000..ac1fcacef8dc8bfb0487e4469d3e25b9 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperBlockItemDataProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperBlockItemDataProperties.java new file mode 100644 -index 0000000000000000000000000000000000000000..ee1d18e2855de575f921fefbae79d293aae08e97 +index 0000000000000000000000000000000000000000..892ccd37fc17fa98134fda7867648bda5e170a71 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperBlockItemDataProperties.java -@@ -0,0 +1,56 @@ +@@ -0,0 +1,57 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; @@ -666,6 +654,7 @@ index 0000000000000000000000000000000000000000..ee1d18e2855de575f921fefbae79d293 +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import org.bukkit.Material; ++import org.bukkit.block.BlockType; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.CraftBlockType; +import org.bukkit.craftbukkit.block.data.CraftBlockData; @@ -679,9 +668,9 @@ index 0000000000000000000000000000000000000000..ee1d18e2855de575f921fefbae79d293 +) implements BlockItemDataProperties, Handleable<BlockItemStateProperties> { + + @Override -+ public BlockData createBlockData(final Material blockType) { -+ Preconditions.checkArgument(blockType.isBlock(), "%s is not a block", blockType); -+ final Block block = CraftBlockType.bukkitToMinecraft(blockType); ++ public BlockData createBlockData(final BlockType blockType) { ++ //Preconditions.checkArgument(blockType.isBlock(), "%s is not a block", blockType); ++ final Block block = CraftBlockType.bukkitToMinecraftNew(blockType); + final BlockState defaultState = block.defaultBlockState(); + return this.impl.apply(defaultState).createCraftBlockData(); + } @@ -833,49 +822,6 @@ index 0000000000000000000000000000000000000000..db00e0d68dba2b844377248c8e70b5e2 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java -new file mode 100644 -index 0000000000000000000000000000000000000000..4188d7ff5b0ecbe2604859201a6074c7e615beb1 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java -@@ -0,0 +1,37 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import org.bukkit.craftbukkit.util.Handleable; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+ -+@DefaultQualifier(NonNull.class) -+public record PaperCustomModelData( -+ net.minecraft.world.item.component.CustomModelData impl -+) implements CustomModelData, Handleable<net.minecraft.world.item.component.CustomModelData> { -+ -+ @Override -+ public net.minecraft.world.item.component.CustomModelData getHandle() { -+ return this.impl; -+ } -+ -+ @Override -+ public int data() { -+ return this.impl.value(); -+ } -+ -+ static final class BuilderImpl implements CustomModelData.Builder { -+ -+ private int data = net.minecraft.world.item.component.CustomModelData.DEFAULT.value(); -+ -+ @Override -+ public CustomModelData.Builder data(final int data) { -+ this.data = data; -+ return this; -+ } -+ -+ @Override -+ public CustomModelData build() { -+ return new PaperCustomModelData(new net.minecraft.world.item.component.CustomModelData(this.data)); -+ } -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperDyedItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperDyedItemColor.java new file mode 100644 index 0000000000000000000000000000000000000000..ff2a81366fcd554451e9b2aa438e9277fa70248b @@ -1876,52 +1822,6 @@ index 0000000000000000000000000000000000000000..1afafbc43cbf1a0ce07b43ceeefdeaf9 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperLockCode.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperLockCode.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0dd5347ff8792ffc394575ce8b1241e8ccb8a6b3 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperLockCode.java -@@ -0,0 +1,40 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import org.bukkit.craftbukkit.util.Handleable; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+ -+@DefaultQualifier(NonNull.class) -+public record PaperLockCode( -+ net.minecraft.world.LockCode impl -+) implements LockCode, Handleable<net.minecraft.world.LockCode> { -+ -+ @Override -+ public net.minecraft.world.LockCode getHandle() { -+ return this.impl; -+ } -+ -+ @Override -+ public String key() { -+ return this.impl.key(); -+ } -+ -+ static final class BuilderImpl implements LockCode.Builder { -+ -+ private String key = net.minecraft.world.LockCode.NO_LOCK.key(); -+ -+ @Override -+ public LockCode.Builder key(final String key) { -+ this.key = key; -+ return this; -+ } -+ -+ @Override -+ public LockCode build() { -+ if (this.key.isEmpty()) { -+ return new PaperLockCode(net.minecraft.world.LockCode.NO_LOCK); -+ } -+ return new PaperLockCode(new net.minecraft.world.LockCode(this.key)); -+ } -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperLodestoneTracker.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperLodestoneTracker.java new file mode 100644 index 0000000000000000000000000000000000000000..104796a363d42c3dea7519e58b1ddafba29c4c00 @@ -2090,49 +1990,6 @@ index 0000000000000000000000000000000000000000..1970e41d600719be4352a9c73c04623c + } + } +} -diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperMapId.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperMapId.java -new file mode 100644 -index 0000000000000000000000000000000000000000..53db58f214fa60a1e3741d5b77f43602984a0c37 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperMapId.java -@@ -0,0 +1,37 @@ -+package io.papermc.paper.datacomponent.item; -+ -+import org.bukkit.craftbukkit.util.Handleable; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+ -+@DefaultQualifier(NonNull.class) -+public record PaperMapId( -+ net.minecraft.world.level.saveddata.maps.MapId impl -+) implements MapId, Handleable<net.minecraft.world.level.saveddata.maps.MapId> { -+ -+ @Override -+ public net.minecraft.world.level.saveddata.maps.MapId getHandle() { -+ return this.impl; -+ } -+ -+ @Override -+ public int id() { -+ return this.impl.id(); -+ } -+ -+ static final class BuilderImpl implements MapId.Builder { -+ -+ private int id = 0; -+ -+ @Override -+ public MapId.Builder id(final int id) { -+ this.id = id; -+ return this; -+ } -+ -+ @Override -+ public MapId build() { -+ return new PaperMapId(new net.minecraft.world.level.saveddata.maps.MapId(this.id)); -+ } -+ } -+} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperMapItemColor.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperMapItemColor.java new file mode 100644 index 0000000000000000000000000000000000000000..20a9652f9a1ab18df8e1581fea1ca363a125b68c @@ -2179,10 +2036,10 @@ index 0000000000000000000000000000000000000000..20a9652f9a1ab18df8e1581fea1ca363 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperPotDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperPotDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..be35ef33c9391ab766940bb7a98e191b73540360 +index 0000000000000000000000000000000000000000..cb19491e0f43e075d76415cad2b8a441f292f2d3 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperPotDecorations.java -@@ -0,0 +1,91 @@ +@@ -0,0 +1,92 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; @@ -2190,6 +2047,7 @@ index 0000000000000000000000000000000000000000..be35ef33c9391ab766940bb7a98e191b +import org.bukkit.Material; +import org.bukkit.craftbukkit.inventory.CraftItemType; +import org.bukkit.craftbukkit.util.Handleable; ++import org.bukkit.inventory.ItemType; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; @@ -2200,23 +2058,23 @@ index 0000000000000000000000000000000000000000..be35ef33c9391ab766940bb7a98e191b +) implements PotDecorations, Handleable<net.minecraft.world.level.block.entity.PotDecorations> { + + @Override -+ public @Nullable Material back() { -+ return this.impl.back().map(CraftItemType::minecraftToBukkit).orElse(null); ++ public @Nullable ItemType back() { ++ return this.impl.back().map(CraftItemType::minecraftToBukkitNew).orElse(null); + } + + @Override -+ public @Nullable Material left() { -+ return this.impl.left().map(CraftItemType::minecraftToBukkit).orElse(null); ++ public @Nullable ItemType left() { ++ return this.impl.left().map(CraftItemType::minecraftToBukkitNew).orElse(null); + } + + @Override -+ public @Nullable Material right() { -+ return this.impl.right().map(CraftItemType::minecraftToBukkit).orElse(null); ++ public @Nullable ItemType right() { ++ return this.impl.right().map(CraftItemType::minecraftToBukkitNew).orElse(null); + } + + @Override -+ public @Nullable Material front() { -+ return this.impl.front().map(CraftItemType::minecraftToBukkit).orElse(null); ++ public @Nullable ItemType front() { ++ return this.impl.front().map(CraftItemType::minecraftToBukkitNew).orElse(null); + } + + @Override @@ -2226,35 +2084,35 @@ index 0000000000000000000000000000000000000000..be35ef33c9391ab766940bb7a98e191b + + static final class BuilderImpl implements PotDecorations.Builder { + -+ private @Nullable Material back; -+ private @Nullable Material left; -+ private @Nullable Material right; -+ private @Nullable Material front; ++ private @Nullable ItemType back; ++ private @Nullable ItemType left; ++ private @Nullable ItemType right; ++ private @Nullable ItemType front; + + @Override -+ public PotDecorations.Builder back(final @Nullable Material back) { -+ Preconditions.checkArgument(back == null || back.isItem(), "%s is not an item", back); ++ public PotDecorations.Builder back(final @Nullable ItemType back) { ++ //Preconditions.checkArgument(back == null, "%s is not an item", back); + this.back = back; + return this; + } + + @Override -+ public PotDecorations.Builder left(final @Nullable Material left) { -+ Preconditions.checkArgument(left == null || left.isItem(), "%s is not an item", left); ++ public PotDecorations.Builder left(final @Nullable ItemType left) { ++ //Preconditions.checkArgument(left == null, "%s is not an item", left); + this.left = left; + return this; + } + + @Override -+ public PotDecorations.Builder right(final @Nullable Material right) { -+ Preconditions.checkArgument(right == null || right.isItem(), "%s is not an item", right); ++ public PotDecorations.Builder right(final @Nullable ItemType right) { ++ //Preconditions.checkArgument(right == null, "%s is not an item", right); + this.right = right; + return this; + } + + @Override -+ public PotDecorations.Builder front(final @Nullable Material front) { -+ Preconditions.checkArgument(front == null || front.isItem(), "%s is not an item", front); ++ public PotDecorations.Builder front(final @Nullable ItemType front) { ++ //Preconditions.checkArgument(front == null, "%s is not an item", front); + this.front = front; + return this; + } @@ -2266,10 +2124,10 @@ index 0000000000000000000000000000000000000000..be35ef33c9391ab766940bb7a98e191b + } + + return new PaperPotDecorations(new net.minecraft.world.level.block.entity.PotDecorations( -+ Optional.ofNullable(this.back).map(CraftItemType::bukkitToMinecraft), -+ Optional.ofNullable(this.left).map(CraftItemType::bukkitToMinecraft), -+ Optional.ofNullable(this.right).map(CraftItemType::bukkitToMinecraft), -+ Optional.ofNullable(this.front).map(CraftItemType::bukkitToMinecraft) ++ Optional.ofNullable(this.back).map(CraftItemType::bukkitToMinecraftNew), ++ Optional.ofNullable(this.left).map(CraftItemType::bukkitToMinecraftNew), ++ Optional.ofNullable(this.right).map(CraftItemType::bukkitToMinecraftNew), ++ Optional.ofNullable(this.front).map(CraftItemType::bukkitToMinecraftNew) + )); + } + } @@ -2676,7 +2534,7 @@ index 0000000000000000000000000000000000000000..2ff5004427766b0034595ddad04aac6b +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java new file mode 100644 -index 0000000000000000000000000000000000000000..8caf1ace56da48bb4eeab90161317e78b290ef4c +index 0000000000000000000000000000000000000000..964e819110825321e06da532c9d94f8fec4eb4b0 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java @@ -0,0 +1,112 @@ @@ -2695,7 +2553,7 @@ index 0000000000000000000000000000000000000000..8caf1ace56da48bb4eeab90161317e78 +import org.checkerframework.framework.qual.DefaultQualifier; + +import static io.papermc.paper.datacomponent.ComponentUtils.transform; -+import static io.papermc.paper.util.Filtered.create; ++import static io.papermc.paper.util.Filtered.of; + +@DefaultQualifier(NonNull.class) +public record PaperWritableBookContent( @@ -2706,7 +2564,7 @@ index 0000000000000000000000000000000000000000..8caf1ace56da48bb4eeab90161317e78 + public PaperWritableBookContent(final net.minecraft.world.item.component.WritableBookContent impl) { + this( + impl, -+ transform(impl.pages(), input -> create(input.raw(), input.filtered().orElse(null))) ++ transform(impl.pages(), input -> of(input.raw(), input.filtered().orElse(null))) + ); + } + @@ -2794,7 +2652,7 @@ index 0000000000000000000000000000000000000000..8caf1ace56da48bb4eeab90161317e78 +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java new file mode 100644 -index 0000000000000000000000000000000000000000..0f6a945faf59100cdfaffdd2cf5fe24f0bbbef64 +index 0000000000000000000000000000000000000000..fdfc10c9b5993d098f0ad8f4772ac7e58e8b07f7 --- /dev/null +++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java @@ -0,0 +1,191 @@ @@ -2833,7 +2691,7 @@ index 0000000000000000000000000000000000000000..0f6a945faf59100cdfaffdd2cf5fe24f + impl, + transform( + impl.pages(), -+ page -> Filtered.create(asAdventure(page.raw()), page.filtered().map(PaperAdventure::asAdventure).orElse(null)) ++ page -> Filtered.of(asAdventure(page.raw()), page.filtered().map(PaperAdventure::asAdventure).orElse(null)) + ) + ); + } @@ -2845,7 +2703,7 @@ index 0000000000000000000000000000000000000000..0f6a945faf59100cdfaffdd2cf5fe24f + + @Override + public Filtered<String> title() { -+ return Filtered.create(this.impl.title().raw(), this.impl.title().filtered().orElse(null)); ++ return Filtered.of(this.impl.title().raw(), this.impl.title().filtered().orElse(null)); + } + + @Override @@ -2990,7 +2848,7 @@ index 0000000000000000000000000000000000000000..0f6a945faf59100cdfaffdd2cf5fe24f + } +} diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java -index 9c0972023bc9be20ba81bbc2e1d6688b615760c0..7eb43862789ec1b37b658727e0fc7a99c91d0129 100644 +index 6ec9d9b9acf557aa2ebf39d38a14225b0205fae1..3a10a72cf6c5f91297a2d2980929f5484b3965be 100644 --- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -3,6 +3,8 @@ package io.papermc.paper.registry; @@ -3002,19 +2860,19 @@ index 9c0972023bc9be20ba81bbc2e1d6688b615760c0..7eb43862789ec1b37b658727e0fc7a99 import io.papermc.paper.registry.entry.RegistryEntry; import io.papermc.paper.registry.tag.TagKey; import java.util.Collections; -@@ -66,6 +68,7 @@ public final class PaperRegistries { - entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new), - entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new), - entry(Registries.ITEM, RegistryKey.ITEM, ItemType.class, CraftItemType::new), +@@ -81,6 +83,7 @@ public final class PaperRegistries { + entry(Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, Villager.Profession.class, CraftVillager.CraftProfession::new), + 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.DATA_COMPONENT_TYPE, RegistryKey.DATA_COMPONENT_TYPE, DataComponentType.class, PaperComponentType::of), // data-drivens entry(Registries.STRUCTURE, RegistryKey.STRUCTURE, Structure.class, CraftStructure::new).delayed(), diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36ad5ba6df5 100644 +index 40fb5b5e00f6bc82e67d318b8b3d1e7606973f52..15b2b43e718e7ea8a982e072ce9c8bc9baef119a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -192,7 +192,7 @@ public final class CraftItemStack extends ItemStack { +@@ -194,7 +194,7 @@ public final class CraftItemStack extends ItemStack { this.adjustTagForItemMeta(oldType); // Paper } } @@ -3023,7 +2881,7 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a } @Override -@@ -231,7 +231,7 @@ public final class CraftItemStack extends ItemStack { +@@ -233,7 +233,7 @@ public final class CraftItemStack extends ItemStack { @Override public int getMaxStackSize() { @@ -3032,7 +2890,7 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a } // Paper start -@@ -253,12 +253,14 @@ public final class CraftItemStack extends ItemStack { +@@ -255,12 +255,14 @@ public final class CraftItemStack extends ItemStack { public void addUnsafeEnchantment(Enchantment ench, int level) { Preconditions.checkArgument(ench != null, "Enchantment cannot be null"); @@ -3052,7 +2910,7 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a // Paper end } -@@ -288,27 +290,49 @@ public final class CraftItemStack extends ItemStack { +@@ -290,17 +292,28 @@ public final class CraftItemStack extends ItemStack { public int removeEnchantment(Enchantment ench) { Preconditions.checkArgument(ench != null, "Enchantment cannot be null"); @@ -3071,8 +2929,10 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a + ItemEnchantments itemEnchantments = this.handle.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); + if (itemEnchantments.isEmpty()) { + return 0; -+ } -+ + } +- // Paper end + +- return level; + Holder<net.minecraft.world.item.enchantment.Enchantment> removedEnchantment = CraftEnchantment.bukkitToMinecraftHolder(ench); + if (itemEnchantments.keySet().contains(removedEnchantment)) { + int previousLevel = itemEnchantments.getLevel(removedEnchantment); @@ -3081,23 +2941,14 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a + mutable.removeIf(enchantment -> enchantment.equals(removedEnchantment)); + this.handle.set(DataComponents.ENCHANTMENTS, mutable.toImmutable()); + return previousLevel; - } -- // Paper end - -- return level; ++ } ++ + return 0; + // Paper end } @Override - public void removeEnchantments() { -+ // Paper start - fix NPE -+ if (this.handle == null) { -+ return; -+ } -+ // Paper end - this.handle.remove(DataComponents.ENCHANTMENTS); - } +@@ -312,7 +325,13 @@ public final class CraftItemStack extends ItemStack { @Override public Map<Enchantment, Integer> getEnchantments() { @@ -3112,7 +2963,7 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a } static Map<Enchantment, Integer> getEnchantments(net.minecraft.world.item.ItemStack item) { -@@ -539,4 +563,84 @@ public final class CraftItemStack extends ItemStack { +@@ -543,4 +562,130 @@ public final class CraftItemStack extends ItemStack { return this.pdcView; } // Paper end - pdc @@ -3195,17 +3046,62 @@ index 32a41c8b324aad67b9dcf74387aef299e6478a64..551bd5bb5d5705fa6a2f84f70a15f36a + // maybe a more efficient way is to expose the "patch" map in PatchedDataComponentMap and just check if the type exists as a key + return !java.util.Objects.equals(this.handle.get(nms), this.handle.getPrototype().get(nms)); + } ++ ++ @Override ++ public boolean matchesWithoutData(final ItemStack item, final java.util.Collection<io.papermc.paper.datacomponent.DataComponentType> exclude, final boolean ignoreCount) { ++ // Extracted from base equals ++ if (!(item instanceof final org.bukkit.inventory.ItemStack bukkit)) return false; ++ final CraftItemStack craftStack = getCraftStack(bukkit); ++ if (this.handle == craftStack.handle) return true; ++ else if (this.handle == null || craftStack.handle == null) return false; ++ else if (this.handle.isEmpty() && craftStack.handle.isEmpty()) return true; ++ else { ++ net.minecraft.world.item.ItemStack left = this.handle; ++ net.minecraft.world.item.ItemStack right = craftStack.handle; ++ if (!ignoreCount && left.getCount() != right.getCount()) { ++ return false; ++ } ++ if (!left.is(right.getItem())) { ++ return false; ++ } ++ ++ // It can be assumed that the prototype is equal since the type is the same. This way all we need to check is the patch ++ ++ // Collect all the NMS types into a set ++ java.util.Set<net.minecraft.core.component.DataComponentType<?>> skippingTypes = exclude.isEmpty() ? java.util.Set.of() : new java.util.HashSet<>(exclude.size()); // micro op ++ for (io.papermc.paper.datacomponent.DataComponentType api : exclude) { ++ net.minecraft.core.component.DataComponentType<?> type = io.papermc.paper.datacomponent.PaperComponentType.bukkitToMinecraft(api); ++ skippingTypes.add(type); ++ } ++ ++ // Iterate over the entries in the left item, where we will then check to make sure the right entry has the same value. ++ // But, ignore if in our special set ++ java.util.Set<java.util.Map.Entry<net.minecraft.core.component.DataComponentType<?>, java.util.Optional<?>>> rightEntries = right.getComponentsPatch().entrySet(); ++ for (java.util.Map.Entry<net.minecraft.core.component.DataComponentType<?>, java.util.Optional<?>> leftEntry : left.getComponentsPatch().entrySet()) { ++ // This type should be skipped! ++ if (skippingTypes.contains(leftEntry.getKey())) { ++ continue; ++ } ++ // This will check if the right value contains the KEY & VALUE of leftEntry ++ if (!rightEntries.contains(leftEntry)) { ++ return false; ++ } ++ } ++ ++ return true; ++ } ++ } ++ + // Paper end - data component API } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java -index 07539ebfefa3352de5ee7a17f2724cf2c979f399..1ad733bd5fe0be1186a4e185424c4d1615f99eda 100644 +index 450c63c31d2f5d056d989aa00452231f50c8224d..65446258661b31c4efb47d3aa7548e991adc0c56 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java -@@ -263,4 +263,21 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han - return this.item.getDescriptionId(); +@@ -273,4 +273,20 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han + return rarity == null ? null : org.bukkit.inventory.ItemRarity.valueOf(rarity.name()); } - // Paper end - add Translatable -+ + // Paper end - expand ItemRarity API + // Paper start - data component API + @Override + public <T> T getDefaultData(final io.papermc.paper.datacomponent.DataComponentType.Valued<T> type) { @@ -3224,7 +3120,7 @@ index 07539ebfefa3352de5ee7a17f2724cf2c979f399..1ad733bd5fe0be1186a4e185424c4d16 + // Paper end - data component API } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java -index 7277e7ee566aabf6e01937072d949ed67c3e8e38..24ff8b4ed2a70d02b850c3701d3295fde726eed5 100644 +index 0eceacbb096481d3bd31f5f99e964c88aea2e3fb..acd80ad00caefe07232fc179cfbf4e7f56450859 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java @@ -78,7 +78,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { @@ -3273,18 +3169,93 @@ index 0000000000000000000000000000000000000000..1c1fcbbacc3881e088d64a7a840b3f3e +++ b/src/main/resources/META-INF/services/io.papermc.paper.datacomponent.item.ComponentTypesBridge @@ -0,0 +1 @@ +io.papermc.paper.datacomponent.item.ComponentTypesBridgesImpl +diff --git a/src/test/java/io/papermc/paper/item/ItemStackDataComponentEqualsTest.java b/src/test/java/io/papermc/paper/item/ItemStackDataComponentEqualsTest.java +new file mode 100644 +index 0000000000000000000000000000000000000000..06476cdd7f8290846e86bdd3837488ca900a7ddc +--- /dev/null ++++ b/src/test/java/io/papermc/paper/item/ItemStackDataComponentEqualsTest.java +@@ -0,0 +1,70 @@ ++package io.papermc.paper.item; ++ ++import io.papermc.paper.datacomponent.DataComponentTypes; ++import net.kyori.adventure.text.Component; ++import org.bukkit.Material; ++import org.bukkit.inventory.ItemStack; ++import org.bukkit.support.AbstractTestingBase; ++import org.junit.jupiter.api.Assertions; ++import org.junit.jupiter.api.Test; ++import java.util.Set; ++ ++class ItemStackDataComponentEqualsTest extends AbstractTestingBase { ++ ++ @Test ++ public void testEqual() { ++ ItemStack item1 = ItemStack.of(Material.STONE, 1); ++ item1.setData(DataComponentTypes.MAX_STACK_SIZE, 32); ++ item1.setData(DataComponentTypes.ITEM_NAME, Component.text("HI")); ++ ++ ItemStack item2 = ItemStack.of(Material.STONE, 1); ++ item2.setData(DataComponentTypes.MAX_STACK_SIZE, 32); ++ item2.setData(DataComponentTypes.ITEM_NAME, Component.text("HI")); ++ ++ Assertions.assertTrue(item1.matchesWithoutData(item2, Set.of())); ++ } ++ ++ @Test ++ public void testEqualIgnoreComponent() { ++ ItemStack item1 = ItemStack.of(Material.STONE, 2); ++ item1.setData(DataComponentTypes.MAX_STACK_SIZE, 1); ++ ++ ItemStack item2 = ItemStack.of(Material.STONE, 1); ++ item2.setData(DataComponentTypes.MAX_STACK_SIZE, 2); ++ ++ Assertions.assertFalse(item1.matchesWithoutData(item2, Set.of(DataComponentTypes.MAX_STACK_SIZE))); ++ } ++ ++ @Test ++ public void testEqualIgnoreComponentAndSize() { ++ ItemStack item1 = ItemStack.of(Material.STONE, 2); ++ item1.setData(DataComponentTypes.MAX_STACK_SIZE, 1); ++ ++ ItemStack item2 = ItemStack.of(Material.STONE, 1); ++ item2.setData(DataComponentTypes.MAX_STACK_SIZE, 2); ++ ++ Assertions.assertTrue(item1.matchesWithoutData(item2, Set.of(DataComponentTypes.MAX_STACK_SIZE), true)); ++ } ++ ++ @Test ++ public void testEqualIncludeComponentIgnoreSize() { ++ ItemStack item1 = ItemStack.of(Material.STONE, 2); ++ item1.setData(DataComponentTypes.MAX_STACK_SIZE, 1); ++ ++ ItemStack item2 = ItemStack.of(Material.STONE, 1); ++ item2.setData(DataComponentTypes.MAX_STACK_SIZE, 1); ++ ++ Assertions.assertTrue(item1.matchesWithoutData(item2, Set.of(), true)); ++ } ++ ++ @Test ++ public void testAdvancedExample() { ++ ItemStack oakLeaves = ItemStack.of(Material.OAK_LEAVES, 1); ++ oakLeaves.setData(DataComponentTypes.HIDE_TOOLTIP); ++ oakLeaves.setData(DataComponentTypes.MAX_STACK_SIZE, 1); ++ ++ ItemStack otherOakLeavesItem = ItemStack.of(Material.OAK_LEAVES, 2); ++ ++ Assertions.assertTrue(oakLeaves.matchesWithoutData(otherOakLeavesItem, Set.of(DataComponentTypes.HIDE_TOOLTIP, DataComponentTypes.MAX_STACK_SIZE), true)); ++ } ++} diff --git a/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java b/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7fdab5a944 +index 0000000000000000000000000000000000000000..ac0a278ca07282397639b4dfc246b770798f10e9 --- /dev/null +++ b/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java -@@ -0,0 +1,386 @@ +@@ -0,0 +1,385 @@ +package io.papermc.paper.item; + +import io.papermc.paper.datacomponent.DataComponentType; +import io.papermc.paper.datacomponent.DataComponentTypes; +import io.papermc.paper.datacomponent.item.ChargedProjectiles; -+import io.papermc.paper.datacomponent.item.CustomModelData; +import io.papermc.paper.datacomponent.item.DyedItemColor; +import io.papermc.paper.datacomponent.item.Fireworks; +import io.papermc.paper.datacomponent.item.FoodProperties; @@ -3293,7 +3264,6 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f +import io.papermc.paper.datacomponent.item.ItemEnchantments; +import io.papermc.paper.datacomponent.item.ItemLore; +import io.papermc.paper.datacomponent.item.JukeboxPlayable; -+import io.papermc.paper.datacomponent.item.MapId; +import io.papermc.paper.datacomponent.item.MapItemColor; +import io.papermc.paper.datacomponent.item.PotDecorations; +import io.papermc.paper.datacomponent.item.Tool; @@ -3320,6 +3290,7 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemRarity; +import org.bukkit.inventory.ItemStack; ++import org.bukkit.inventory.ItemType; +import org.bukkit.inventory.meta.ArmorMeta; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.CrossbowMeta; @@ -3453,7 +3424,7 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f + + @Test + void testCustomModelData() { -+ testWithMeta(new ItemStack(Material.STONE), DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelData.customModelData().data(1).build(), CustomModelData::data, ItemMeta.class, ItemMeta::getCustomModelData, ItemMeta::setCustomModelData); ++ testWithMeta(new ItemStack(Material.STONE), DataComponentTypes.CUSTOM_MODEL_DATA, 1, ItemMeta.class, ItemMeta::getCustomModelData, ItemMeta::setCustomModelData); + } + + @Test @@ -3573,7 +3544,7 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f + + @Test + void testMapId() { -+ testWithMeta(new ItemStack(Material.FILLED_MAP), DataComponentTypes.MAP_ID, MapId.mapId().id(1).build(), MapId::id, MapMeta.class, MapMeta::getMapId, MapMeta::setMapId); ++ testWithMeta(new ItemStack(Material.FILLED_MAP), DataComponentTypes.MAP_ID, 1, MapMeta.class, MapMeta::getMapId, MapMeta::setMapId); + } + + @Test @@ -3616,7 +3587,7 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f + @Test + void testPot() { + final ItemStack stack = new ItemStack(Material.DECORATED_POT); -+ stack.setData(DataComponentTypes.POT_DECORATIONS, PotDecorations.potDecorations().back(Material.DANGER_POTTERY_SHERD).build()); ++ stack.setData(DataComponentTypes.POT_DECORATIONS, PotDecorations.potDecorations().back(ItemType.DANGER_POTTERY_SHERD).build()); + + BlockState state = ((BlockStateMeta) stack.getItemMeta()).getBlockState(); + DecoratedPot decoratedPot = (DecoratedPot) state; @@ -3624,7 +3595,7 @@ index 0000000000000000000000000000000000000000..c87976e4bbef18ab536af6a86ae6fa7f + Assertions.assertEquals(decoratedPot.getSherd(DecoratedPot.Side.BACK), Material.DANGER_POTTERY_SHERD); + stack.unsetData(DataComponentTypes.POT_DECORATIONS); + decoratedPot = (DecoratedPot) ((BlockStateMeta) stack.getItemMeta()).getBlockState(); -+ Assertions.assertTrue(decoratedPot.getSherds().values().stream().allMatch((m) -> m == Material.BRICK)); ++ Assertions.assertTrue(decoratedPot.getSherds().values().stream().allMatch((m) -> m.asItemType() == ItemType.BRICK)); + } + + private static <T, M extends ItemMeta> void testWithMeta(final ItemStack stack, final DataComponentType.Valued<T> type, final T value, final Class<M> metaType, final Function<M, T> metaGetter, final BiConsumer<M, T> metaSetter) { @@ -3955,7 +3926,7 @@ index 0000000000000000000000000000000000000000..5a61ad9f3517b6cbf52e03c40b935900 + } +} diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java -index c28386c3114ce85d67832e55ab44e2ab8f6e04d7..c1fca209e67e2f7bfa6f9efdef52264253ef8d58 100644 +index 7787e399c6432120fb5a1826799cd229bbb28fe2..c06b409f3dce00bce846ae30852fe0cb33830684 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -100,17 +100,13 @@ public class PerMaterialTest extends AbstractTestingBase { @@ -3980,10 +3951,10 @@ index c28386c3114ce85d67832e55ab44e2ab8f6e04d7..c1fca209e67e2f7bfa6f9efdef522642 @ParameterizedTest diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java -index aabe3730fa582f442ee0544dd1a9f3123f719c68..a75fb4f856728610bec5ebd24eb9c28331ab16f5 100644 +index 1a582ee78334835df79f93cc9fd3669c347d8b3a..83a11c0eeecaf6aeb65f386a777b495231be8dc4 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java -@@ -444,7 +444,7 @@ public class ItemMetaTest extends AbstractTestingBase { +@@ -452,7 +452,7 @@ public class ItemMetaTest extends AbstractTestingBase { assertThat(providers, hasSize(ItemStackTest.COMPOUND_MATERIALS.length - 4/* Normal item meta, skulls, eggs and tile entities */), "Forgotten test?"); for (final StackProvider provider : providers) { @@ -3992,7 +3963,7 @@ index aabe3730fa582f442ee0544dd1a9f3123f719c68..a75fb4f856728610bec5ebd24eb9c283 this.downCastTest(new CraftWrapper(provider)); } } -@@ -504,13 +504,6 @@ public class ItemMetaTest extends AbstractTestingBase { +@@ -512,13 +512,6 @@ public class ItemMetaTest extends AbstractTestingBase { final ItemStack blank = new ItemStack(Material.STONE); final ItemStack craftBlank = CraftItemStack.asCraftCopy(blank); @@ -4007,14 +3978,14 @@ index aabe3730fa582f442ee0544dd1a9f3123f719c68..a75fb4f856728610bec5ebd24eb9c283 this.downCastTest(name, provider.stack(), craftBlank); craftBlank.setItemMeta(craftBlank.getItemMeta()); diff --git a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java -index a480944e1fc1b79b91be7e8d3e3799b9168cf5a0..2649f6cc4d51de64841318362b69aaef6f14b589 100644 +index c1f886c906a9f9313d97a223f719095fa2624c57..115a12d3d33abe70388f9fa20da2c3c6fca19849 100644 --- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java -@@ -58,6 +58,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { - register(RegistryKey.WOLF_VARIANT, Wolf.Variant.class, Registries.WOLF_VARIANT, CraftWolf.CraftVariant.class, WolfVariant.class); - register(RegistryKey.ITEM, ItemType.class, Registries.ITEM, CraftItemType.class, net.minecraft.world.item.Item.class, true); - register(RegistryKey.BLOCK, BlockType.class, Registries.BLOCK, CraftBlockType.class, net.minecraft.world.level.block.Block.class, true); +@@ -80,6 +80,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { + register(RegistryKey.CAT_VARIANT, Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class); + register(RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class); + register(RegistryKey.BANNER_PATTERN, PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class); + register(RegistryKey.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.DataComponentType.class, Registries.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.PaperComponentType.class, net.minecraft.core.component.DataComponentType.class); - } + private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper |