Added custom_model_data, food, dyed_color, map_color, map_id, map_decorations, map_post_processing,bundle_contents, potion_contents,suspicious_stew_effects, recipes, base_color, container_loot

This commit is contained in:
Owen1212055 2024-06-02 18:00:49 -04:00 committed by Jake Potrebic
parent 47a6877ba0
commit 444c2d631a
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
3 changed files with 1305 additions and 33 deletions

View file

@ -36,22 +36,36 @@ index 0000000000000000000000000000000000000000..089047983db1e72f7144fd549c592ae8
+}
diff --git a/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java b/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java
new file mode 100644
index 0000000000000000000000000000000000000000..cfd23f6b3559354c1b3e875649b86dd260111ddf
index 0000000000000000000000000000000000000000..69c1258e572a4e9b9cef579d14febf17ebd602e0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/DataComponentTypes.java
@@ -0,0 +1,80 @@
@@ -0,0 +1,94 @@
+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;
+import net.kyori.adventure.text.Component;
+import org.bukkit.DyeColor;
+import org.bukkit.NamespacedKey;
+import org.bukkit.Registry;
+import org.bukkit.inventory.ItemRarity;
+import java.security.Key;
+import java.util.List;
+
+public class DataComponentTypes {
+
@ -67,26 +81,26 @@ index 0000000000000000000000000000000000000000..cfd23f6b3559354c1b3e875649b86dd2
+ // can_place_on
+ // can_break
+ public static final DataComponentType.Valued<ItemAttributeModifiers> ATTRIBUTE_MODIFIERS = valued("attribute_modifiers");
+ // custom_model_data
+ public static final DataComponentType.Valued<CustomModelData> CUSTOM_MODEL_DATA = valued("custom_model_data");
+ public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip");
+ public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip");
+ public static final DataComponentType.Valued<Integer> REPAIR_COST = valued("repair_cost");
+ public static final DataComponentType.NonValued CREATIVE_SLOT_LOCK = unvalued("creative_slot_lock");
+ public static final DataComponentType.Valued<Boolean> ENCHANTMENT_GLINT_OVERRIDE = valued("enchantment_glint_override");
+ public static final DataComponentType.NonValued INTANGIBLE_PROJECTILE = unvalued("intangible_projectile");
+ // food
+ public static final DataComponentType.Valued<FoodProperties> FOOD = valued("food");
+ public static final DataComponentType.NonValued FIRE_RESISTANT = unvalued("fire_resistant");
+ // tool
+ public static final DataComponentType.Valued<ItemEnchantments> STORED_ENCHANTMENTS = valued("stored_enchantments");
+ // dyed_color
+ // map_color
+ // map_id
+ // map_decorations
+ // map_post_processing
+ public static final DataComponentType.Valued<DyedItemColor> DYED_COLOR = valued("dyed_color");
+ public static final DataComponentType.Valued<MapItemColor> MAP_COLOR = valued("map_color");
+ public static final DataComponentType.Valued<MapID> MAP_ID = valued("map_id");
+ public static final DataComponentType.Valued<MapDecorations> MAP_DECORATIONS = valued("map_decorations");
+ public static final DataComponentType.Valued<MapPostProcessing> MAP_POST_PROCESSING = valued("map_post_processing");
+ public static final DataComponentType.Valued<ChargedProjectiles> CHARGED_PROJECTILES = valued("charged_projectiles");
+ // bundle_contents
+ // potion_contents
+ // suspicious_stew_effects
+ public static final DataComponentType.Valued<BundleContents> BUNDLE_CONTENTS = valued("bundle_contents");
+ public static final DataComponentType.Valued<PotionContents> POTION_CONTENTS = valued("potion_contents");
+ public static final DataComponentType.Valued<SuspiciousStewEffects> SUSPICIOUS_STEW_EFFECTS = valued("suspicious_stew_effects");
+ // writable_book_content
+ // written_book_content
+ // trim
@ -96,20 +110,20 @@ index 0000000000000000000000000000000000000000..cfd23f6b3559354c1b3e875649b86dd2
+ // block_entity_data
+ // instrument
+ public static final DataComponentType.Valued<Integer> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
+ // recipes
+ public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
+ // lodestone_tracker
+ // firework_explosion
+ // fireworks
+ // profile
+ // note_block_sound
+ // banner_patterns
+ // base_color
+ public static final DataComponentType.Valued<DyeColor> BASE_COLOR = valued("base_color");
+ public static final DataComponentType.Valued<PotDecorations> POT_DECORATIONS = valued("pot_decorations");
+ // container
+ // block_state
+ // bees
+ // lock
+ // container_loot
+ public static final DataComponentType.Valued<SeededContainerLoot> CONTAINER_LOOT = valued("container_loot");
+
+ private static DataComponentType.NonValued unvalued(final String name) {
+ return (DataComponentType.NonValued) Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name));
@ -319,6 +333,47 @@ index 0000000000000000000000000000000000000000..325a597b8d3e0c574b7bc80b7c9d0dee
+// 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..76fcaaaf9057f9d8251ef0bf6da389f7e1fdd523
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/BundleContents.java
@@ -0,0 +1,35 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.NonExtendable
+public interface BundleContents {
+
+ @Contract(value = "-> new", pure = true)
+ static BundleContents.@NotNull Builder bundleContents() {
+ return ComponentTypesBridge.Holder.bridge().bundleContents();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull @Unmodifiable List<ItemStack> getItems();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder add(@NotNull ItemStack itemStack);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder addAll(@NotNull List<ItemStack> itemStack);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..71c08d84678638ce57348631e9d950d9f2acb1d6
@ -364,14 +419,16 @@ index 0000000000000000000000000000000000000000..71c08d84678638ce57348631e9d950d9
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java
new file mode 100644
index 0000000000000000000000000000000000000000..03023338725b3de04f940f83845ccf42e9c3b3a4
index 0000000000000000000000000000000000000000..4df4c250945f8af2e48f1fddb883256dd50e5012
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridge.java
@@ -0,0 +1,30 @@
@@ -0,0 +1,56 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.Optional;
+import net.kyori.adventure.util.Services;
+import org.bukkit.map.MapCursor;
+import org.bukkit.potion.PotionEffect;
+import org.jetbrains.annotations.ApiStatus;
+
+@ApiStatus.Internal
@ -389,6 +446,30 @@ index 0000000000000000000000000000000000000000..03023338725b3de04f940f83845ccf42
+
+ ItemAttributeModifiers.Builder modifiers();
+
+ FoodProperties.Builder food();
+
+ FoodProperties.PossibleEffect foodEffect(PotionEffect effect, float probability);
+
+ DyedItemColor.Builder dyedItemColor();
+
+ PotionContents.Builder potionContents();
+
+ BundleContents.Builder bundleContents();
+
+ CustomModelData.Builder customModelData();
+
+ SuspiciousStewEffects.Builder suspiciousStewEffects();
+
+ BundleContents.Builder mapItemColor();
+
+ MapID.Builder mapId();
+
+ MapDecorations.Builder mapDecorations();
+
+ MapDecorations.DecorationEntry decorationEntry(MapCursor.Type type, double x, double z, float rotation);
+
+ SeededContainerLoot.Builder seededContainerLoot();
+
+ @ApiStatus.Internal
+ final class Holder {
+ private static final Optional<ComponentTypesBridge> BRIDGE = Services.service(ComponentTypesBridge.class);
@ -398,6 +479,147 @@ index 0000000000000000000000000000000000000000..03023338725b3de04f940f83845ccf42
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java b/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java
new file mode 100644
index 0000000000000000000000000000000000000000..e76925085a45b2eccc5fe9ce03cbc15ba11d109a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/CustomModelData.java
@@ -0,0 +1,27 @@
+package io.papermc.paper.datakey.types;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+
+@ApiStatus.NonExtendable
+public interface CustomModelData {
+
+ @Contract(value = "-> new", pure = true)
+ static CustomModelData.@NotNull Builder customModelData() {
+ return ComponentTypesBridge.Holder.bridge().customModelData();
+ }
+
+ int data();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder customModelData(int data);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull 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
new file mode 100644
index 0000000000000000000000000000000000000000..fc70603f05c115db845dae498bdf9fe419fad220
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/DyedItemColor.java
@@ -0,0 +1,30 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.Color;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+
+@ApiStatus.NonExtendable
+public interface DyedItemColor extends ShownInTooltip<DyedItemColor> {
+
+ @Contract(value = "-> new", pure = true)
+ static DyedItemColor.@NotNull Builder dyedItemColor() {
+ return ComponentTypesBridge.Holder.bridge().dyedItemColor();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull Color color();
+
+ @ApiStatus.NonExtendable
+ interface Builder extends ShownInTooltip.Builder<Builder> {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder color(@NotNull Color color);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..a4be568244eaedc32fa2d9f1e0a5d9107cc864d8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/FoodProperties.java
@@ -0,0 +1,66 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.List;
+import org.bukkit.potion.PotionEffect;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.NonExtendable
+public interface FoodProperties {
+
+ @Contract(value = "-> new", pure = true)
+ static FoodProperties.@NotNull Builder food() { // can't name it just "enchantments"
+ return ComponentTypesBridge.Holder.bridge().food();
+ }
+
+ int nutrition();
+
+ float saturation();
+
+ boolean canAlwaysEat();
+
+ float eatSeconds();
+
+ @Unmodifiable @NotNull List<PossibleEffect> effects();
+
+ @ApiStatus.NonExtendable
+ interface PossibleEffect {
+
+ @NotNull
+ static PossibleEffect of(@NotNull PotionEffect effect, float probability) {
+ return ComponentTypesBridge.Holder.bridge().foodEffect(effect, probability);
+ }
+
+ @NotNull
+ PotionEffect effect();
+
+ @NotNull
+ float probability();
+
+ }
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_, _ -> this", mutates = "this")
+ @NotNull Builder canAlwaysEat(boolean canAlwaysEat);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder eatSeconds(float eatSeconds);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder saturation(float saturation);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder nutrition(int nutrition);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder addEffect(@NotNull PossibleEffect effect);
+
+ @Contract(value="-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..818d2abb16d35fdb2830f3cbde4a63a6ea317bbe
@ -532,6 +754,149 @@ index 0000000000000000000000000000000000000000..9b2ffe96abfe7312be86736c306dc98b
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java b/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b1d2baa978768bf74e87c47fca32edb2f6fd2c1
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/MapDecorations.java
@@ -0,0 +1,55 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.List;
+import java.util.Optional;
+import io.papermc.paper.potion.SuspiciousEffectEntry;
+import org.bukkit.map.MapCursor;
+import org.bukkit.potion.PotionEffect;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.NonExtendable
+public interface MapDecorations {
+
+ @Contract(value = "-> new", pure = true)
+ static MapDecorations.@NotNull Builder mapDecorations() {
+ return ComponentTypesBridge.Holder.bridge().mapDecorations();
+ }
+
+ @Nullable DecorationEntry getDecoration(@NotNull String id);
+
+ @ApiStatus.NonExtendable
+ interface DecorationEntry {
+
+ @NotNull
+ static DecorationEntry of(@NotNull MapCursor.Type type, double x, double z, float rotation) {
+ return ComponentTypesBridge.Holder.bridge().decorationEntry(type, x, z, rotation);
+ }
+
+ @NotNull
+ MapCursor.Type type();
+
+ double x();
+
+ double z();
+
+ float rotation();
+
+ }
+
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull
+ MapDecorations.Builder register(@NotNull String id, @NotNull DecorationEntry entry);
+
+ @Contract(value="-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..0d74917b515c789317be059236837181dde01aca
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/MapID.java
@@ -0,0 +1,28 @@
+package io.papermc.paper.datakey.types;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+
+@ApiStatus.NonExtendable
+public interface MapID {
+
+ @Contract(value = "-> new", pure = true)
+ static MapID.@NotNull Builder mapId() {
+ return ComponentTypesBridge.Holder.bridge().mapId();
+ }
+
+ int id();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder mapId(int id);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull
+ MapID build();
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java b/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c564fcce47a2db0de16c0c44dd35a1e4b219515
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/MapItemColor.java
@@ -0,0 +1,30 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.Color;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+
+@ApiStatus.NonExtendable
+public interface MapItemColor {
+
+ @Contract(value = "-> new", pure = true)
+ static BundleContents.@NotNull Builder mapItemColor() {
+ return ComponentTypesBridge.Holder.bridge().mapItemColor();
+ }
+
+ @NotNull
+ Color mapColor();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull Builder mapColor(@NotNull Color color);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull
+ MapItemColor build();
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java b/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java
new file mode 100644
index 0000000000000000000000000000000000000000..e803c5eadf8bd2db645c3bf0a7d8935ec9e5b53e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/MapPostProcessing.java
@@ -0,0 +1,6 @@
+package io.papermc.paper.datakey.types;
+
+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
new file mode 100644
index 0000000000000000000000000000000000000000..07be7fbab96d000c7a4f73ee00561b0a720cd09b
@ -588,6 +953,107 @@ index 0000000000000000000000000000000000000000..07be7fbab96d000c7a4f73ee00561b0a
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/PotionContents.java b/src/main/java/io/papermc/paper/datakey/types/PotionContents.java
new file mode 100644
index 0000000000000000000000000000000000000000..ef9c5b09a59f63de616e98c71a8caf667816b984
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PotionContents.java
@@ -0,0 +1,47 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.List;
+import org.bukkit.Color;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.NonExtendable
+public interface PotionContents {
+
+ @Contract(value = "-> new", pure = true)
+ static PotionContents.@NotNull Builder potionContents() { // can't name it just "enchantments"
+ return ComponentTypesBridge.Holder.bridge().potionContents();
+ }
+
+ @Nullable PotionType potion();
+
+ @Nullable Color customColor();
+
+ @Unmodifiable @NotNull List<PotionEffect> customEffects();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_, _ -> this", mutates = "this")
+ @NotNull Builder potion(@Nullable PotionType potionType);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder customColor(@Nullable Color color);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder addAll(@NotNull List<PotionEffect> potionEffects);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder add(@NotNull PotionEffect potionEffect);
+
+
+ @Contract(value="-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..2607f35f72c8ab5226e0d5559c5f126a3b2ed936
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/SeededContainerLoot.java
@@ -0,0 +1,42 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.List;
+import io.papermc.paper.registry.RegistryKey;
+import io.papermc.paper.registry.TypedKey;
+import net.kyori.adventure.key.Key;
+import org.bukkit.Color;
+import org.bukkit.loot.LootTable;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+@ApiStatus.NonExtendable
+public interface SeededContainerLoot {
+
+ @Contract(value = "-> new", pure = true)
+ static SeededContainerLoot.@NotNull Builder seededContainerLoot() {
+ return ComponentTypesBridge.Holder.bridge().seededContainerLoot();
+ }
+
+ @NotNull Key lootTable();
+
+ long seed();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder lootTable(@NotNull Key key);
+
+ @Contract(value = "_, -> this", mutates = "this")
+ @NotNull Builder seed(@NotNull long seed);
+
+ @Contract(value="-> new", pure = true)
+ @NotNull
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..ac3fe6bee4423341ac7fa56b88c38b8c2e7cc3f6
@ -610,6 +1076,50 @@ index 0000000000000000000000000000000000000000..ac3fe6bee4423341ac7fa56b88c38b8c
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..3c8d0a88607d313e0ff55393b5a556f393414632
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/SuspiciousStewEffects.java
@@ -0,0 +1,38 @@
+package io.papermc.paper.datakey.types;
+
+import io.papermc.paper.potion.SuspiciousEffectEntry;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Unmodifiable;
+import java.util.List;
+
+@ApiStatus.NonExtendable
+public interface SuspiciousStewEffects {
+
+ @Contract(value = "-> new", pure = true)
+ static SuspiciousStewEffects.@NotNull Builder suspiciousStewEffects() {
+ return ComponentTypesBridge.Holder.bridge().suspiciousStewEffects();
+ }
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull @Unmodifiable
+ List<SuspiciousEffectEntry> getEntries();
+
+ @ApiStatus.NonExtendable
+ interface Builder {
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull
+ Builder add(@NotNull SuspiciousEffectEntry entry);
+
+ @Contract(value = "_ -> this", mutates = "this")
+ @NotNull
+ Builder addAll(@NotNull List<SuspiciousEffectEntry> entries);
+
+ @Contract(value = "-> new", pure = true)
+ @NotNull
+ SuspiciousStewEffects build();
+
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/Unbreakable.java b/src/main/java/io/papermc/paper/datakey/types/Unbreakable.java
new file mode 100644
index 0000000000000000000000000000000000000000..1fe6d7a9a552f9150e8519d8707a4149b0036e4d

View file

@ -436,12 +436,15 @@ index 0000000000000000000000000000000000000000..e6ebc39e96c9eb6f9869cfff258d4e25
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..1eb1ea0f64ce990c6740c070ec9ab45900a6eb36
index 0000000000000000000000000000000000000000..c32cd7bf77028a612dce8ab7d372374fa9f8eb78
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/ComponentTypesBridgesImpl.java
@@ -0,0 +1,34 @@
@@ -0,0 +1,97 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.map.MapCursor;
+import org.bukkit.potion.PotionEffect;
+
+public final class ComponentTypesBridgesImpl implements ComponentTypesBridge {
+
+ @Override
@ -473,7 +476,128 @@ index 0000000000000000000000000000000000000000..1eb1ea0f64ce990c6740c070ec9ab459
+ public ItemAttributeModifiers.Builder modifiers() {
+ return new PaperItemAttributeModifiers.BuilderImpl();
+ }
+
+ @Override
+ public FoodProperties.Builder food() {
+ return new PaperFoodProperties.BuilderImpl();
+ }
+
+ @Override
+ public FoodProperties.PossibleEffect foodEffect(final PotionEffect effect, final float probability) {
+ return PaperFoodProperties.PossibleEffectImpl.toApi(effect, probability);
+ }
+
+ @Override
+ public DyedItemColor.Builder dyedItemColor() {
+ return new PaperDyedItemColor.BuilderImpl();
+ }
+
+ @Override
+ public PotionContents.Builder potionContents() {
+ return new PaperPotionContents.BuilderImpl();
+ }
+
+ @Override
+ public BundleContents.Builder bundleContents() {
+ return new PaperBundleContents.BuilderImpl();
+ }
+
+ @Override
+ public CustomModelData.Builder customModelData() {
+ return new PaperCustomModelData.BuilderImpl();
+ }
+
+ @Override
+ public SuspiciousStewEffects.Builder suspiciousStewEffects() {
+ return new PaperSuspiciousStewEffects.BuilderImpl();
+ }
+
+ @Override
+ public BundleContents.Builder mapItemColor() {
+ return new PaperBundleContents.BuilderImpl();
+ }
+
+ @Override
+ public MapID.Builder mapId() {
+ return new PaperMapID.BuilderImpl();
+ }
+
+ @Override
+ public MapDecorations.Builder mapDecorations() {
+ return new PaperMapDecorations.BuilderImpl();
+ }
+
+ @Override
+ public MapDecorations.DecorationEntry decorationEntry(final MapCursor.Type type, final double x, final double z, final float rotation) {
+ return PaperMapDecorations.PaperDecorationEntry.toApi(type, x, z, rotation);
+ }
+
+ @Override
+ public SeededContainerLoot.Builder seededContainerLoot() {
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..c0e9f1df6c9cb28796fe794988b06b01e4ea335a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperBundleContents.java
@@ -0,0 +1,55 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.bukkit.inventory.ItemStack;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+@DefaultQualifier(NonNull.class)
+public record PaperBundleContents(net.minecraft.world.item.component.BundleContents impl) implements BundleContents, Handleable<net.minecraft.world.item.component.BundleContents> {
+
+ @Override
+ public net.minecraft.world.item.component.BundleContents getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @NotNull List<ItemStack> getItems() {
+ final Iterable<net.minecraft.world.item.ItemStack> nmsItemStacks = this.impl.itemsCopy(); // gets copies of the stacks
+ final List<ItemStack> apiItemStacks = new ArrayList<>(this.impl.size());
+ for (final net.minecraft.world.item.ItemStack nmsItemStack : nmsItemStacks) {
+ apiItemStacks.add(CraftItemStack.asCraftMirror(nmsItemStack.copy()));
+ }
+
+ return Collections.unmodifiableList(apiItemStacks);
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private final List<net.minecraft.world.item.ItemStack> items = new ArrayList<>();
+
+ @Override
+ public Builder add(final ItemStack itemStack) {
+ this.items.add(CraftItemStack.asNMSCopy(itemStack));
+ return this;
+ }
+
+ @Override
+ public Builder addAll(final List<ItemStack> itemStack) {
+ for (ItemStack item : itemStack) {
+ this.items.add(CraftItemStack.asNMSCopy(item));
+ }
+ return this;
+ }
+
+ @Override
+ public BundleContents build() {
+ return new PaperBundleContents(new net.minecraft.world.item.component.BundleContents(this.items));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperChargedProjectiles.java b/src/main/java/io/papermc/paper/datakey/types/PaperChargedProjectiles.java
new file mode 100644
index 0000000000000000000000000000000000000000..c099da3817c20fd7b355c77e8fdbf9aa4f261518
@ -541,6 +665,241 @@ index 0000000000000000000000000000000000000000..c099da3817c20fd7b355c77e8fdbf9aa
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java b/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6fcce7469a78f1e3be1c7a63195ac6a960b82e0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperCustomModelData.java
@@ -0,0 +1,38 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.craftbukkit.util.Handleable;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+
+@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 Builder {
+
+ private int data;
+
+ @Override
+ public @NotNull Builder customModelData(final int data) {
+ this.data = data;
+ return this;
+ }
+
+ @Override
+ public @NotNull CustomModelData build() {
+ return new PaperCustomModelData(new net.minecraft.world.item.component.CustomModelData(this.data));
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java b/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java
new file mode 100644
index 0000000000000000000000000000000000000000..c846fbca52f8465d2658618b27ede1521e2749e9
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperDyedItemColor.java
@@ -0,0 +1,56 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.Color;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+
+@DefaultQualifier(NonNull.class)
+public record PaperDyedItemColor(
+ net.minecraft.world.item.component.DyedItemColor impl
+) implements DyedItemColor, Handleable<net.minecraft.world.item.component.DyedItemColor> {
+
+ @Override
+ public net.minecraft.world.item.component.DyedItemColor getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @NotNull Color color() {
+ return Color.fromRGB(this.impl.rgb());
+ }
+
+ @Override
+ public boolean showInTooltip() {
+ return this.impl.showInTooltip();
+ }
+
+ @Override
+ public DyedItemColor showInTooltip(final boolean showInTooltip) {
+ return new PaperDyedItemColor(new net.minecraft.world.item.component.DyedItemColor(this.impl.rgb(), showInTooltip));
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private Color color = Color.WHITE;
+ private boolean showInToolTip = true;
+
+ @Override
+ public @NotNull Builder color(@NotNull final Color color) {
+ this.color = color;
+ return this;
+ }
+
+ @Override
+ public Builder showInTooltip(final boolean showInTooltip) {
+ this.showInToolTip = showInTooltip;
+ return this;
+ }
+
+ @Override
+ public @NotNull DyedItemColor build() {
+ return new PaperDyedItemColor(new net.minecraft.world.item.component.DyedItemColor(this.color.asRGB(), this.showInToolTip));
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java b/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..b695b80c81eb57369713a2b17c6ed0bd95564f1f
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperFoodProperties.java
@@ -0,0 +1,123 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.bukkit.craftbukkit.CraftEffect;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Unmodifiable;
+
+@DefaultQualifier(NonNull.class)
+public record PaperFoodProperties(net.minecraft.world.food.FoodProperties impl) implements FoodProperties, Handleable<net.minecraft.world.food.FoodProperties> {
+
+ @Override
+ public int nutrition() {
+ return this.impl.nutrition();
+ }
+
+ @Override
+ public float saturation() {
+ return this.impl.saturation();
+ }
+
+ @Override
+ public boolean canAlwaysEat() {
+ return this.impl.canAlwaysEat();
+ }
+
+ @Override
+ public float eatSeconds() {
+ return this.impl.eatSeconds();
+ }
+
+ @Override
+ public @Unmodifiable @NotNull List<PossibleEffect> effects() {
+ final List<net.minecraft.world.food.FoodProperties.PossibleEffect> nms = this.impl.effects();
+ final List<PossibleEffect> api = new ArrayList<>(nms.size());
+ for (final net.minecraft.world.food.FoodProperties.PossibleEffect effect : nms) {
+ api.add(new PossibleEffectImpl(effect));
+ }
+
+ return Collections.unmodifiableList(api);
+ }
+
+ @Override
+ public net.minecraft.world.food.FoodProperties getHandle() {
+ return this.impl;
+ }
+
+ record PossibleEffectImpl(net.minecraft.world.food.FoodProperties.PossibleEffect possibleEffect) implements PossibleEffect, Handleable<net.minecraft.world.food.FoodProperties.PossibleEffect> {
+
+ public static PossibleEffect toApi(PotionEffect effect, float probability) {
+ return new PossibleEffectImpl(new net.minecraft.world.food.FoodProperties.PossibleEffect(CraftPotionUtil.fromBukkit(effect), probability));
+ }
+
+ @Override
+ public @NotNull PotionEffect effect() {
+ return CraftPotionUtil.toBukkit(this.possibleEffect.effect());
+ }
+
+ @Override
+ public @NotNull float probability() {
+ return this.possibleEffect.probability();
+ }
+
+ @Override
+ public net.minecraft.world.food.FoodProperties.PossibleEffect getHandle() {
+ return this.possibleEffect;
+ }
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private final List<net.minecraft.world.food.FoodProperties.PossibleEffect> possibleEffects = new ArrayList<>();
+ private boolean canAlwaysEat = false;
+ private float eatSeconds = net.minecraft.world.food.FoodProperties.DEFAULT_EAT_SECONDS;
+ private float saturation = 0;
+ private int nutrition = 0;
+
+ @Override
+ public @NotNull Builder canAlwaysEat(final boolean canAlwaysEat) {
+ this.canAlwaysEat = canAlwaysEat;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder eatSeconds(final float eatSeconds) {
+ this.eatSeconds = eatSeconds;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder saturation(final float saturation) {
+ this.saturation = saturation;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder nutrition(final int nutrition) {
+ this.nutrition = nutrition;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder addEffect(@NotNull final PossibleEffect effect) {
+ this.possibleEffects.add(((PossibleEffectImpl) effect).possibleEffect());
+ return this;
+ }
+
+ @Override
+ public @NotNull FoodProperties build() {
+ return new PaperFoodProperties(new net.minecraft.world.food.FoodProperties(this.nutrition, this.saturation, this.canAlwaysEat, this.eatSeconds, this.possibleEffects));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datakey/types/PaperItemAttributeModifiers.java
new file mode 100644
index 0000000000000000000000000000000000000000..cea05ee86cfc8e833226983cf458c19751f47385
@ -795,6 +1154,178 @@ 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
new file mode 100644
index 0000000000000000000000000000000000000000..518b2b4acda353de40aea683d5ad8352d8e0ce8b
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapDecorations.java
@@ -0,0 +1,76 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import org.bukkit.craftbukkit.map.CraftMapCursor;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.bukkit.map.MapCursor;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+@DefaultQualifier(NonNull.class)
+public record PaperMapDecorations(
+ net.minecraft.world.item.component.MapDecorations impl
+) implements MapDecorations, Handleable<net.minecraft.world.item.component.MapDecorations> {
+
+ @Override
+ public net.minecraft.world.item.component.MapDecorations getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @Nullable DecorationEntry getDecoration(@NotNull final String id) {
+ net.minecraft.world.item.component.MapDecorations.Entry decoration = this.impl.decorations().get(id);
+ if (decoration == null) {
+ return null;
+ }
+
+ return new PaperDecorationEntry(decoration);
+ }
+
+ public record PaperDecorationEntry(net.minecraft.world.item.component.MapDecorations.Entry entry) implements DecorationEntry {
+
+ public static DecorationEntry toApi(MapCursor.Type type, double x, double z, float rotation) {
+ return new PaperDecorationEntry(new net.minecraft.world.item.component.MapDecorations.Entry(CraftMapCursor.CraftType.bukkitToMinecraftHolder(type), x, z, rotation));
+ }
+
+ @Override
+ public @NotNull MapCursor.Type type() {
+ return CraftMapCursor.CraftType.minecraftHolderToBukkit(this.entry.type());
+ }
+
+ @Override
+ public double x() {
+ return this.entry.x();
+ }
+
+ @Override
+ public double z() {
+ return this.entry.z();
+ }
+
+ @Override
+ public float rotation() {
+ return this.entry.rotation();
+ }
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private final Map<String, net.minecraft.world.item.component.MapDecorations.Entry> effects = new HashMap<>();
+
+ @Override
+ public @NotNull MapDecorations.Builder register(final String id, @NotNull final DecorationEntry entry) {
+ this.effects.put(id, new net.minecraft.world.item.component.MapDecorations.Entry(CraftMapCursor.CraftType.bukkitToMinecraftHolder(entry.type()), entry.x(), entry.z(), entry.rotation()));
+ return this;
+ }
+
+ @Override
+ public MapDecorations build() {
+ return new PaperMapDecorations(new net.minecraft.world.item.component.MapDecorations(this.effects));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java b/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java
new file mode 100644
index 0000000000000000000000000000000000000000..ab6b36f01fc0efe15be0468bd198c8faef208ee7
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapID.java
@@ -0,0 +1,39 @@
+package io.papermc.paper.datakey.types;
+
+import net.minecraft.world.level.saveddata.maps.MapId;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+
+@DefaultQualifier(NonNull.class)
+public record PaperMapID(
+ MapId impl
+) implements MapID, Handleable<MapId> {
+
+ @Override
+ public MapId getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public int id() {
+ return this.impl.id();
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private int id = 0;
+
+ @Override
+ public @NotNull Builder mapId(final int id) {
+ this.id = id;
+ return this;
+ }
+
+ @Override
+ public @NotNull MapID build() {
+ return new PaperMapID(new MapId(this.id));
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java b/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java
new file mode 100644
index 0000000000000000000000000000000000000000..53559f54971997d4ea72d12884796aadb9308794
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperMapItemColor.java
@@ -0,0 +1,39 @@
+package io.papermc.paper.datakey.types;
+
+import org.bukkit.Color;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+
+@DefaultQualifier(NonNull.class)
+public record PaperMapItemColor(
+ net.minecraft.world.item.component.MapItemColor impl
+) implements MapItemColor, Handleable<net.minecraft.world.item.component.MapItemColor> {
+
+ @Override
+ public net.minecraft.world.item.component.MapItemColor getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @NotNull Color mapColor() {
+ return Color.fromRGB(this.impl.rgb());
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private Color color = Color.WHITE;
+
+ @Override
+ public @NotNull Builder mapColor(@NotNull final Color color) {
+ this.color = color;
+ return this;
+ }
+
+ @Override
+ public @NotNull MapItemColor build() {
+ return new PaperMapItemColor(new net.minecraft.world.item.component.MapItemColor(this.color.asRGB()));
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperPotDecorations.java b/src/main/java/io/papermc/paper/datakey/types/PaperPotDecorations.java
new file mode 100644
index 0000000000000000000000000000000000000000..7b00677f61d6815505b4542d5979471f0b4e57f8
@ -883,6 +1414,250 @@ index 0000000000000000000000000000000000000000..7b00677f61d6815505b4542d5979471f
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java b/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d3e6a97f56dee5d702bcf1536b2276506cc30f7
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperPotionContents.java
@@ -0,0 +1,96 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Function;
+import net.minecraft.core.Holder;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.item.alchemy.Potion;
+import org.bukkit.Color;
+import org.bukkit.craftbukkit.potion.CraftPotionType;
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionType;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+@DefaultQualifier(NonNull.class)
+public record PaperPotionContents(net.minecraft.world.item.alchemy.PotionContents impl) implements PotionContents, Handleable<net.minecraft.world.item.alchemy.PotionContents> {
+
+ @Override
+ public net.minecraft.world.item.alchemy.PotionContents getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @Nullable PotionType potion() {
+ return this.impl.potion()
+ .map(CraftPotionType::minecraftHolderToBukkit)
+ .orElse(null);
+ }
+
+ @Override
+ public @Nullable Color customColor() {
+ return this.impl.customColor()
+ .map(Color::fromRGB)
+ .orElse(null);
+ }
+
+ @Override
+ public @Unmodifiable @NotNull List<PotionEffect> customEffects() {
+ final List<MobEffectInstance> nms = this.impl.customEffects();
+ final List<PotionEffect> api = new ArrayList<>(nms.size());
+ for (final MobEffectInstance effect : nms) {
+ api.add(CraftPotionUtil.toBukkit(effect));
+ }
+
+ return Collections.unmodifiableList(api);
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private @Nullable PotionType type;
+ private @Nullable Color color;
+ private @NotNull List<MobEffectInstance> potionEffects = new ArrayList<>();
+
+ @Override
+ public @NotNull Builder potion(@Nullable final PotionType potionType) {
+ this.type = potionType;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder customColor(@Nullable final Color color) {
+ this.color = color;
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder addAll(@NotNull final List<PotionEffect> potionEffects) {
+ potionEffects.forEach(this::add);
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder add(@NotNull final PotionEffect potionEffect) {
+ this.potionEffects.add(CraftPotionUtil.fromBukkit(potionEffect));
+ return this;
+ }
+
+ @Override
+ public @NotNull PotionContents build() {
+ return new PaperPotionContents(new net.minecraft.world.item.alchemy.PotionContents(
+ Optional.ofNullable(this.type).map(CraftPotionType::bukkitToMinecraftHolder),
+ Optional.ofNullable(this.color).map(Color::asARGB),
+ this.potionEffects
+ ));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java b/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java
new file mode 100644
index 0000000000000000000000000000000000000000..24ee501b802ceb5beea23168077cfaa2589ec4dd
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperSeededContainerLoot.java
@@ -0,0 +1,72 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import io.papermc.paper.registry.PaperRegistries;
+import io.papermc.paper.registry.RegistryKey;
+import io.papermc.paper.registry.TypedKey;
+import net.kyori.adventure.key.Key;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.effect.MobEffectInstance;
+import org.bukkit.Color;
+import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.potion.CraftPotionType;
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.bukkit.loot.LootTable;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionType;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+@DefaultQualifier(NonNull.class)
+public record PaperSeededContainerLoot(net.minecraft.world.item.component.SeededContainerLoot impl) implements SeededContainerLoot, Handleable<net.minecraft.world.item.component.SeededContainerLoot> {
+
+ @Override
+ public net.minecraft.world.item.component.SeededContainerLoot getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @NotNull Key lootTable() {
+ return CraftNamespacedKey.fromMinecraft(this.impl.lootTable().location());
+ }
+
+ @Override
+ public long seed() {
+ return this.impl.seed();
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private long seed = 0;
+ private NamespacedKey lootTableRegistryKey;
+
+ @Override
+ public @NotNull Builder lootTable(@NotNull final Key key) {
+ this.lootTableRegistryKey = new NamespacedKey(key.namespace(), key.value());
+ return this;
+ }
+
+ @Override
+ public @NotNull Builder seed(@NotNull final long seed) {
+ this.seed = seed;
+ return this;
+ }
+
+ @Override
+ public @NotNull SeededContainerLoot build() {
+ return new PaperSeededContainerLoot(new net.minecraft.world.item.component.SeededContainerLoot(
+ ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(this.lootTableRegistryKey)),
+ this.seed
+ ));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java
new file mode 100644
index 0000000000000000000000000000000000000000..a462ea7ec881f07684b3ed13aa6fb6fd36e96555
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datakey/types/PaperSuspiciousStewEffects.java
@@ -0,0 +1,58 @@
+package io.papermc.paper.datakey.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import io.papermc.paper.potion.SuspiciousEffectEntry;
+import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
+import org.bukkit.craftbukkit.util.Handleable;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.NotNull;
+
+@DefaultQualifier(NonNull.class)
+public record PaperSuspiciousStewEffects(
+ net.minecraft.world.item.component.SuspiciousStewEffects impl
+) implements SuspiciousStewEffects, Handleable<net.minecraft.world.item.component.SuspiciousStewEffects> {
+
+ @Override
+ public net.minecraft.world.item.component.SuspiciousStewEffects getHandle() {
+ return this.impl;
+ }
+
+ @Override
+ public @NotNull List<SuspiciousEffectEntry> getEntries() {
+ final List<net.minecraft.world.item.component.SuspiciousStewEffects.Entry> nms = this.impl.effects(); // gets copies of the stacks
+ final List<SuspiciousEffectEntry> api = new ArrayList<>(nms.size());
+ for (final net.minecraft.world.item.component.SuspiciousStewEffects.Entry entry : nms) {
+ api.add(SuspiciousEffectEntry.create(CraftPotionEffectType.minecraftHolderToBukkit(entry.effect()), entry.duration()));
+ }
+
+ return Collections.unmodifiableList(api);
+ }
+
+ static final class BuilderImpl implements Builder {
+
+ private final List<net.minecraft.world.item.component.SuspiciousStewEffects.Entry> effects = new ArrayList<>();
+
+ @Override
+ public Builder add(final SuspiciousEffectEntry itemStack) {
+ this.effects.add(new net.minecraft.world.item.component.SuspiciousStewEffects.Entry(
+ org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(itemStack.effect()),
+ itemStack.duration()
+ ));
+ return this;
+ }
+
+ @Override
+ public Builder addAll(final List<SuspiciousEffectEntry> itemStack) {
+ itemStack.forEach(this::add);
+ return this;
+ }
+
+ @Override
+ public SuspiciousStewEffects build() {
+ return new PaperSuspiciousStewEffects(new net.minecraft.world.item.component.SuspiciousStewEffects(this.effects));
+ }
+ }
+ }
diff --git a/src/main/java/io/papermc/paper/datakey/types/PaperUnbreakable.java b/src/main/java/io/papermc/paper/datakey/types/PaperUnbreakable.java
new file mode 100644
index 0000000000000000000000000000000000000000..8af596088fe4dd7d81f6d4d4ebf4c37121b442cb

View file

@ -5,7 +5,7 @@ Subject: [PATCH] fixup! Test changes
diff --git a/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java b/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java
index 4f3534f76cf6722c8a13076f26b11b1ff2a5aa28..70310b8af0f10abbccc76efe60bced009e80e426 100644
index 4f3534f76cf6722c8a13076f26b11b1ff2a5aa28..922084742c0f1021e2e77b5230ec39086e2d6131 100644
--- a/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java
+++ b/src/main/java/io/papermc/paper/datakey/ComponentAdapters.java
@@ -24,7 +24,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@ -17,19 +17,6 @@ index 4f3534f76cf6722c8a13076f26b11b1ff2a5aa28..70310b8af0f10abbccc76efe60bced00
throw new UnsupportedOperationException("Cannot convert the Unit type to an API value");
};
@@ -52,6 +52,12 @@ public final class ComponentAdapters {
register(DataComponents.ENCHANTMENTS, PaperItemEnchantments::new);
register(DataComponents.STORED_ENCHANTMENTS, PaperItemEnchantments::new);
register(DataComponents.ATTRIBUTE_MODIFIERS, PaperItemAttributeModifiers::new);
+ // TODO: REMOVE THIS... we want to build the PR... so lets just make things UNTYPED!
+ for (Map.Entry<ResourceKey<DataComponentType<?>>, DataComponentType<?>> componentType : BuiltInRegistries.DATA_COMPONENT_TYPE.entrySet()) {
+ if (!ADAPTERS.containsKey(componentType.getKey())) {
+ registerUntyped((DataComponentType<Unit>) componentType.getValue());
+ }
+ }
}
public static void registerUntyped(final DataComponentType<Unit> type) {
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