diff options
author | Jake Potrebic <[email protected]> | 2024-06-02 20:54:53 -0700 |
---|---|---|
committer | Owen1212055 <[email protected]> | 2024-11-18 14:50:37 -0500 |
commit | 7eedb357bf15b5643bebb2de9c0a11bfc257c034 (patch) | |
tree | e12a7f08fe9a640f0ede49b5fcd47979aeedc1bc | |
parent | f717c7142e5e1f365e8f1597e2677d17cf515db9 (diff) | |
download | Paper-7eedb357bf15b5643bebb2de9c0a11bfc257c034.tar.gz Paper-7eedb357bf15b5643bebb2de9c0a11bfc257c034.zip |
remove 'patch' and change package name
-rw-r--r-- | patches/api/0484-WIP-DataComponent-API.patch | 616 | ||||
-rw-r--r-- | patches/server/1053-WIP-DataComponent-API.patch | 313 |
2 files changed, 448 insertions, 481 deletions
diff --git a/patches/api/0484-WIP-DataComponent-API.patch b/patches/api/0484-WIP-DataComponent-API.patch index c1416612ca..46d7a83fbb 100644 --- a/patches/api/0484-WIP-DataComponent-API.patch +++ b/patches/api/0484-WIP-DataComponent-API.patch @@ -4,13 +4,13 @@ Date: Sun, 28 Apr 2024 19:53:06 -0400 Subject: [PATCH] WIP DataComponent API -diff --git a/src/main/java/io/papermc/paper/datakey/DataComponentType.java b/src/main/java/io/papermc/paper/datakey/DataComponentType.java +diff --git a/src/main/java/io/papermc/paper/component/DataComponentType.java b/src/main/java/io/papermc/paper/component/DataComponentType.java new file mode 100644 -index 0000000000000000000000000000000000000000..6ded5a082226abc61f3af625383149a1bb1dca9c +index 0000000000000000000000000000000000000000..d58cda809e551cb273b5ef6b449220b40cc443dc --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/DataComponentType.java ++++ b/src/main/java/io/papermc/paper/component/DataComponentType.java @@ -0,0 +1,24 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import net.kyori.adventure.key.Key; +import org.bukkit.Keyed; @@ -34,31 +34,31 @@ index 0000000000000000000000000000000000000000..6ded5a082226abc61f3af625383149a1 + + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java b/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java +diff --git a/src/main/java/io/papermc/paper/component/DataComponentTypes.java b/src/main/java/io/papermc/paper/component/DataComponentTypes.java new file mode 100644 -index 0000000000000000000000000000000000000000..f9c2401a74f4b827478aae9043033ca137545137 +index 0000000000000000000000000000000000000000..ea1a789086ba3f853cc0ac91cbe603fc3c416592 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java ++++ b/src/main/java/io/papermc/paper/component/DataComponentTypes.java @@ -0,0 +1,99 @@ -+package io.papermc.paper.datakey; -+ -+import io.papermc.paper.datakey.types.BundleContents; -+import io.papermc.paper.datakey.types.ChargedProjectiles; -+import io.papermc.paper.datakey.types.CustomModelData; -+import io.papermc.paper.datakey.types.DyedItemColor; -+import io.papermc.paper.datakey.types.FoodProperties; -+import io.papermc.paper.datakey.types.ItemAttributeModifiers; -+import io.papermc.paper.datakey.types.ItemEnchantments; -+import io.papermc.paper.datakey.types.ItemLore; -+import io.papermc.paper.datakey.types.MapDecorations; -+import io.papermc.paper.datakey.types.MapID; -+import io.papermc.paper.datakey.types.MapItemColor; -+import io.papermc.paper.datakey.types.MapPostProcessing; -+import io.papermc.paper.datakey.types.PotDecorations; -+import io.papermc.paper.datakey.types.PotionContents; -+import io.papermc.paper.datakey.types.SeededContainerLoot; -+import io.papermc.paper.datakey.types.SuspiciousStewEffects; -+import io.papermc.paper.datakey.types.Unbreakable; ++package io.papermc.paper.component; ++ ++import io.papermc.paper.component.item.BundleContents; ++import io.papermc.paper.component.item.ChargedProjectiles; ++import io.papermc.paper.component.item.CustomModelData; ++import io.papermc.paper.component.item.DyedItemColor; ++import io.papermc.paper.component.item.FoodProperties; ++import io.papermc.paper.component.item.ItemAttributeModifiers; ++import io.papermc.paper.component.item.ItemEnchantments; ++import io.papermc.paper.component.item.ItemLore; ++import io.papermc.paper.component.item.MapDecorations; ++import io.papermc.paper.component.item.MapID; ++import io.papermc.paper.component.item.MapItemColor; ++import io.papermc.paper.component.item.MapPostProcessing; ++import io.papermc.paper.component.item.PotDecorations; ++import io.papermc.paper.component.item.PotionContents; ++import io.papermc.paper.component.item.SeededContainerLoot; ++import io.papermc.paper.component.item.SuspiciousStewEffects; ++import io.papermc.paper.component.item.Unbreakable; +import net.kyori.adventure.text.Component; +import org.bukkit.DyeColor; +import org.bukkit.NamespacedKey; @@ -139,212 +139,13 @@ index 0000000000000000000000000000000000000000..f9c2401a74f4b827478aae9043033ca1 + private DataComponentTypes() { + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/map/DataComponentMap.java b/src/main/java/io/papermc/paper/datakey/map/DataComponentMap.java +diff --git a/src/main/java/io/papermc/paper/component/item/BundleContents.java b/src/main/java/io/papermc/paper/component/item/BundleContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..c3f2d8371dc5fb5bd22f7f5866cec2fbe4345dc1 +index 0000000000000000000000000000000000000000..8686f4022395d3cd64a077b388e6f48595dac6f7 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/map/DataComponentMap.java -@@ -0,0 +1,31 @@ -+package io.papermc.paper.datakey.map; -+ -+import io.papermc.paper.datakey.DataComponentType; -+import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import org.jetbrains.annotations.Unmodifiable; -+import java.util.Set; -+ -+public interface DataComponentMap { -+ -+ @Contract(value = "-> new", pure = true) -+ static @NotNull DataComponentMap empty() { -+ return DataComponentPatchMapBridge.Holder.bridge().empty(); -+ } -+ -+ @Contract(pure = true) -+ <T> @Nullable T get(DataComponentType.@NotNull Valued<T> type); -+ -+ @Contract(value = "_, !null -> !null", pure = true) -+ default <T> @Nullable T getOrDefault(final DataComponentType.@NotNull Valued<? extends T> type, final @Nullable T fallback) { -+ final T object = this.get(type); -+ return object != null ? object : fallback; -+ } -+ -+ @Contract(pure = true) -+ boolean has(@NotNull DataComponentType type); -+ -+ @NotNull @Unmodifiable Set<DataComponentType> keySet(); -+ -+} -diff --git a/src/main/java/io/papermc/paper/datakey/map/DataComponentPatchMapBridge.java b/src/main/java/io/papermc/paper/datakey/map/DataComponentPatchMapBridge.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5d60b4c1a7f2588838145001865236ce0d283c46 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/map/DataComponentPatchMapBridge.java -@@ -0,0 +1,30 @@ -+package io.papermc.paper.datakey.map; -+ -+import java.util.Optional; -+import net.kyori.adventure.util.Services; -+import org.bukkit.Material; -+import org.bukkit.inventory.meta.ItemMeta; -+import org.jetbrains.annotations.ApiStatus; -+ -+public interface DataComponentPatchMapBridge { -+ -+ PatchedDataComponentMap of(DataComponentMap map); -+ -+ DataComponentMap empty(); -+ -+ DataComponentMap fromItem(Material material); -+ -+ PatchedDataComponentMap fromItemAndMeta(Material material, ItemMeta meta); -+ -+ ItemMeta toItemMeta(Material material, PatchedDataComponentMap map); -+ -+ @ApiStatus.Internal -+ final class Holder { -+ private static final Optional<DataComponentPatchMapBridge> BRIDGE = Services.service(DataComponentPatchMapBridge.class); -+ -+ public static DataComponentPatchMapBridge bridge() { -+ return BRIDGE.orElseThrow(); -+ } -+ } -+} -diff --git a/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMap.java b/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMap.java -new file mode 100644 -index 0000000000000000000000000000000000000000..8d5614f9760f0b553ac3c8f3eb477a6a23a561b8 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMap.java -@@ -0,0 +1,57 @@ -+package io.papermc.paper.datakey.map; -+ -+import io.papermc.paper.datakey.DataComponentType; -+import io.papermc.paper.datakey.patch.DataKeyMapPatch; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+public interface PatchedDataComponentMap extends DataComponentMap { -+ -+ static @NotNull PatchedDataComponentMap empty() { -+ return DataComponentPatchMapBridge.Holder.bridge().of(DataComponentPatchMapBridge.Holder.bridge().empty()); -+ } -+ -+ static @NotNull PatchedDataComponentMap of(@NotNull final DataComponentMap map) { -+ return DataComponentPatchMapBridge.Holder.bridge().of(map); -+ } -+ -+ /** -+ * Sets this data component type to be present with a value in this map. -+ * <p> -+ * Note: supplying null will act similarly to {@link PatchedDataComponentMap#unset(DataComponentType)} -+ * -+ * @param type component type -+ * @param value set value -+ * @param <T> type -+ */ -+ <T> void set(@NotNull DataComponentType.Valued<T> type, @Nullable T value); -+ -+ /** -+ * Sets this data component type to be present in this map. -+ * -+ * @param type type -+ */ -+ void set(@NotNull DataComponentType.NonValued type); -+ -+ /** -+ * Unsets the value from this map. -+ * -+ * @param type data component type -+ */ -+ void unset(@NotNull DataComponentType type); -+ -+ /** -+ * Resets the value of this component to be the default value as -+ * supplied in the base map of this patched map. -+ * -+ * @param type data component type to reset -+ */ -+ void reset(@NotNull DataComponentType type); -+ -+ @NotNull DataKeyMapPatch asPatch(); -+ -+ void applyPatch(@NotNull DataKeyMapPatch patch); -+ -+ @NotNull -+ PatchedDataComponentMap copy(); -+} -diff --git a/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMapHolder.java b/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMapHolder.java -new file mode 100644 -index 0000000000000000000000000000000000000000..daf706d7312670348c5030cb25dec89e4df59839 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/map/PatchedDataComponentMapHolder.java -@@ -0,0 +1,35 @@ -+package io.papermc.paper.datakey.map; -+ -+import io.papermc.paper.datakey.DataComponentType; -+import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+public interface PatchedDataComponentMapHolder { -+ -+ @NotNull PatchedDataComponentMap components(); -+ -+ default boolean hasData(@NotNull final DataComponentType type) { -+ return this.components().has(type); -+ } -+ -+ @Nullable -+ default <T> T getData(@NotNull final DataComponentType.@NotNull Valued<T> type) { -+ return this.components().get(type); -+ } -+ -+ default <T> void setData(final DataComponentType.@NotNull Valued<T> type, final @Nullable T value) { -+ this.components().set(type, value); -+ } -+ -+ default void setData(final DataComponentType.@NotNull NonValued type) { -+ this.components().set(type); -+ } -+ -+ default <T> void removeData(final @NotNull DataComponentType type) { -+ this.components().unset(type); -+ } -+ -+} -diff --git a/src/main/java/io/papermc/paper/datakey/package-info.java b/src/main/java/io/papermc/paper/datakey/package-info.java -new file mode 100644 -index 0000000000000000000000000000000000000000..c0e4e57a278a107c013f15acbc7a149bcc6ed932 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/package-info.java -@@ -0,0 +1,5 @@ -+@DefaultQualifier(NonNull.class) -+package io.papermc.paper.datakey; -+ -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -diff --git a/src/main/java/io/papermc/paper/datakey/patch/DataKeyMapPatch.java b/src/main/java/io/papermc/paper/datakey/patch/DataKeyMapPatch.java -new file mode 100644 -index 0000000000000000000000000000000000000000..325a597b8d3e0c574b7bc80b7c9d0deeb3b28037 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/patch/DataKeyMapPatch.java -@@ -0,0 +1,5 @@ -+package io.papermc.paper.datakey.patch; -+ -+// TODO: Do we want this? -+public interface DataKeyMapPatch { -+} -diff --git a/src/main/java/io/papermc/paper/datakey/types/BundleContents.java b/src/main/java/io/papermc/paper/datakey/types/BundleContents.java -new file mode 100644 -index 0000000000000000000000000000000000000000..99076b20d5b8c4a44bf5ba19c0b1b0497ddc551b ---- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/BundleContents.java ++++ b/src/main/java/io/papermc/paper/component/item/BundleContents.java @@ -0,0 +1,33 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -377,13 +178,13 @@ index 0000000000000000000000000000000000000000..99076b20d5b8c4a44bf5ba19c0b1b049 + @NonNull BundleContents build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ChargedProjectiles.java b/src/main/java/io/papermc/paper/datakey/types/ChargedProjectiles.java +diff --git a/src/main/java/io/papermc/paper/component/item/ChargedProjectiles.java b/src/main/java/io/papermc/paper/component/item/ChargedProjectiles.java new file mode 100644 -index 0000000000000000000000000000000000000000..d6a9fdf1660027d2090c14c676415733af6abf50 +index 0000000000000000000000000000000000000000..dcf759607fd49aefd2abce280e0f3f434e6d7993 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ChargedProjectiles.java ++++ b/src/main/java/io/papermc/paper/component/item/ChargedProjectiles.java @@ -0,0 +1,33 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import org.bukkit.inventory.ItemStack; @@ -416,13 +217,13 @@ index 0000000000000000000000000000000000000000..d6a9fdf1660027d2090c14c676415733 + @NonNull ChargedProjectiles build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java +diff --git a/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java new file mode 100644 -index 0000000000000000000000000000000000000000..3877ff611ef9f6d5d979a45d2677ebbd1124fc79 +index 0000000000000000000000000000000000000000..0173820bd80354e4af215398db9308d38c6e59ab --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java ++++ b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java @@ -0,0 +1,58 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.Optional; +import net.kyori.adventure.key.Key; @@ -480,13 +281,13 @@ index 0000000000000000000000000000000000000000..3877ff611ef9f6d5d979a45d2677ebbd + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java b/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java +diff --git a/src/main/java/io/papermc/paper/component/item/CustomModelData.java b/src/main/java/io/papermc/paper/component/item/CustomModelData.java new file mode 100644 -index 0000000000000000000000000000000000000000..c9afd9da363708dc0ca1e1746b3eb12f69a9844f +index 0000000000000000000000000000000000000000..889b860be17a9690c0e9a7f383d55a8216a37000 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java ++++ b/src/main/java/io/papermc/paper/component/item/CustomModelData.java @@ -0,0 +1,26 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -512,13 +313,13 @@ index 0000000000000000000000000000000000000000..c9afd9da363708dc0ca1e1746b3eb12f + @NonNull CustomModelData build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/DyedItemColor.java b/src/main/java/io/papermc/paper/datakey/types/DyedItemColor.java +diff --git a/src/main/java/io/papermc/paper/component/item/DyedItemColor.java b/src/main/java/io/papermc/paper/component/item/DyedItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..37c7e5884303f38a04c63936b9512b99fe793555 +index 0000000000000000000000000000000000000000..825ec454ad412ecacce8da8c2a8dcc3590a0bb88 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/DyedItemColor.java ++++ b/src/main/java/io/papermc/paper/component/item/DyedItemColor.java @@ -0,0 +1,28 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.Color; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -546,13 +347,13 @@ index 0000000000000000000000000000000000000000..37c7e5884303f38a04c63936b9512b99 + @NonNull DyedItemColor build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/FoodProperties.java b/src/main/java/io/papermc/paper/datakey/types/FoodProperties.java +diff --git a/src/main/java/io/papermc/paper/component/item/FoodProperties.java b/src/main/java/io/papermc/paper/component/item/FoodProperties.java new file mode 100644 -index 0000000000000000000000000000000000000000..560f18ee9ffe473101f9df56abda34a10fd42149 +index 0000000000000000000000000000000000000000..fd8a2c011c214fe667938c22fdbe0c54db676e6f --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/FoodProperties.java ++++ b/src/main/java/io/papermc/paper/component/item/FoodProperties.java @@ -0,0 +1,61 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import org.bukkit.potion.PotionEffect; @@ -565,7 +366,7 @@ index 0000000000000000000000000000000000000000..560f18ee9ffe473101f9df56abda34a1 +public interface FoodProperties { + + @Contract(value = "-> new", pure = true) -+ static FoodProperties.@NonNull Builder food() { // can't name it just "enchantments" ++ static FoodProperties.@NonNull Builder food() { + return ComponentTypesBridge.Holder.bridge().food(); + } + @@ -613,13 +414,13 @@ index 0000000000000000000000000000000000000000..560f18ee9ffe473101f9df56abda34a1 + @NonNull FoodProperties build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datakey/types/ItemAttributeModifiers.java +diff --git a/src/main/java/io/papermc/paper/component/item/ItemAttributeModifiers.java b/src/main/java/io/papermc/paper/component/item/ItemAttributeModifiers.java new file mode 100644 -index 0000000000000000000000000000000000000000..d13cfbe8002dbc8c09bf28f1a3ed5952696449df +index 0000000000000000000000000000000000000000..ab1ed5e705256855dc35300161bc922f02e8227a --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ItemAttributeModifiers.java ++++ b/src/main/java/io/papermc/paper/component/item/ItemAttributeModifiers.java @@ -0,0 +1,36 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import org.bukkit.attribute.Attribute; @@ -655,13 +456,13 @@ index 0000000000000000000000000000000000000000..d13cfbe8002dbc8c09bf28f1a3ed5952 + @NonNull ItemAttributeModifiers build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ItemEnchantments.java b/src/main/java/io/papermc/paper/datakey/types/ItemEnchantments.java +diff --git a/src/main/java/io/papermc/paper/component/item/ItemEnchantments.java b/src/main/java/io/papermc/paper/component/item/ItemEnchantments.java new file mode 100644 -index 0000000000000000000000000000000000000000..196fbd62c586a1f401e07e4ae66cccd90b354ae2 +index 0000000000000000000000000000000000000000..ee1b18269cbc1b71f753d9eea2dfe59ffbc69e2c --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ItemEnchantments.java ++++ b/src/main/java/io/papermc/paper/component/item/ItemEnchantments.java @@ -0,0 +1,40 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.Map; +import org.bukkit.enchantments.Enchantment; @@ -701,13 +502,13 @@ index 0000000000000000000000000000000000000000..196fbd62c586a1f401e07e4ae66cccd9 + @NonNull ItemEnchantments build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ItemLore.java b/src/main/java/io/papermc/paper/datakey/types/ItemLore.java +diff --git a/src/main/java/io/papermc/paper/component/item/ItemLore.java b/src/main/java/io/papermc/paper/component/item/ItemLore.java new file mode 100644 -index 0000000000000000000000000000000000000000..dadeae6d1424123604a09ffa6972209a400f09f0 +index 0000000000000000000000000000000000000000..0f9f645ad2fbffb26636dfb702295fb358ecb58a --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ItemLore.java ++++ b/src/main/java/io/papermc/paper/component/item/ItemLore.java @@ -0,0 +1,40 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import net.kyori.adventure.text.Component; @@ -747,13 +548,13 @@ index 0000000000000000000000000000000000000000..dadeae6d1424123604a09ffa6972209a + + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java b/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java +diff --git a/src/main/java/io/papermc/paper/component/item/MapDecorations.java b/src/main/java/io/papermc/paper/component/item/MapDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..fd0b29b48e99fc97cce5fd647786ee1cd8112444 +index 0000000000000000000000000000000000000000..d22f08c08c209facd31c14c44c52221f0105b35b --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java ++++ b/src/main/java/io/papermc/paper/component/item/MapDecorations.java @@ -0,0 +1,47 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.map.MapCursor; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -800,13 +601,13 @@ index 0000000000000000000000000000000000000000..fd0b29b48e99fc97cce5fd647786ee1c + @NonNull MapDecorations build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/MapID.java b/src/main/java/io/papermc/paper/datakey/types/MapID.java +diff --git a/src/main/java/io/papermc/paper/component/item/MapID.java b/src/main/java/io/papermc/paper/component/item/MapID.java new file mode 100644 -index 0000000000000000000000000000000000000000..b1efd4e440e4b0294e2fb31af3db2b962a46df95 +index 0000000000000000000000000000000000000000..c5d7c7e23a60336869e4df0641e3915ed64eca17 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/MapID.java ++++ b/src/main/java/io/papermc/paper/component/item/MapID.java @@ -0,0 +1,27 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -833,13 +634,13 @@ index 0000000000000000000000000000000000000000..b1efd4e440e4b0294e2fb31af3db2b96 + + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java b/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java +diff --git a/src/main/java/io/papermc/paper/component/item/MapItemColor.java b/src/main/java/io/papermc/paper/component/item/MapItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..1f850d9554282e8676b360a3a5a673164f9975b0 +index 0000000000000000000000000000000000000000..09a16f4d9178b25012ee82ed4adba9c78682f0a9 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java ++++ b/src/main/java/io/papermc/paper/component/item/MapItemColor.java @@ -0,0 +1,28 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.Color; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -867,25 +668,25 @@ index 0000000000000000000000000000000000000000..1f850d9554282e8676b360a3a5a67316 + + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java b/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java +diff --git a/src/main/java/io/papermc/paper/component/item/MapPostProcessing.java b/src/main/java/io/papermc/paper/component/item/MapPostProcessing.java new file mode 100644 -index 0000000000000000000000000000000000000000..e803c5eadf8bd2db645c3bf0a7d8935ec9e5b53e +index 0000000000000000000000000000000000000000..0b26ee6870600557b82a6ea37e2789dcb5e267c8 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java ++++ b/src/main/java/io/papermc/paper/component/item/MapPostProcessing.java @@ -0,0 +1,6 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +public enum MapPostProcessing { + LOCK, + SCALE +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PotDecorations.java b/src/main/java/io/papermc/paper/datakey/types/PotDecorations.java +diff --git a/src/main/java/io/papermc/paper/component/item/PotDecorations.java b/src/main/java/io/papermc/paper/component/item/PotDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..99e6b393f3ad076b7646e07ec03dfa97c7421277 +index 0000000000000000000000000000000000000000..e4e62f40d375a5933b35f64537291d13fb0c9533 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PotDecorations.java ++++ b/src/main/java/io/papermc/paper/component/item/PotDecorations.java @@ -0,0 +1,43 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.inventory.ItemType; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -928,13 +729,13 @@ index 0000000000000000000000000000000000000000..99e6b393f3ad076b7646e07ec03dfa97 + @NonNull PotDecorations build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PotionContents.java b/src/main/java/io/papermc/paper/datakey/types/PotionContents.java +diff --git a/src/main/java/io/papermc/paper/component/item/PotionContents.java b/src/main/java/io/papermc/paper/component/item/PotionContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..d2e149715b1f402f34213ba4427149bf9dff5505 +index 0000000000000000000000000000000000000000..2fea9c373b4a86f98510bcf85979e35e053e2423 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PotionContents.java ++++ b/src/main/java/io/papermc/paper/component/item/PotionContents.java @@ -0,0 +1,45 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.List; +import org.bukkit.Color; @@ -979,13 +780,13 @@ index 0000000000000000000000000000000000000000..d2e149715b1f402f34213ba4427149bf + @NonNull PotionContents build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/SeededContainerLoot.java b/src/main/java/io/papermc/paper/datakey/types/SeededContainerLoot.java +diff --git a/src/main/java/io/papermc/paper/component/item/SeededContainerLoot.java b/src/main/java/io/papermc/paper/component/item/SeededContainerLoot.java new file mode 100644 -index 0000000000000000000000000000000000000000..90e8932dfb96650d3b30241a21aa6b15019449f9 +index 0000000000000000000000000000000000000000..eb89ff28b773f3fe24b0073513d5fc2abf4c370e --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/SeededContainerLoot.java ++++ b/src/main/java/io/papermc/paper/component/item/SeededContainerLoot.java @@ -0,0 +1,32 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import net.kyori.adventure.key.Key; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -1017,13 +818,13 @@ index 0000000000000000000000000000000000000000..90e8932dfb96650d3b30241a21aa6b15 + @NonNull SeededContainerLoot build(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ShownInTooltip.java b/src/main/java/io/papermc/paper/datakey/types/ShownInTooltip.java +diff --git a/src/main/java/io/papermc/paper/component/item/ShownInTooltip.java b/src/main/java/io/papermc/paper/component/item/ShownInTooltip.java new file mode 100644 -index 0000000000000000000000000000000000000000..90694aecb783918cfabfd3857fb5a2598a00b66c +index 0000000000000000000000000000000000000000..79b17d6b4b76059abed8c86428a49252723d8657 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ShownInTooltip.java ++++ b/src/main/java/io/papermc/paper/component/item/ShownInTooltip.java @@ -0,0 +1,21 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.Contract; @@ -1044,13 +845,13 @@ index 0000000000000000000000000000000000000000..90694aecb783918cfabfd3857fb5a259 + B showInTooltip(boolean showInTooltip); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/SuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datakey/types/SuspiciousStewEffects.java +diff --git a/src/main/java/io/papermc/paper/component/item/SuspiciousStewEffects.java b/src/main/java/io/papermc/paper/component/item/SuspiciousStewEffects.java new file mode 100644 -index 0000000000000000000000000000000000000000..1f939e9ee90e03b72601002a9826e649390b14c3 +index 0000000000000000000000000000000000000000..c34a430f608e8b50da907831eede570373c568f0 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/SuspiciousStewEffects.java ++++ b/src/main/java/io/papermc/paper/component/item/SuspiciousStewEffects.java @@ -0,0 +1,35 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import io.papermc.paper.potion.SuspiciousEffectEntry; +import java.util.List; @@ -1085,13 +886,13 @@ index 0000000000000000000000000000000000000000..1f939e9ee90e03b72601002a9826e649 + + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/Unbreakable.java b/src/main/java/io/papermc/paper/datakey/types/Unbreakable.java +diff --git a/src/main/java/io/papermc/paper/component/item/Unbreakable.java b/src/main/java/io/papermc/paper/component/item/Unbreakable.java new file mode 100644 -index 0000000000000000000000000000000000000000..44691c89fc42ed3f148f42ade08567fb3f617fce +index 0000000000000000000000000000000000000000..36e48ef697c001fff1697542eae6f79bd968d44a --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/Unbreakable.java ++++ b/src/main/java/io/papermc/paper/component/item/Unbreakable.java @@ -0,0 +1,27 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; @@ -1118,14 +919,197 @@ index 0000000000000000000000000000000000000000..44691c89fc42ed3f148f42ade08567fb + + } +} +diff --git a/src/main/java/io/papermc/paper/component/map/DataComponentMap.java b/src/main/java/io/papermc/paper/component/map/DataComponentMap.java +new file mode 100644 +index 0000000000000000000000000000000000000000..9378fca2d5122328f3b985fcdb4e1ea67d38ed2c +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/map/DataComponentMap.java +@@ -0,0 +1,31 @@ ++package io.papermc.paper.component.map; ++ ++import io.papermc.paper.component.DataComponentType; ++import org.jetbrains.annotations.Contract; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++import org.jetbrains.annotations.Unmodifiable; ++import java.util.Set; ++ ++public interface DataComponentMap { ++ ++ @Contract(value = "-> new", pure = true) ++ static @NotNull DataComponentMap empty() { ++ return DataComponentPatchMapBridge.Holder.bridge().empty(); ++ } ++ ++ @Contract(pure = true) ++ <T> @Nullable T get(DataComponentType.@NotNull Valued<T> type); ++ ++ @Contract(value = "_, !null -> !null", pure = true) ++ default <T> @Nullable T getOrDefault(final DataComponentType.@NotNull Valued<? extends T> type, final @Nullable T fallback) { ++ final T object = this.get(type); ++ return object != null ? object : fallback; ++ } ++ ++ @Contract(pure = true) ++ boolean has(@NotNull DataComponentType type); ++ ++ @NotNull @Unmodifiable Set<DataComponentType> keySet(); ++ ++} +diff --git a/src/main/java/io/papermc/paper/component/map/DataComponentPatchMapBridge.java b/src/main/java/io/papermc/paper/component/map/DataComponentPatchMapBridge.java +new file mode 100644 +index 0000000000000000000000000000000000000000..c4b4f7d5d3c02d94733f78b3d15a7d8703db4d88 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/map/DataComponentPatchMapBridge.java +@@ -0,0 +1,30 @@ ++package io.papermc.paper.component.map; ++ ++import java.util.Optional; ++import net.kyori.adventure.util.Services; ++import org.bukkit.Material; ++import org.bukkit.inventory.meta.ItemMeta; ++import org.jetbrains.annotations.ApiStatus; ++ ++public interface DataComponentPatchMapBridge { ++ ++ PatchedDataComponentMap of(DataComponentMap map); ++ ++ DataComponentMap empty(); ++ ++ DataComponentMap fromItem(Material material); ++ ++ PatchedDataComponentMap fromItemAndMeta(Material material, ItemMeta meta); ++ ++ ItemMeta toItemMeta(Material material, PatchedDataComponentMap map); ++ ++ @ApiStatus.Internal ++ final class Holder { ++ private static final Optional<DataComponentPatchMapBridge> BRIDGE = Services.service(DataComponentPatchMapBridge.class); ++ ++ public static DataComponentPatchMapBridge bridge() { ++ return BRIDGE.orElseThrow(); ++ } ++ } ++} +diff --git a/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMap.java b/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMap.java +new file mode 100644 +index 0000000000000000000000000000000000000000..63db7226900ab69d87f49124ffa1f9695ca35e26 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMap.java +@@ -0,0 +1,52 @@ ++package io.papermc.paper.component.map; ++ ++import io.papermc.paper.component.DataComponentType; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++public interface PatchedDataComponentMap extends DataComponentMap { ++ ++ static @NotNull PatchedDataComponentMap empty() { ++ return DataComponentPatchMapBridge.Holder.bridge().of(DataComponentPatchMapBridge.Holder.bridge().empty()); ++ } ++ ++ static @NotNull PatchedDataComponentMap of(@NotNull final DataComponentMap map) { ++ return DataComponentPatchMapBridge.Holder.bridge().of(map); ++ } ++ ++ /** ++ * Sets this data component type to be present with a value in this map. ++ * <p> ++ * Note: supplying null will act similarly to {@link PatchedDataComponentMap#unset(DataComponentType)} ++ * ++ * @param type component type ++ * @param value set value ++ * @param <T> type ++ */ ++ <T> void set(@NotNull DataComponentType.Valued<T> type, @Nullable T value); ++ ++ /** ++ * Sets this data component type to be present in this map. ++ * ++ * @param type type ++ */ ++ void set(@NotNull DataComponentType.NonValued type); ++ ++ /** ++ * Unsets the value from this map. ++ * ++ * @param type data component type ++ */ ++ void unset(@NotNull DataComponentType type); ++ ++ /** ++ * Resets the value of this component to be the default value as ++ * supplied in the base map of this patched map. ++ * ++ * @param type data component type to reset ++ */ ++ void reset(@NotNull DataComponentType type); ++ ++ @NotNull ++ PatchedDataComponentMap copy(); ++} +diff --git a/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMapHolder.java b/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMapHolder.java +new file mode 100644 +index 0000000000000000000000000000000000000000..e7b2dae4d569089c43e0ce70b7b7c82bfff994f1 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/map/PatchedDataComponentMapHolder.java +@@ -0,0 +1,35 @@ ++package io.papermc.paper.component.map; ++ ++import io.papermc.paper.component.DataComponentType; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++public interface PatchedDataComponentMapHolder { ++ ++ @NotNull PatchedDataComponentMap components(); ++ ++ default boolean hasData(@NotNull final DataComponentType type) { ++ return this.components().has(type); ++ } ++ ++ @Nullable ++ default <T> T getData(@NotNull final DataComponentType.@NotNull Valued<T> type) { ++ return this.components().get(type); ++ } ++ ++ default <T> void setData(final DataComponentType.@NotNull Valued<T> type, final @Nullable T value) { ++ this.components().set(type, value); ++ } ++ ++ default void setData(final DataComponentType.@NotNull NonValued type) { ++ this.components().set(type); ++ } ++ ++ default <T> void removeData(final @NotNull DataComponentType type) { ++ this.components().unset(type); ++ } ++ ++} +diff --git a/src/main/java/io/papermc/paper/component/package-info.java b/src/main/java/io/papermc/paper/component/package-info.java +new file mode 100644 +index 0000000000000000000000000000000000000000..37c9e2b084fe4c82242ae64569bb76beb6a88c09 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/package-info.java +@@ -0,0 +1,5 @@ ++@DefaultQualifier(NonNull.class) ++package io.papermc.paper.component; ++ ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java -index 7b79bf33074355020e0b3b5ef40c7f2e6ba644b4..76c9b6fe88b8cb0dd1d1ca1f9d8134c0def608a7 100644 +index 7b79bf33074355020e0b3b5ef40c7f2e6ba644b4..5cf3aa4641822c91adfbd70a847ca529fb2752a5 100644 --- a/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -1,5 +1,6 @@ package io.papermc.paper.registry; -+import io.papermc.paper.datakey.DataComponentType; ++import io.papermc.paper.component.DataComponentType; import net.kyori.adventure.key.Keyed; import org.bukkit.Art; import org.bukkit.Fluid; @@ -1149,7 +1133,7 @@ index 7509b61dfdc0a6675256970cb850b08f9e814580..35127ef25494f70a0d57ff8b8d0c3be5 GRANITE(21091), POLISHED_GRANITE(5477), diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index 88bb3b9ae99fae97ec21972b75ec43cb6b7b22b5..628257e4609fc39895ac4cff974cc92be1ac33af 100644 +index 88bb3b9ae99fae97ec21972b75ec43cb6b7b22b5..ca3a0a268a80ea3d342ec1c2c9d8ae105d271c88 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -343,6 +343,8 @@ public interface Registry<T extends Keyed> extends Iterable<T> { @@ -1157,7 +1141,7 @@ index 88bb3b9ae99fae97ec21972b75ec43cb6b7b22b5..628257e4609fc39895ac4cff974cc92b } }; + -+ Registry<io.papermc.paper.datakey.DataComponentType> DATA_COMPONENT_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.DATA_COMPONENT_TYPE); // Paper ++ Registry<io.papermc.paper.component.DataComponentType> DATA_COMPONENT_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.DATA_COMPONENT_TYPE); // Paper // Paper end /** * Get the object by its key. @@ -1174,7 +1158,7 @@ index e20f64828548c647a29dad5a475f4596cad88cd8..80c10ab30ca6ea6e2a80a916d8a5831a /** diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af51af002b 100644 +index c64413a6740b604282984dea2a8430a6e7478d68..8cc949629995c9093437a07671a02f131da0319b 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -1,7 +1,6 @@ @@ -1190,12 +1174,12 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af * returns false.</b> */ -public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowItem>, net.kyori.adventure.translation.Translatable { // Paper -+public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowItem>, net.kyori.adventure.translation.Translatable, io.papermc.paper.datakey.map.PatchedDataComponentMapHolder { // Paper ++public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowItem>, net.kyori.adventure.translation.Translatable, io.papermc.paper.component.map.PatchedDataComponentMapHolder { // Paper private Material type = Material.AIR; private int amount = 0; private MaterialData data = null; - private ItemMeta meta; -+ private io.papermc.paper.datakey.map.PatchedDataComponentMap dataKeyMap; // Paper ++ private io.papermc.paper.component.map.PatchedDataComponentMap dataKeyMap; // Paper @Utility protected ItemStack() {} @@ -1203,7 +1187,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af Preconditions.checkArgument(type != null, "Material cannot be null"); this.type = type; this.amount = amount; -+ this.dataKeyMap = io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().of(io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(type)); // Paper ++ this.dataKeyMap = io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().of(io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(type)); // Paper if (damage != 0) { setDurability(damage); } @@ -1211,7 +1195,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af Preconditions.checkArgument(stack != null, "Cannot copy null stack"); this.type = stack.getType(); this.amount = stack.getAmount(); -+ this.dataKeyMap = io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().of(io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(type)); // Paper ++ this.dataKeyMap = io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().of(io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(type)); // Paper if (this.type.isLegacy()) { this.data = stack.getData(); } @@ -1219,7 +1203,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af @Deprecated // Paper public void setType(@NotNull Material type) { Preconditions.checkArgument(type != null, "Material cannot be null"); -+ this.dataKeyMap = io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().fromItemAndMeta(type, Bukkit.getItemFactory().asMetaFor(this.getItemMeta(), type)); // Paper - update type first too, we need the old context to resolve the meta from the type ++ this.dataKeyMap = io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().fromItemAndMeta(type, Bukkit.getItemFactory().asMetaFor(this.getItemMeta(), type)); // Paper - update type first too, we need the old context to resolve the meta from the type this.type = type; - if (this.meta != null) { - this.meta = Bukkit.getItemFactory().asMetaFor(meta, type); @@ -1326,7 +1310,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af @UndefinedNullability // Paper public ItemMeta getItemMeta() { - return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone(); -+ return io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().toItemMeta(this.type, this.components()); ++ return io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().toItemMeta(this.type, this.components()); } /** @@ -1344,7 +1328,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af private boolean setItemMeta0(@Nullable ItemMeta itemMeta, @NotNull Material material) { if (itemMeta == null) { - this.meta = null; -+ this.dataKeyMap = io.papermc.paper.datakey.map.PatchedDataComponentMap.of(io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(material)); ++ this.dataKeyMap = io.papermc.paper.component.map.PatchedDataComponentMap.of(io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().fromItem(material)); return true; } if (!Bukkit.getItemFactory().isApplicable(itemMeta, material)) { @@ -1360,7 +1344,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af - if (this.meta == itemMeta) { - this.meta = itemMeta.clone(); - } -+ this.dataKeyMap = io.papermc.paper.datakey.map.DataComponentPatchMapBridge.Holder.bridge().fromItemAndMeta(material, itemMeta); ++ this.dataKeyMap = io.papermc.paper.component.map.DataComponentPatchMapBridge.Holder.bridge().fromItemAndMeta(material, itemMeta); return true; } @@ -1371,7 +1355,7 @@ index c64413a6740b604282984dea2a8430a6e7478d68..d9531cbe6005561bc802420405d5b2af + // Paper start + @NotNull + @Override -+ public io.papermc.paper.datakey.map.PatchedDataComponentMap components() { ++ public io.papermc.paper.component.map.PatchedDataComponentMap components() { + return this.dataKeyMap; + } + // Paper end diff --git a/patches/server/1053-WIP-DataComponent-API.patch b/patches/server/1053-WIP-DataComponent-API.patch index 54d33d40e8..b2f9d6e889 100644 --- a/patches/server/1053-WIP-DataComponent-API.patch +++ b/patches/server/1053-WIP-DataComponent-API.patch @@ -4,13 +4,13 @@ Date: Sun, 28 Apr 2024 19:53:01 -0400 Subject: [PATCH] WIP DataComponent API -diff --git a/src/main/java/io/papermc/paper/datakey/ComponentAdapter.java b/src/main/java/io/papermc/paper/datakey/ComponentAdapter.java +diff --git a/src/main/java/io/papermc/paper/component/ComponentAdapter.java b/src/main/java/io/papermc/paper/component/ComponentAdapter.java new file mode 100644 -index 0000000000000000000000000000000000000000..264a8a14d2a778ef4eaa5937342b5978d8856dca +index 0000000000000000000000000000000000000000..e538819c873a324c58bcd8e73f89510ed77b7a00 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/ComponentAdapter.java ++++ b/src/main/java/io/papermc/paper/component/ComponentAdapter.java @@ -0,0 +1,25 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import java.util.function.Function; +import net.minecraft.core.component.DataComponentType; @@ -35,31 +35,31 @@ index 0000000000000000000000000000000000000000..264a8a14d2a778ef4eaa5937342b5978 + return this.vanillaToApi.apply(value); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java b/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java +diff --git a/src/main/java/io/papermc/paper/component/ComponentAdapters.java b/src/main/java/io/papermc/paper/component/ComponentAdapters.java new file mode 100644 -index 0000000000000000000000000000000000000000..b3bbd86e9aa7fa30ec5bfc25c195522fc7caf060 +index 0000000000000000000000000000000000000000..ca621dd53bee70a2f383517a4f1f4c15d46ef485 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java ++++ b/src/main/java/io/papermc/paper/component/ComponentAdapters.java @@ -0,0 +1,131 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import io.papermc.paper.adventure.PaperAdventure; -+import io.papermc.paper.datakey.types.PaperBundleContents; -+import io.papermc.paper.datakey.types.PaperChargedProjectiles; -+import io.papermc.paper.datakey.types.PaperCustomModelData; -+import io.papermc.paper.datakey.types.PaperDyedItemColor; -+import io.papermc.paper.datakey.types.PaperFoodProperties; -+import io.papermc.paper.datakey.types.PaperItemAttributeModifiers; -+import io.papermc.paper.datakey.types.PaperItemEnchantments; -+import io.papermc.paper.datakey.types.PaperItemLore; -+import io.papermc.paper.datakey.types.PaperMapDecorations; -+import io.papermc.paper.datakey.types.PaperMapID; -+import io.papermc.paper.datakey.types.PaperMapItemColor; -+import io.papermc.paper.datakey.types.PaperPotDecorations; -+import io.papermc.paper.datakey.types.PaperPotionContents; -+import io.papermc.paper.datakey.types.PaperSeededContainerLoot; -+import io.papermc.paper.datakey.types.PaperSuspiciousStewEffects; -+import io.papermc.paper.datakey.types.PaperUnbreakable; ++import io.papermc.paper.component.item.PaperBundleContents; ++import io.papermc.paper.component.item.PaperChargedProjectiles; ++import io.papermc.paper.component.item.PaperCustomModelData; ++import io.papermc.paper.component.item.PaperDyedItemColor; ++import io.papermc.paper.component.item.PaperFoodProperties; ++import io.papermc.paper.component.item.PaperItemAttributeModifiers; ++import io.papermc.paper.component.item.PaperItemEnchantments; ++import io.papermc.paper.component.item.PaperItemLore; ++import io.papermc.paper.component.item.PaperMapDecorations; ++import io.papermc.paper.component.item.PaperMapID; ++import io.papermc.paper.component.item.PaperMapItemColor; ++import io.papermc.paper.component.item.PaperPotDecorations; ++import io.papermc.paper.component.item.PaperPotionContents; ++import io.papermc.paper.component.item.PaperSeededContainerLoot; ++import io.papermc.paper.component.item.PaperSuspiciousStewEffects; ++import io.papermc.paper.component.item.PaperUnbreakable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; @@ -172,17 +172,17 @@ index 0000000000000000000000000000000000000000..b3bbd86e9aa7fa30ec5bfc25c195522f + ADAPTERS.put(key, new ComponentAdapter<>(type, apiToVanilla, vanillaToApi)); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/DataComponentPatchBridgeImpl.java b/src/main/java/io/papermc/paper/datakey/DataComponentPatchBridgeImpl.java +diff --git a/src/main/java/io/papermc/paper/component/DataComponentPatchBridgeImpl.java b/src/main/java/io/papermc/paper/component/DataComponentPatchBridgeImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..825d2744187378cbf8de8b35ad5acc2a94d3653f +index 0000000000000000000000000000000000000000..d949c9b7d64ab6a1b97d6db5b181126b3b48b974 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/DataComponentPatchBridgeImpl.java ++++ b/src/main/java/io/papermc/paper/component/DataComponentPatchBridgeImpl.java @@ -0,0 +1,61 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import com.mojang.authlib.GameProfile; -+import io.papermc.paper.datakey.map.DataComponentMap; -+import io.papermc.paper.datakey.map.PatchedDataComponentMap; ++import io.papermc.paper.component.map.DataComponentMap; ++import io.papermc.paper.component.map.PatchedDataComponentMap; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; @@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..825d2744187378cbf8de8b35ad5acc2a +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Nullable; + -+public class DataComponentPatchBridgeImpl implements io.papermc.paper.datakey.map.DataComponentPatchMapBridge { ++public class DataComponentPatchBridgeImpl implements io.papermc.paper.component.map.DataComponentPatchMapBridge { + @Override + public PatchedDataComponentMap of(final DataComponentMap map) { + return new PaperPatchedDataComponentMap(new net.minecraft.core.component.PatchedDataComponentMap(((PaperDataComponentMap) map).map)); @@ -239,13 +239,13 @@ index 0000000000000000000000000000000000000000..825d2744187378cbf8de8b35ad5acc2a + return CraftItemStack.getItemMeta(stack, material); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/NonValuedDataComponentTypeImpl.java b/src/main/java/io/papermc/paper/datakey/NonValuedDataComponentTypeImpl.java +diff --git a/src/main/java/io/papermc/paper/component/NonValuedDataComponentTypeImpl.java b/src/main/java/io/papermc/paper/component/NonValuedDataComponentTypeImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..67ce3b2960396c86c1ba2cb568b76a982c608e58 +index 0000000000000000000000000000000000000000..5d474294598dc66134c584d50370f671c50177ac --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/NonValuedDataComponentTypeImpl.java ++++ b/src/main/java/io/papermc/paper/component/NonValuedDataComponentTypeImpl.java @@ -0,0 +1,14 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import org.bukkit.NamespacedKey; + @@ -259,13 +259,13 @@ index 0000000000000000000000000000000000000000..67ce3b2960396c86c1ba2cb568b76a98 + super(key, type, adapter); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/PaperComponentType.java b/src/main/java/io/papermc/paper/datakey/PaperComponentType.java +diff --git a/src/main/java/io/papermc/paper/component/PaperComponentType.java b/src/main/java/io/papermc/paper/component/PaperComponentType.java new file mode 100644 -index 0000000000000000000000000000000000000000..c5f6005b57e77061900b6c1b145f33f373834247 +index 0000000000000000000000000000000000000000..cf6d127c61116c6afd1b389420d9ed3d58c6b27b --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/PaperComponentType.java ++++ b/src/main/java/io/papermc/paper/component/PaperComponentType.java @@ -0,0 +1,71 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import net.kyori.adventure.key.Key; +import net.minecraft.core.registries.Registries; @@ -336,21 +336,19 @@ index 0000000000000000000000000000000000000000..c5f6005b57e77061900b6c1b145f33f3 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/PaperDataComponentMap.java b/src/main/java/io/papermc/paper/datakey/PaperDataComponentMap.java +diff --git a/src/main/java/io/papermc/paper/component/PaperDataComponentMap.java b/src/main/java/io/papermc/paper/component/PaperDataComponentMap.java new file mode 100644 -index 0000000000000000000000000000000000000000..8755afe2ed48aa086842ca6e53c3f6fd3ccc1468 +index 0000000000000000000000000000000000000000..0f225fa522b2b1595a994b86fd5daf548a5bb011 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/PaperDataComponentMap.java -@@ -0,0 +1,46 @@ -+package io.papermc.paper.datakey; ++++ b/src/main/java/io/papermc/paper/component/PaperDataComponentMap.java +@@ -0,0 +1,44 @@ ++package io.papermc.paper.component; + -+import io.papermc.paper.datakey.map.DataComponentMap; ++import io.papermc.paper.component.map.DataComponentMap; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; -+import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; -+import org.checkerframework.framework.qual.DefaultQualifier; + +public class PaperDataComponentMap implements DataComponentMap { + @@ -388,16 +386,16 @@ index 0000000000000000000000000000000000000000..8755afe2ed48aa086842ca6e53c3f6fd + return this.map.has(typeAsImpl.getHandle()); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/PaperPatchedDataComponentMap.java b/src/main/java/io/papermc/paper/datakey/PaperPatchedDataComponentMap.java +diff --git a/src/main/java/io/papermc/paper/component/PaperPatchedDataComponentMap.java b/src/main/java/io/papermc/paper/component/PaperPatchedDataComponentMap.java new file mode 100644 -index 0000000000000000000000000000000000000000..e5d89c6a0a31d8b4f6843e7149b28ba85c4616a2 +index 0000000000000000000000000000000000000000..3326e22a9914a47e09a29929afb4ec1e5defde0c --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/PaperPatchedDataComponentMap.java ++++ b/src/main/java/io/papermc/paper/component/PaperPatchedDataComponentMap.java @@ -0,0 +1,71 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + -+import io.papermc.paper.datakey.map.PatchedDataComponentMap; -+import io.papermc.paper.datakey.patch.DataKeyMapPatch; ++import io.papermc.paper.component.map.PatchedDataComponentMap; ++import io.papermc.paper.component.patch.DataKeyMapPatch; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -465,13 +463,13 @@ index 0000000000000000000000000000000000000000..e5d89c6a0a31d8b4f6843e7149b28ba8 + return ((net.minecraft.core.component.PatchedDataComponentMap) this.map); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/ValuedDataComponentTypeImpl.java b/src/main/java/io/papermc/paper/datakey/ValuedDataComponentTypeImpl.java +diff --git a/src/main/java/io/papermc/paper/component/ValuedDataComponentTypeImpl.java b/src/main/java/io/papermc/paper/component/ValuedDataComponentTypeImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..e6ebc39e96c9eb6f9869cfff258d4e25f28f8878 +index 0000000000000000000000000000000000000000..b05cf497c61efe8dd574b608e6e40ec75cddacb6 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/ValuedDataComponentTypeImpl.java ++++ b/src/main/java/io/papermc/paper/component/ValuedDataComponentTypeImpl.java @@ -0,0 +1,14 @@ -+package io.papermc.paper.datakey; ++package io.papermc.paper.component; + +import org.bukkit.NamespacedKey; + @@ -485,13 +483,13 @@ index 0000000000000000000000000000000000000000..e6ebc39e96c9eb6f9869cfff258d4e25 + super(key, type, adapter); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java +diff --git a/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..1f80dcaefb2934819e9f1230dbbc239be2fe24d6 +index 0000000000000000000000000000000000000000..1acb646804a449a8190909857f894c6897960b5e --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java ++++ b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java @@ -0,0 +1,98 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import net.kyori.adventure.key.Key; +import org.bukkit.map.MapCursor; @@ -589,13 +587,13 @@ index 0000000000000000000000000000000000000000..1f80dcaefb2934819e9f1230dbbc239b + return new PaperSeededContainerLoot.BuilderImpl(); + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperBundleContents.java b/src/main/java/io/papermc/paper/datakey/types/PaperBundleContents.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperBundleContents.java b/src/main/java/io/papermc/paper/component/item/PaperBundleContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..bf28f31d6c8a7ee3ca009ce7e521967f61208bc4 +index 0000000000000000000000000000000000000000..daf6de52e86870babaa5fe0e1bb5e04781363f21 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperBundleContents.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperBundleContents.java @@ -0,0 +1,57 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.ArrayList; +import java.util.Collections; @@ -652,13 +650,13 @@ index 0000000000000000000000000000000000000000..bf28f31d6c8a7ee3ca009ce7e521967f + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperChargedProjectiles.java b/src/main/java/io/papermc/paper/datakey/types/PaperChargedProjectiles.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperChargedProjectiles.java b/src/main/java/io/papermc/paper/component/item/PaperChargedProjectiles.java new file mode 100644 -index 0000000000000000000000000000000000000000..791cfb71a6ee82d31f8bd2b3284bed2a94a0769b +index 0000000000000000000000000000000000000000..9a86fc62758e61f6e006159f542733a2ebfd4f98 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperChargedProjectiles.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperChargedProjectiles.java @@ -0,0 +1,56 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import com.google.common.collect.Lists; +import java.util.ArrayList; @@ -714,13 +712,13 @@ index 0000000000000000000000000000000000000000..791cfb71a6ee82d31f8bd2b3284bed2a + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java b/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperCustomModelData.java b/src/main/java/io/papermc/paper/component/item/PaperCustomModelData.java new file mode 100644 -index 0000000000000000000000000000000000000000..7fa092ea11be29631ef96a21c5840cdf74b36228 +index 0000000000000000000000000000000000000000..72e1c55b1d4bc4304bf179f2ff98708c2220e531 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperCustomModelData.java @@ -0,0 +1,37 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.craftbukkit.util.Handleable; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -757,13 +755,13 @@ index 0000000000000000000000000000000000000000..7fa092ea11be29631ef96a21c5840cdf + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java b/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperDyedItemColor.java b/src/main/java/io/papermc/paper/component/item/PaperDyedItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..ac8a572978f00187ad08b4d9f16ab707692db1a8 +index 0000000000000000000000000000000000000000..1e2b03f7de79a2b2559bb896f2ea82862a6ec987 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperDyedItemColor.java @@ -0,0 +1,55 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.Color; +import org.bukkit.craftbukkit.util.Handleable; @@ -818,13 +816,13 @@ index 0000000000000000000000000000000000000000..ac8a572978f00187ad08b4d9f16ab707 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java b/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperFoodProperties.java b/src/main/java/io/papermc/paper/component/item/PaperFoodProperties.java new file mode 100644 -index 0000000000000000000000000000000000000000..33234042550eb3746f24fba45f5979529a38330e +index 0000000000000000000000000000000000000000..cb19f766943ac3aabddf03b958d151c25f8a9a16 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperFoodProperties.java @@ -0,0 +1,121 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.ArrayList; +import java.util.Collections; @@ -945,13 +943,13 @@ index 0000000000000000000000000000000000000000..33234042550eb3746f24fba45f597952 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datakey/types/PaperItemAttributeModifiers.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperItemAttributeModifiers.java b/src/main/java/io/papermc/paper/component/item/PaperItemAttributeModifiers.java new file mode 100644 -index 0000000000000000000000000000000000000000..80fecbc1c612f9df2746e0015022fa5669f5f349 +index 0000000000000000000000000000000000000000..26b195f590025406232fde513f602fd3ff536405 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperItemAttributeModifiers.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperItemAttributeModifiers.java @@ -0,0 +1,89 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import com.google.common.collect.Lists; +import java.util.ArrayList; @@ -1040,13 +1038,13 @@ index 0000000000000000000000000000000000000000..80fecbc1c612f9df2746e0015022fa56 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperItemEnchantments.java b/src/main/java/io/papermc/paper/datakey/types/PaperItemEnchantments.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperItemEnchantments.java b/src/main/java/io/papermc/paper/component/item/PaperItemEnchantments.java new file mode 100644 -index 0000000000000000000000000000000000000000..e14b02cf9e81a260d79c52f1f154e708f2cad374 +index 0000000000000000000000000000000000000000..ed99ed52fe47b231dae2b78bd1bc363389f9c11f --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperItemEnchantments.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperItemEnchantments.java @@ -0,0 +1,90 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.Collections; +import java.util.HashMap; @@ -1136,13 +1134,13 @@ index 0000000000000000000000000000000000000000..e14b02cf9e81a260d79c52f1f154e708 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperItemLore.java b/src/main/java/io/papermc/paper/datakey/types/PaperItemLore.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperItemLore.java b/src/main/java/io/papermc/paper/component/item/PaperItemLore.java new file mode 100644 -index 0000000000000000000000000000000000000000..7f4af0bbe6c2921d943234a910831d7ec7405581 +index 0000000000000000000000000000000000000000..b972ceebd3d5965d4926262b752c33a0ddb063d4 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperItemLore.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperItemLore.java @@ -0,0 +1,56 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import com.google.common.collect.Lists; +import io.papermc.paper.adventure.PaperAdventure; @@ -1198,13 +1196,13 @@ index 0000000000000000000000000000000000000000..7f4af0bbe6c2921d943234a910831d7e + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperMapDecorations.java b/src/main/java/io/papermc/paper/datakey/types/PaperMapDecorations.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperMapDecorations.java b/src/main/java/io/papermc/paper/component/item/PaperMapDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..05d83abd563e58f4f4a19283de566bc605abb300 +index 0000000000000000000000000000000000000000..2d97d20e0b16558a61ef21d2595b920e528d9879 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapDecorations.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperMapDecorations.java @@ -0,0 +1,74 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.HashMap; +import java.util.Map; @@ -1278,13 +1276,13 @@ index 0000000000000000000000000000000000000000..05d83abd563e58f4f4a19283de566bc6 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java b/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperMapID.java b/src/main/java/io/papermc/paper/component/item/PaperMapID.java new file mode 100644 -index 0000000000000000000000000000000000000000..ab6b36f01fc0efe15be0468bd198c8faef208ee7 +index 0000000000000000000000000000000000000000..805a86b4da99e82b3fa4254b62c0e26593f9f480 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperMapID.java @@ -0,0 +1,39 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import net.minecraft.world.level.saveddata.maps.MapId; +import org.bukkit.craftbukkit.util.Handleable; @@ -1323,13 +1321,13 @@ index 0000000000000000000000000000000000000000..ab6b36f01fc0efe15be0468bd198c8fa + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java b/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperMapItemColor.java b/src/main/java/io/papermc/paper/component/item/PaperMapItemColor.java new file mode 100644 -index 0000000000000000000000000000000000000000..be4dd3b5dddf59a02adbf4f7c2e6b9f05dc03bdb +index 0000000000000000000000000000000000000000..307fdefe165380c31e51b81c431b88709efbc494 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperMapItemColor.java @@ -0,0 +1,38 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.Color; +import org.bukkit.craftbukkit.util.Handleable; @@ -1367,13 +1365,13 @@ index 0000000000000000000000000000000000000000..be4dd3b5dddf59a02adbf4f7c2e6b9f0 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperPotDecorations.java b/src/main/java/io/papermc/paper/datakey/types/PaperPotDecorations.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperPotDecorations.java b/src/main/java/io/papermc/paper/component/item/PaperPotDecorations.java new file mode 100644 -index 0000000000000000000000000000000000000000..e65e5565bbcb5fe8a2b1cc41e5dc5c6d1e0c55af +index 0000000000000000000000000000000000000000..1ee8467c2156d1876cd84db2cfdda2884e75f33d --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperPotDecorations.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperPotDecorations.java @@ -0,0 +1,82 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.Optional; +import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -1455,13 +1453,13 @@ index 0000000000000000000000000000000000000000..e65e5565bbcb5fe8a2b1cc41e5dc5c6d + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java b/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperPotionContents.java b/src/main/java/io/papermc/paper/component/item/PaperPotionContents.java new file mode 100644 -index 0000000000000000000000000000000000000000..320832d0ab7b3d4a1a397b98859f8367275e984b +index 0000000000000000000000000000000000000000..b98bd15e9d0d32102a6213b4107f85bfd27fb9dd --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperPotionContents.java @@ -0,0 +1,92 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import java.util.ArrayList; +import java.util.Collections; @@ -1553,13 +1551,13 @@ index 0000000000000000000000000000000000000000..320832d0ab7b3d4a1a397b98859f8367 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java b/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperSeededContainerLoot.java b/src/main/java/io/papermc/paper/component/item/PaperSeededContainerLoot.java new file mode 100644 -index 0000000000000000000000000000000000000000..948f760f0171b9663e9c71b6d580d293e3cefc77 +index 0000000000000000000000000000000000000000..fc6169ea30df1d91363adcb48556afba30ac34a5 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperSeededContainerLoot.java @@ -0,0 +1,61 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import net.kyori.adventure.key.Key; +import net.minecraft.core.registries.Registries; @@ -1620,13 +1618,13 @@ index 0000000000000000000000000000000000000000..948f760f0171b9663e9c71b6d580d293 + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperSuspiciousStewEffects.java b/src/main/java/io/papermc/paper/component/item/PaperSuspiciousStewEffects.java new file mode 100644 -index 0000000000000000000000000000000000000000..0a878a20dce69a401ba1b3b5e68e2bfa567cad6e +index 0000000000000000000000000000000000000000..77780290067b7df301c0ca2634b61651506b7cda --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperSuspiciousStewEffects.java @@ -0,0 +1,58 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import io.papermc.paper.potion.SuspiciousEffectEntry; +import java.util.ArrayList; @@ -1684,13 +1682,13 @@ index 0000000000000000000000000000000000000000..0a878a20dce69a401ba1b3b5e68e2bfa + } + } +} -diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperUnbreakable.java b/src/main/java/io/papermc/paper/datakey/types/PaperUnbreakable.java +diff --git a/src/main/java/io/papermc/paper/component/item/PaperUnbreakable.java b/src/main/java/io/papermc/paper/component/item/PaperUnbreakable.java new file mode 100644 -index 0000000000000000000000000000000000000000..284bd1f81bc24645b6da6d5ff229eff3d13f28ca +index 0000000000000000000000000000000000000000..8be3187a6c624d4ba74d2a58bc64b1b0615a23f6 --- /dev/null -+++ b/src/main/java/io/papermc/paper/datakey/types/PaperUnbreakable.java ++++ b/src/main/java/io/papermc/paper/component/item/PaperUnbreakable.java @@ -0,0 +1,42 @@ -+package io.papermc.paper.datakey.types; ++package io.papermc.paper.component.item; + +import org.bukkit.craftbukkit.util.Handleable; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -1733,14 +1731,14 @@ index 0000000000000000000000000000000000000000..284bd1f81bc24645b6da6d5ff229eff3 + } +} diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java -index 51979b3c3f1f3a3c63e0559c70bed9193fd35dbb..d4ff5ba6afab0d19db277e4323aaa7bbb2d786b0 100644 +index 51979b3c3f1f3a3c63e0559c70bed9193fd35dbb..df2af45f32af3a1ddef25c5e7cca3973481806e2 100644 --- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -1,5 +1,7 @@ package io.papermc.paper.registry; -+import io.papermc.paper.datakey.DataComponentType; -+import io.papermc.paper.datakey.PaperComponentType; ++import io.papermc.paper.component.DataComponentType; ++import io.papermc.paper.component.PaperComponentType; import io.papermc.paper.registry.entry.RegistryEntry; import java.util.Collections; import java.util.IdentityHashMap; @@ -1766,7 +1764,7 @@ index af18de11dd55938b6091f5ab183bd3fe4e8df152..dad6cb4bbb52f4ce7e8f40131ee0bd37 ItemEnchantments(Object2IntAVLTreeMap<Holder<Enchantment>> enchantments, boolean showInTooltip) { // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index f1e1953f2dc65dc615b7b7b648c37b195d3b4c25..a31ed898a2ac447f90634cbd3d9fd1842154cc2a 100644 +index f1e1953f2dc65dc615b7b7b648c37b195d3b4c25..7660c37e775e3010ae265113ad7e1d60e1ce0af9 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -163,7 +163,7 @@ public final class CraftItemStack extends ItemStack { @@ -1811,12 +1809,12 @@ index f1e1953f2dc65dc615b7b7b648c37b195d3b4c25..a31ed898a2ac447f90634cbd3d9fd184 } + + @Override -+ public io.papermc.paper.datakey.PaperPatchedDataComponentMap components() { ++ public io.papermc.paper.component.PaperPatchedDataComponentMap components() { + if (this.handle == null) { -+ return new io.papermc.paper.datakey.PaperPatchedDataComponentMap(new net.minecraft.core.component.PatchedDataComponentMap(net.minecraft.core.component.DataComponentMap.EMPTY)); // Paper ++ return new io.papermc.paper.component.PaperPatchedDataComponentMap(new net.minecraft.core.component.PatchedDataComponentMap(net.minecraft.core.component.DataComponentMap.EMPTY)); // Paper + } + -+ return new io.papermc.paper.datakey.PaperPatchedDataComponentMap((net.minecraft.core.component.PatchedDataComponentMap) this.handle.getComponents()); // Paper ++ return new io.papermc.paper.component.PaperPatchedDataComponentMap((net.minecraft.core.component.PatchedDataComponentMap) this.handle.getComponents()); // Paper + } // Paper end } @@ -1862,21 +1860,20 @@ index d5789326d70bb8b029c5448270bbaa6faf52e6e1..02cdd38a55741a56ed9de428d9145e61 if (this.hasDisplayName()) { itemTag.put(CraftMetaItem.NAME, this.displayName); } -diff --git a/src/main/resources/META-INF/services/io.papermc.paper.datakey.map.DataComponentPatchMapBridge b/src/main/resources/META-INF/services/io.papermc.paper.datakey.map.DataComponentPatchMapBridge +diff --git a/src/main/resources/META-INF/services/io.papermc.paper.component.item.ComponentTypesBridge b/src/main/resources/META-INF/services/io.papermc.paper.component.item.ComponentTypesBridge new file mode 100644 -index 0000000000000000000000000000000000000000..9fd7c2b9089b3a13834fcca23e9a7c47c0cead83 +index 0000000000000000000000000000000000000000..a2c02206254a18e089cb2b40eab5c59e08c1e8c8 --- /dev/null -+++ b/src/main/resources/META-INF/services/io.papermc.paper.datakey.map.DataComponentPatchMapBridge ++++ b/src/main/resources/META-INF/services/io.papermc.paper.component.item.ComponentTypesBridge @@ -0,0 +1 @@ -+io.papermc.paper.datakey.DataComponentPatchBridgeImpl -diff --git a/src/main/resources/META-INF/services/io.papermc.paper.datakey.types.ComponentTypesBridge b/src/main/resources/META-INF/services/io.papermc.paper.datakey.types.ComponentTypesBridge ++io.papermc.paper.component.item.ComponentTypesBridgesImpl +diff --git a/src/main/resources/META-INF/services/io.papermc.paper.component.map.DataComponentPatchMapBridge b/src/main/resources/META-INF/services/io.papermc.paper.component.map.DataComponentPatchMapBridge new file mode 100644 -index 0000000000000000000000000000000000000000..d43e2b2d0e86ed585ba7bfd4e26d625960cc6fe7 +index 0000000000000000000000000000000000000000..766f11eb61fc5588b61f303f960f6f9dc1f32fee --- /dev/null -+++ b/src/main/resources/META-INF/services/io.papermc.paper.datakey.types.ComponentTypesBridge ++++ b/src/main/resources/META-INF/services/io.papermc.paper.component.map.DataComponentPatchMapBridge @@ -0,0 +1 @@ -+io.papermc.paper.datakey.types.ComponentTypesBridgesImpl -\ No newline at end of file ++io.papermc.paper.component.DataComponentPatchBridgeImpl diff --git a/src/test/java/io/papermc/paper/configuration/ConfigurationSectionTest.java b/src/test/java/io/papermc/paper/configuration/ConfigurationSectionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0aad5d896a6adb691a7efaee3baebed4da7c607e @@ -1958,17 +1955,17 @@ index 0000000000000000000000000000000000000000..def33c36f207a4c5306b5a895336aa70 +} 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..23de6a166fd48e231912d80f897eee6e006abca9 +index 0000000000000000000000000000000000000000..40c77423134931083913e871b80dae8e6e5f2194 --- /dev/null +++ b/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java -@@ -0,0 +1,128 @@ +@@ -0,0 +1,127 @@ +package io.papermc.paper.item; + -+import io.papermc.paper.datakey.DataComponentType; -+import io.papermc.paper.datakey.DataComponentTypes; -+import io.papermc.paper.datakey.types.ChargedProjectiles; -+import io.papermc.paper.datakey.types.PotDecorations; -+import io.papermc.paper.datakey.types.Unbreakable; ++import io.papermc.paper.component.DataComponentType; ++import io.papermc.paper.component.DataComponentTypes; ++import io.papermc.paper.component.item.ChargedProjectiles; ++import io.papermc.paper.component.item.PotDecorations; ++import io.papermc.paper.component.item.Unbreakable; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.block.DecoratedPot; @@ -1983,7 +1980,6 @@ index 0000000000000000000000000000000000000000..23de6a166fd48e231912d80f897eee6e +import org.bukkit.support.AbstractTestingBase; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -+import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Function; + @@ -2433,28 +2429,15 @@ 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 24f01242513d6c815f60599d7118fe12bc577804..0a97ce55fb1e31195bbb9c75a6cac7ce56f13f3e 100644 +index 24f01242513d6c815f60599d7118fe12bc577804..6210b43c364da26cf3d30a2add695dbba5d9c521 100644 --- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java -@@ -1,9 +1,12 @@ - package org.bukkit.support.provider; - - import com.google.common.collect.Lists; -+import io.papermc.paper.datakey.PaperComponentType; - import io.papermc.paper.registry.RegistryKey; - import java.util.List; - import java.util.stream.Stream; -+import io.papermc.paper.datakey.DataComponentType; -+import io.papermc.paper.datakey.PaperComponentType; - import net.minecraft.core.registries.Registries; - import net.minecraft.resources.ResourceKey; - import net.minecraft.world.effect.MobEffect; -@@ -55,7 +58,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { +@@ -55,7 +55,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); - -+ register(RegistryKey.DATA_COMPONENT_TYPE, DataComponentType.class, Registries.DATA_COMPONENT_TYPE, PaperComponentType.class, net.minecraft.core.component.DataComponentType.class, false); ++ register(RegistryKey.DATA_COMPONENT_TYPE, io.papermc.paper.component.DataComponentType.class, Registries.DATA_COMPONENT_TYPE, io.papermc.paper.component.PaperComponentType.class, net.minecraft.core.component.DataComponentType.class, false); } private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper |