Fix jukebox component (#11642)
Dieser Commit ist enthalten in:
Ursprung
915637df5c
Commit
751e9bd125
@ -158,7 +158,7 @@ index 0000000000000000000000000000000000000000..e2266d86a4dd1bf20346e48c428f8baf
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e79737ae012179fc7c89b14af8801b8b09fa042b
|
||||
index 0000000000000000000000000000000000000000..68284abd5c4358617ee7766101e942f81a001e2c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
||||
@@ -0,0 +1,344 @@
|
||||
@ -322,9 +322,9 @@ index 0000000000000000000000000000000000000000..e79737ae012179fc7c89b14af8801b8b
|
||||
+ * If not present, has an implicit default value of: {@code 0}.
|
||||
+ */
|
||||
+ public static final DataComponentType.Valued<@NonNegative Integer> REPAIR_COST = valued("repair_cost");
|
||||
+ /**
|
||||
+ * Causes an item to not be pickable in the creative menu, currently not very useful.
|
||||
+ */
|
||||
+ // /**
|
||||
+ // * Causes an item to not be pickable in the creative menu, currently not very useful.
|
||||
+ // */
|
||||
+ // public static final DataComponentType.NonValued CREATIVE_SLOT_LOCK = unvalued("creative_slot_lock");
|
||||
+ /**
|
||||
+ * Overrides the enchantment glint effect on an item.
|
||||
@ -508,14 +508,13 @@ index 0000000000000000000000000000000000000000..e79737ae012179fc7c89b14af8801b8b
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12cfae82234b8c4cb231ab91e72ad82d28b85183
|
||||
index 0000000000000000000000000000000000000000..785b5db96bb5a0584647f2ed41fcd882ab6b3250
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BannerPatternLayers.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,65 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.block.banner.Pattern;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -637,14 +636,13 @@ index 0000000000000000000000000000000000000000..65f1bc8d1bea0042dca9683c43956113
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c0f671aef8225c87632d2368d1b28fc8b1bce686
|
||||
index 0000000000000000000000000000000000000000..d47a78a6f51db66950ee67c60cfef1e21f4a4d40
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,65 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -709,14 +707,13 @@ index 0000000000000000000000000000000000000000..c0f671aef8225c87632d2368d1b28fc8
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d0a6e7db06f540e13ac00e8da3acabd9f7838f1f
|
||||
index 0000000000000000000000000000000000000000..aac079e1d8056ec02741386a1bf2e7adf592e5bd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,65 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -781,17 +778,16 @@ index 0000000000000000000000000000000000000000..d0a6e7db06f540e13ac00e8da3acabd9
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Consumable.java b/src/main/java/io/papermc/paper/datacomponent/item/Consumable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a448fedb63ffce18b9f6a1bd0fecfc5cd90224a6
|
||||
index 0000000000000000000000000000000000000000..8c88bbbeef179e6c6666d07c8b28157ee1e84a2b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Consumable.java
|
||||
@@ -0,0 +1,70 @@
|
||||
@@ -0,0 +1,69 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.BuildableDataComponent;
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
|
||||
+import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation;
|
||||
+import java.util.Collection;
|
||||
+import java.util.List;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import org.checkerframework.checker.index.qual.NonNegative;
|
||||
@ -927,16 +923,14 @@ index 0000000000000000000000000000000000000000..6cbd73cb2a11f4858b44a2f57d2fe0ac
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/DeathProtection.java b/src/main/java/io/papermc/paper/datacomponent/item/DeathProtection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..87c2220708af7db06348994ad5940c7cecd9f691
|
||||
index 0000000000000000000000000000000000000000..8a42550bb52d00d9b5df1a64e997e0762bffde59
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/DeathProtection.java
|
||||
@@ -0,0 +1,48 @@
|
||||
@@ -0,0 +1,46 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collection;
|
||||
+import java.util.List;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
@ -1040,7 +1034,7 @@ index 0000000000000000000000000000000000000000..d80581fc8b894cc4d4af9741244b1bb0
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Enchantable.java b/src/main/java/io/papermc/paper/datacomponent/item/Enchantable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5169b9cd73dc0ffc8297f8d5f63d3d707a47d279
|
||||
index 0000000000000000000000000000000000000000..a128348247d8845321d3fecebaa09a5175a923cc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Enchantable.java
|
||||
@@ -0,0 +1,31 @@
|
||||
@ -1069,18 +1063,18 @@ index 0000000000000000000000000000000000000000..5169b9cd73dc0ffc8297f8d5f63d3d70
|
||||
+ * Gets the current enchantment value level allowed,
|
||||
+ * a higher value allows enchantments with a higher cost to be picked.
|
||||
+ *
|
||||
+ * @see <a href="https://minecraft.wiki/w/Enchanting_mechanics#Java_Edition_2">Minecraft Wiki</a>
|
||||
+ * @return the value
|
||||
+ * @see <a href="https://minecraft.wiki/w/Enchanting_mechanics#Java_Edition_2">Minecraft Wiki</a>
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ @Positive int value();
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java b/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7d84217814bba4ce826e33755fee0d5c3b280009
|
||||
index 0000000000000000000000000000000000000000..826bb860bd55ff18f91d9bc7a5dde4d638b39f98
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java
|
||||
@@ -0,0 +1,170 @@
|
||||
@@ -0,0 +1,169 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.BuildableDataComponent;
|
||||
@ -1094,7 +1088,6 @@ index 0000000000000000000000000000000000000000..7d84217814bba4ce826e33755fee0d5c
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * Holds the equippable properties of an item.
|
||||
+ * @see io.papermc.paper.datacomponent.DataComponentTypes#EQUIPPABLE
|
||||
@ -1106,8 +1099,8 @@ index 0000000000000000000000000000000000000000..7d84217814bba4ce826e33755fee0d5c
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a new {@link Equippable.Builder} instance.
|
||||
+ * @param slot The slot for the new equippable to be equippable in.
|
||||
+ *
|
||||
+ * @param slot The slot for the new equippable to be equippable in.
|
||||
+ * @return a new builder
|
||||
+ */
|
||||
+ @Contract(value = "_ -> new", pure = true)
|
||||
@ -1190,11 +1183,11 @@ index 0000000000000000000000000000000000000000..7d84217814bba4ce826e33755fee0d5c
|
||||
+ /**
|
||||
+ * Sets the equip sound key for this item.
|
||||
+ *
|
||||
+ * @param equipSound the equip sound key
|
||||
+ * @param sound the equip sound key
|
||||
+ * @return the builder for chaining
|
||||
+ */
|
||||
+ @Contract(value = "_ -> this", mutates = "this")
|
||||
+ Builder equipSound(Key equipSound);
|
||||
+ Builder equipSound(Key sound);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the model key for this item.
|
||||
@ -1343,10 +1336,10 @@ index 0000000000000000000000000000000000000000..72aa1b4bda2693e0cd78d93449dda23b
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..369208e15a0e7fc91a9505fef2097c4283445e4a
|
||||
index 0000000000000000000000000000000000000000..2b94017d0310d023556bdd7b9ab1eae0261669c6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/FoodProperties.java
|
||||
@@ -0,0 +1,87 @@
|
||||
@@ -0,0 +1,86 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.BuildableDataComponent;
|
||||
@ -1431,7 +1424,6 @@ index 0000000000000000000000000000000000000000..369208e15a0e7fc91a9505fef2097c42
|
||||
+ */
|
||||
+ @Contract(value = "_ -> this", mutates = "this")
|
||||
+ Builder nutrition(@NonNegative int nutrition);
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAdventurePredicate.java
|
||||
@ -1566,10 +1558,10 @@ index 0000000000000000000000000000000000000000..0309ae59ab7945ddfb5410930d161e2c
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..948505d38121d54df62e6a67d4597bc7d42c356f
|
||||
index 0000000000000000000000000000000000000000..56a3e678c6658dd617da4974d9392006875aef0c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java
|
||||
@@ -0,0 +1,98 @@
|
||||
@@ -0,0 +1,97 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
@ -1584,7 +1576,6 @@ index 0000000000000000000000000000000000000000..948505d38121d54df62e6a67d4597bc7
|
||||
+
|
||||
+/**
|
||||
+ * Holds attribute modifiers applied to any item.
|
||||
+ *
|
||||
+ * @see io.papermc.paper.datacomponent.DataComponentTypes#ATTRIBUTE_MODIFIERS
|
||||
+ */
|
||||
+@NullMarked
|
||||
@ -1652,7 +1643,7 @@ index 0000000000000000000000000000000000000000..948505d38121d54df62e6a67d4597bc7
|
||||
+ * @return the builder for chaining
|
||||
+ * @see #modifiers()
|
||||
+ */
|
||||
+ @Contract(value = "_, _, _ -> this", mutates = "this")
|
||||
+ @Contract(value = "_, _ -> this", mutates = "this")
|
||||
+ Builder addModifier(Attribute attribute, AttributeModifier modifier);
|
||||
+
|
||||
+ /**
|
||||
@ -1788,14 +1779,13 @@ index 0000000000000000000000000000000000000000..1ce34642371a65590ce1ac74b402ccfc
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7d1c973ba566752d7a85496327b1352d973f2218
|
||||
index 0000000000000000000000000000000000000000..3b00e34a1d6aeec694c712d7a3a323da938f270b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemContainerContents.java
|
||||
@@ -0,0 +1,63 @@
|
||||
@@ -0,0 +1,62 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -2393,10 +2383,10 @@ index 0000000000000000000000000000000000000000..4f16e08f04c2cea24f3cb132ff21f4bd
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6da78b8735a6cadd1282fa2fafd8b0f74f087fb4
|
||||
index 0000000000000000000000000000000000000000..15154d7f9f861991134eb5a5210f7244db3216eb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PotDecorations.java
|
||||
@@ -0,0 +1,109 @@
|
||||
@@ -0,0 +1,108 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
@ -2406,7 +2396,6 @@ index 0000000000000000000000000000000000000000..6da78b8735a6cadd1282fa2fafd8b0f7
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+// CONTRIBUTORS: LEAVE THIS AS ITEM TYPE!!!
|
||||
+/**
|
||||
+ * Holds the item types for the decorations on a flower pot.
|
||||
+ * @see io.papermc.paper.datacomponent.DataComponentTypes#POT_DECORATIONS
|
||||
@ -2508,10 +2497,10 @@ index 0000000000000000000000000000000000000000..6da78b8735a6cadd1282fa2fafd8b0f7
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7cf05b382319064d45433a7e2678f65c25d11b14
|
||||
index 0000000000000000000000000000000000000000..1583d408336aec5d0c6eb7124b2cecc32c4fda56
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PotionContents.java
|
||||
@@ -0,0 +1,120 @@
|
||||
@@ -0,0 +1,118 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
@ -2593,8 +2582,8 @@ index 0000000000000000000000000000000000000000..7cf05b382319064d45433a7e2678f65c
|
||||
+ *
|
||||
+ * @param color color
|
||||
+ * @return the builder for chaining
|
||||
+ * @see #customColor()
|
||||
+ * @apiNote alpha channel of the color is supported only for Tipped Arrow
|
||||
+ * @see #customColor()
|
||||
+ */
|
||||
+ @Contract(value = "_ -> this", mutates = "this")
|
||||
+ Builder customColor(@Nullable Color color);
|
||||
@ -2613,7 +2602,6 @@ index 0000000000000000000000000000000000000000..7cf05b382319064d45433a7e2678f65c
|
||||
+ * Adds a custom effect instance to this builder.
|
||||
+ *
|
||||
+ * @param effect effect
|
||||
+ * @see #customEffects()
|
||||
+ * @return the builder for chaining
|
||||
+ * @see #customEffects()
|
||||
+ */
|
||||
@ -2624,7 +2612,6 @@ index 0000000000000000000000000000000000000000..7cf05b382319064d45433a7e2678f65c
|
||||
+ * Adds custom effect instances to this builder.
|
||||
+ *
|
||||
+ * @param effects effects
|
||||
+ * @see #customEffects()
|
||||
+ * @return the builder for chaining
|
||||
+ * @see #customEffects()
|
||||
+ */
|
||||
@ -2876,10 +2863,10 @@ index 0000000000000000000000000000000000000000..f79af65e8f3f8ffbb9be1cf1c6b537cd
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7e058aebcbd768517f6db51540598721cdae4425
|
||||
index 0000000000000000000000000000000000000000..1307221216d2b38ec5daee4d798d7fcabef7a2e2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java
|
||||
@@ -0,0 +1,52 @@
|
||||
@@ -0,0 +1,55 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -2889,6 +2876,7 @@ index 0000000000000000000000000000000000000000..7e058aebcbd768517f6db51540598721
|
||||
+/**
|
||||
+ * Holds the state of whether a data component should be shown
|
||||
+ * in an item's tooltip.
|
||||
+ *
|
||||
+ * @param <T> the data component type
|
||||
+ */
|
||||
+@NullMarked
|
||||
@ -2907,6 +2895,7 @@ index 0000000000000000000000000000000000000000..7e058aebcbd768517f6db51540598721
|
||||
+ /**
|
||||
+ * Returns a copy of this data component with the specified
|
||||
+ * show-in-tooltip state.
|
||||
+ *
|
||||
+ * @param showInTooltip {@code true} to show in the tooltip
|
||||
+ * @return the new data component
|
||||
+ */
|
||||
@ -2915,6 +2904,7 @@ index 0000000000000000000000000000000000000000..7e058aebcbd768517f6db51540598721
|
||||
+
|
||||
+ /**
|
||||
+ * A builder for creating a {@link ShownInTooltip} data component.
|
||||
+ *
|
||||
+ * @param <B> builder type
|
||||
+ */
|
||||
+ @ApiStatus.Experimental
|
||||
@ -2934,15 +2924,14 @@ index 0000000000000000000000000000000000000000..7e058aebcbd768517f6db51540598721
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..422bb5ccc42b94b60fba6714e9e6fb8aced6eb0c
|
||||
index 0000000000000000000000000000000000000000..9a740ef7da967e865a801367cf179eead0632d66
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/SuspiciousStewEffects.java
|
||||
@@ -0,0 +1,67 @@
|
||||
@@ -0,0 +1,66 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import io.papermc.paper.potion.SuspiciousEffectEntry;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collection;
|
||||
+import java.util.List;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
@ -3273,13 +3262,12 @@ index 0000000000000000000000000000000000000000..57fc55ad1def2bb14fc0a95ee3c0c157
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/UseRemainder.java b/src/main/java/io/papermc/paper/datacomponent/item/UseRemainder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..50e42e073311332142980828d0beec1828570512
|
||||
index 0000000000000000000000000000000000000000..aaecc3c954ea7c6b70c1effea65a34901e1a0924
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/UseRemainder.java
|
||||
@@ -0,0 +1,31 @@
|
||||
@@ -0,0 +1,29 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentBuilder;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
@ -3306,7 +3294,6 @@ index 0000000000000000000000000000000000000000..50e42e073311332142980828d0beec18
|
||||
+ */
|
||||
+ @Contract(value = "-> new", pure = true)
|
||||
+ ItemStack transformInto();
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java
|
||||
new file mode 100644
|
||||
@ -3612,20 +3599,20 @@ index 0000000000000000000000000000000000000000..a845ccfc21f101f0632249745bbd8b33
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumeEffect.java b/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumeEffect.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f190a75aca0
|
||||
index 0000000000000000000000000000000000000000..87537e431e505e498f9c5f86cc3401d39ebdb2ac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumeEffect.java
|
||||
@@ -0,0 +1,150 @@
|
||||
@@ -0,0 +1,147 @@
|
||||
+package io.papermc.paper.datacomponent.item.consumable;
|
||||
+
|
||||
+import io.papermc.paper.registry.set.RegistryKeySet;
|
||||
+import java.util.List;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import org.bukkit.potion.PotionEffect;
|
||||
+import org.bukkit.potion.PotionEffectType;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Effect that occurs when consuming an item.
|
||||
@ -3690,7 +3677,6 @@ index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f19
|
||||
+ return ConsumableTypesBridge.bridge().applyStatusEffects(effects, probability);
|
||||
+ }
|
||||
+
|
||||
+ @NullMarked
|
||||
+ @ApiStatus.Experimental
|
||||
+ @ApiStatus.NonExtendable
|
||||
+ interface TeleportRandomly extends ConsumeEffect {
|
||||
@ -3706,7 +3692,6 @@ index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f19
|
||||
+ /**
|
||||
+ * Represents a consumable effect that removes status effects on consumption
|
||||
+ */
|
||||
+ @NullMarked
|
||||
+ @ApiStatus.Experimental
|
||||
+ @ApiStatus.NonExtendable
|
||||
+ interface RemoveStatusEffects extends ConsumeEffect {
|
||||
@ -3722,7 +3707,6 @@ index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f19
|
||||
+ /**
|
||||
+ * Represents a consumable effect that plays a sound on consumption.
|
||||
+ */
|
||||
+ @NullMarked
|
||||
+ @ApiStatus.Experimental
|
||||
+ @ApiStatus.NonExtendable
|
||||
+ interface PlaySound extends ConsumeEffect {
|
||||
@ -3738,7 +3722,8 @@ index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f19
|
||||
+ /**
|
||||
+ * Represents a consumable effect that clears all effects on consumption.
|
||||
+ */
|
||||
+ @NullMarked
|
||||
+ @ApiStatus.Experimental
|
||||
+ @ApiStatus.NonExtendable
|
||||
+ interface ClearAllStatusEffects extends ConsumeEffect {
|
||||
+
|
||||
+ }
|
||||
@ -3746,7 +3731,6 @@ index 0000000000000000000000000000000000000000..ff1a14e19c21dd22f249503a0b738f19
|
||||
+ /**
|
||||
+ * Represents a consumable effect that applies effects based on a probability on consumption.
|
||||
+ */
|
||||
+ @NullMarked
|
||||
+ @ApiStatus.Experimental
|
||||
+ @ApiStatus.NonExtendable
|
||||
+ interface ApplyStatusEffects extends ConsumeEffect {
|
||||
|
@ -4691,16 +4691,15 @@ index 0000000000000000000000000000000000000000..197224e31175252d8438a8df585bbb65
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e85e544506b4c762503a1cb490e6c0f5b1d563f4
|
||||
index 0000000000000000000000000000000000000000..9d97c9afa31bed6d2e6b7778bfe4cc41cea31c4d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -0,0 +1,220 @@
|
||||
@@ -0,0 +1,209 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import com.google.common.collect.Collections2;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.math.BlockPosition;
|
||||
+import io.papermc.paper.math.FinePosition;
|
||||
+import io.papermc.paper.math.Position;
|
||||
@ -4716,15 +4715,10 @@ index 0000000000000000000000000000000000000000..e85e544506b4c762503a1cb490e6c0f5
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+import java.util.function.Supplier;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.Holder;
|
||||
+import net.minecraft.core.Vec3i;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
@ -4896,11 +4890,6 @@ index 0000000000000000000000000000000000000000..e85e544506b4c762503a1cb490e6c0f5
|
||||
+ return CraftNamespacedKey.fromMinecraft(key.location());
|
||||
+ }
|
||||
+
|
||||
+ public static Holder<SoundEvent> keyToSound(Key key) {
|
||||
+ ResourceLocation soundId = PaperAdventure.asVanilla(key);
|
||||
+ return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(BuiltInRegistries.SOUND_EVENT.getOptional(soundId).orElse(SoundEvent.createVariableRangeEvent(soundId)));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M> List<A> transformUnmodifiable(final List<? extends M> nms, final Function<? super M, ? extends A> converter) {
|
||||
+ return Collections.unmodifiableList(Lists.transform(nms, converter::apply));
|
||||
+ }
|
||||
|
@ -1161,16 +1161,15 @@ index 0000000000000000000000000000000000000000..2fd6c3e65354071af71c7d8ebb97b559
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..610003a668c4a7fe53e3477accc6bafb8479b936
|
||||
index 0000000000000000000000000000000000000000..8ec506a1ae40f2e4b01af9b34a0b98be8653b460
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
@@ -0,0 +1,483 @@
|
||||
@@ -0,0 +1,505 @@
|
||||
+package io.papermc.paper.adventure;
|
||||
+
|
||||
+import com.mojang.brigadier.StringReader;
|
||||
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
+import com.mojang.serialization.JavaOps;
|
||||
+import com.mojang.serialization.JsonOps;
|
||||
+import io.netty.util.AttributeKey;
|
||||
+import java.io.IOException;
|
||||
+import java.util.ArrayList;
|
||||
@ -1223,6 +1222,7 @@ index 0000000000000000000000000000000000000000..610003a668c4a7fe53e3477accc6bafb
|
||||
+import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.network.Filterable;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
@ -1322,13 +1322,35 @@ index 0000000000000000000000000000000000000000..610003a668c4a7fe53e3477accc6bafb
|
||||
+ return ResourceLocation.fromNamespaceAndPath(key.namespace(), key.value());
|
||||
+ }
|
||||
+
|
||||
+ public static ResourceLocation asVanillaNullable(final Key key) {
|
||||
+ public static <T> ResourceKey<T> asVanilla(
|
||||
+ final ResourceKey<? extends net.minecraft.core.Registry<T>> registry,
|
||||
+ final Key key
|
||||
+ ) {
|
||||
+ return ResourceKey.create(registry, asVanilla(key));
|
||||
+ }
|
||||
+
|
||||
+ public static Key asAdventureKey(final ResourceKey<?> key) {
|
||||
+ return asAdventure(key.location());
|
||||
+ }
|
||||
+
|
||||
+ public static @Nullable ResourceLocation asVanillaNullable(final Key key) {
|
||||
+ if (key == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return asVanilla(key);
|
||||
+ }
|
||||
+
|
||||
+ public static Holder<SoundEvent> resolveSound(final Key key) {
|
||||
+ ResourceLocation id = asVanilla(key);
|
||||
+ Optional<Holder.Reference<SoundEvent>> vanilla = BuiltInRegistries.SOUND_EVENT.get(id);
|
||||
+ if (vanilla.isPresent()) {
|
||||
+ return vanilla.get();
|
||||
+ }
|
||||
+
|
||||
+ // sound is not known so not in the registry but might be used by the client with a resource pack
|
||||
+ return Holder.direct(SoundEvent.createVariableRangeEvent(id));
|
||||
+ }
|
||||
+
|
||||
+ // Component
|
||||
+
|
||||
+ public static @NotNull Component asAdventure(@Nullable final net.minecraft.network.chat.Component component) {
|
||||
|
@ -222,10 +222,10 @@ index 0000000000000000000000000000000000000000..8f07539a82f449ad217e316a7513a170
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
index 161bc8c577643094d824ea96fb6974c76e5e77f0..cfcaf215c4a901dd2938c7ce41db502c57b42bbf 100644
|
||||
index 8ec506a1ae40f2e4b01af9b34a0b98be8653b460..f466bfdf5557c94ebee3ad609d9b6f18f86aefef 100644
|
||||
--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
@@ -32,6 +32,7 @@ import net.kyori.adventure.text.flattener.ComponentFlattener;
|
||||
@@ -31,6 +31,7 @@ import net.kyori.adventure.text.flattener.ComponentFlattener;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
|
@ -57,10 +57,10 @@ index 0000000000000000000000000000000000000000..4a49f65cae1354afbcd4afda07581790
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java b/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c11de1f077c51483c61af6492f998781df866b88
|
||||
index 0000000000000000000000000000000000000000..ee7adf16febfb508b14ff1453e73c75a42be7d26
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/ComponentAdapters.java
|
||||
@@ -0,0 +1,168 @@
|
||||
@@ -0,0 +1,171 @@
|
||||
+package io.papermc.paper.datacomponent;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
@ -101,13 +101,13 @@ index 0000000000000000000000000000000000000000..c11de1f077c51483c61af6492f998781
|
||||
+import io.papermc.paper.datacomponent.item.PaperUseRemainder;
|
||||
+import io.papermc.paper.datacomponent.item.PaperWritableBookContent;
|
||||
+import io.papermc.paper.datacomponent.item.PaperWrittenBookContent;
|
||||
+import io.papermc.paper.registry.PaperRegistries;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.Function;
|
||||
+import net.minecraft.core.component.DataComponentType;
|
||||
+import net.minecraft.core.component.DataComponents;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.util.Unit;
|
||||
+import net.minecraft.world.item.Rarity;
|
||||
@ -119,7 +119,7 @@ index 0000000000000000000000000000000000000000..c11de1f077c51483c61af6492f998781
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
+import org.bukkit.inventory.ItemRarity;
|
||||
+
|
||||
+import static io.papermc.paper.datacomponent.ComponentUtils.transform;
|
||||
+import static io.papermc.paper.util.MCUtil.transformUnmodifiable;
|
||||
+
|
||||
+public final class ComponentAdapters {
|
||||
+
|
||||
@ -182,7 +182,10 @@ index 0000000000000000000000000000000000000000..c11de1f077c51483c61af6492f998781
|
||||
+ register(DataComponents.INSTRUMENT, CraftMusicInstrument::minecraftHolderToBukkit, CraftMusicInstrument::bukkitToMinecraftHolder);
|
||||
+ register(DataComponents.OMINOUS_BOTTLE_AMPLIFIER, PaperOminousBottleAmplifier::new);
|
||||
+ register(DataComponents.JUKEBOX_PLAYABLE, PaperJukeboxPlayable::new);
|
||||
+ register(DataComponents.RECIPES, nms -> transform(nms, PaperRegistries::fromNms), api -> transform(api, PaperRegistries::toNms));
|
||||
+ register(DataComponents.RECIPES,
|
||||
+ nms -> transformUnmodifiable(nms, PaperAdventure::asAdventureKey),
|
||||
+ api -> transformUnmodifiable(api, key -> PaperAdventure.asVanilla(Registries.RECIPE, key))
|
||||
+ );
|
||||
+ register(DataComponents.LODESTONE_TRACKER, PaperLodestoneTracker::new);
|
||||
+ register(DataComponents.FIREWORK_EXPLOSION, CraftMetaFirework::getEffect, CraftMetaFirework::getExplosion);
|
||||
+ register(DataComponents.FIREWORKS, PaperFireworks::new);
|
||||
@ -229,51 +232,6 @@ index 0000000000000000000000000000000000000000..c11de1f077c51483c61af6492f998781
|
||||
+ ADAPTERS.put(key, new ComponentAdapter<>(type, apiToVanilla, vanillaToApi, codecValidation && !type.isTransient()));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/ComponentUtils.java b/src/main/java/io/papermc/paper/datacomponent/ComponentUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c95ffef54d7149cd8bb220533dddade515e48c8c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/ComponentUtils.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package io.papermc.paper.datacomponent;
|
||||
+
|
||||
+import com.google.common.collect.Collections2;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import java.util.Collection;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Function;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.Holder;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+
|
||||
+public final class ComponentUtils {
|
||||
+
|
||||
+ private ComponentUtils() {
|
||||
+ }
|
||||
+
|
||||
+ public static Holder<SoundEvent> keyToSound(Key key) {
|
||||
+ ResourceLocation soundId = PaperAdventure.asVanilla(key);
|
||||
+ return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(BuiltInRegistries.SOUND_EVENT.getOptional(soundId).orElse(SoundEvent.createVariableRangeEvent(soundId)));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M> List<A> transform(final List<? extends M> nms, final Function<? super M, ? extends A> converter) {
|
||||
+ return Collections.unmodifiableList(Lists.transform(nms, converter::apply));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M> Collection<A> transform(final Collection<? extends M> nms, final Function<? super M, ? extends A> converter) {
|
||||
+ return Collections.unmodifiableCollection(Collections2.transform(nms, converter::apply));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M, C extends Collection<M>> void addAndConvert(final C target, final Collection<A> toAdd, final Function<? super A, ? extends M> converter) {
|
||||
+ for (final A value : toAdd) {
|
||||
+ target.add(converter.apply(value));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/PaperComponentType.java b/src/main/java/io/papermc/paper/datacomponent/PaperComponentType.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f0d4ec462eee47840e91bac888ae46045b493f07
|
||||
@ -391,7 +349,7 @@ index 0000000000000000000000000000000000000000..f0d4ec462eee47840e91bac888ae4604
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..14d039995a16a2c85569ca09e7f825c7de42fd6b
|
||||
index 0000000000000000000000000000000000000000..9111c3095986bea43d5eb06763cbe287f6853434
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java
|
||||
@@ -0,0 +1,239 @@
|
||||
@ -574,7 +532,7 @@ index 0000000000000000000000000000000000000000..14d039995a16a2c85569ca09e7f825c7
|
||||
+
|
||||
+ @Override
|
||||
+ public UseRemainder useRemainder(final ItemStack itemStack) {
|
||||
+ Preconditions.checkNotNull(itemStack);
|
||||
+ Preconditions.checkArgument(itemStack != null, "Item cannot be null");
|
||||
+ Preconditions.checkArgument(!itemStack.isEmpty(), "Remaining item cannot be empty!");
|
||||
+ return new PaperUseRemainder(
|
||||
+ new net.minecraft.world.item.component.UseRemainder(CraftItemStack.asNMSCopy(itemStack))
|
||||
@ -636,7 +594,7 @@ index 0000000000000000000000000000000000000000..14d039995a16a2c85569ca09e7f825c7
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperBannerPatternLayers.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperBannerPatternLayers.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9fde759d57bb9f54e32ce2e7ac36876079013c2b
|
||||
index 0000000000000000000000000000000000000000..ca49c2d2e1edcf6c4f7a5ca6c9ba96920aa385f4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperBannerPatternLayers.java
|
||||
@@ -0,0 +1,62 @@
|
||||
@ -663,7 +621,7 @@ index 0000000000000000000000000000000000000000..9fde759d57bb9f54e32ce2e7ac368760
|
||||
+ private static List<Pattern> convert(final net.minecraft.world.level.block.entity.BannerPatternLayers nmsPatterns) {
|
||||
+ return MCUtil.transformUnmodifiable(nmsPatterns.layers(), input -> {
|
||||
+ final Optional<PatternType> type = CraftRegistry.unwrapAndConvertHolder(RegistryAccess.registryAccess().getRegistry(RegistryKey.BANNER_PATTERN), input.pattern());
|
||||
+ return new Pattern(Objects.requireNonNull(DyeColor.getByWoolData((byte) input.color().getId())), type.orElseThrow(() -> new IllegalStateException("Inline banner patterns are not supported yet in the API!")));
|
||||
+ return new Pattern(Objects.requireNonNull(DyeColor.getByWoolData((byte) input.color().getId())), type.orElseThrow(() -> new IllegalStateException("Inlined banner patterns are not supported yet in the API!")));
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
@ -760,7 +718,7 @@ index 0000000000000000000000000000000000000000..5757e16c5948a6897bc61005ea726094
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a59a98bdb15d2f4595d5ea651bfdf62542d80b2b
|
||||
index 0000000000000000000000000000000000000000..ba95ce77dbddb90fd2616c9112fd74051dddc3ee
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java
|
||||
@@ -0,0 +1,51 @@
|
||||
@ -794,7 +752,7 @@ index 0000000000000000000000000000000000000000..a59a98bdb15d2f4595d5ea651bfdf625
|
||||
+
|
||||
+ @Override
|
||||
+ public BundleContents.Builder add(final ItemStack stack) {
|
||||
+ Preconditions.checkNotNull(stack, "stack cannot be null");
|
||||
+ Preconditions.checkArgument(stack != null, "stack cannot be null");
|
||||
+ Preconditions.checkArgument(!stack.isEmpty(), "stack cannot be empty");
|
||||
+ this.items.add(CraftItemStack.asNMSCopy(stack));
|
||||
+ return this;
|
||||
@ -817,7 +775,7 @@ index 0000000000000000000000000000000000000000..a59a98bdb15d2f4595d5ea651bfdf625
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3aa8b905748f2b82e1c464272d4b9da0c20086ad
|
||||
index 0000000000000000000000000000000000000000..2129dd67fd02a13f6e6fbdfb07505dc64307a3f0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java
|
||||
@@ -0,0 +1,51 @@
|
||||
@ -851,7 +809,7 @@ index 0000000000000000000000000000000000000000..3aa8b905748f2b82e1c464272d4b9da0
|
||||
+
|
||||
+ @Override
|
||||
+ public ChargedProjectiles.Builder add(final ItemStack stack) {
|
||||
+ Preconditions.checkNotNull(stack, "stack cannot be null");
|
||||
+ Preconditions.checkArgument(stack != null, "stack cannot be null");
|
||||
+ Preconditions.checkArgument(!stack.isEmpty(), "stack cannot be empty");
|
||||
+ this.items.add(CraftItemStack.asNMSCopy(stack));
|
||||
+ return this;
|
||||
@ -874,10 +832,10 @@ index 0000000000000000000000000000000000000000..3aa8b905748f2b82e1c464272d4b9da0
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperConsumable.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperConsumable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9badd3859745c0090c782fdccdd6fe8830f36b49
|
||||
index 0000000000000000000000000000000000000000..0bc2bad71d6945ca24f37008effc903a84466004
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperConsumable.java
|
||||
@@ -0,0 +1,134 @@
|
||||
@@ -0,0 +1,126 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
@ -890,8 +848,6 @@ index 0000000000000000000000000000000000000000..9badd3859745c0090c782fdccdd6fe88
|
||||
+import java.util.List;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.Holder;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.sounds.SoundEvents;
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
@ -931,7 +887,7 @@ index 0000000000000000000000000000000000000000..9badd3859745c0090c782fdccdd6fe88
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<ConsumeEffect> consumeEffects() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.onConsumeEffects(), PaperConsumableEffects::fromNms);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.onConsumeEffects(), PaperConsumableEffects::fromNms);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -968,13 +924,7 @@ index 0000000000000000000000000000000000000000..9badd3859745c0090c782fdccdd6fe88
|
||||
+
|
||||
+ @Override
|
||||
+ public Builder sound(final Key sound) {
|
||||
+ final ResourceLocation keySound = PaperAdventure.asVanilla(sound);
|
||||
+ this.eatSound = BuiltInRegistries.SOUND_EVENT.wrapAsHolder(
|
||||
+ BuiltInRegistries.SOUND_EVENT.getOptional(keySound).orElse(
|
||||
+ SoundEvent.createVariableRangeEvent(keySound)
|
||||
+ )
|
||||
+ );
|
||||
+
|
||||
+ this.eatSound = PaperAdventure.resolveSound(sound);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
@ -1065,7 +1015,7 @@ index 0000000000000000000000000000000000000000..adc986c8b3d65e3fb91a8951048194bb
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperDeathProtection.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperDeathProtection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6184acced73d8e99c0fa8b0df03680ad9b84f689
|
||||
index 0000000000000000000000000000000000000000..798e45d3b3e895f8b3abb9db1c9d58348bcd22d3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperDeathProtection.java
|
||||
@@ -0,0 +1,50 @@
|
||||
@ -1090,7 +1040,7 @@ index 0000000000000000000000000000000000000000..6184acced73d8e99c0fa8b0df03680ad
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<ConsumeEffect> deathEffects() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.deathEffects(), PaperConsumableEffects::fromNms);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.deathEffects(), PaperConsumableEffects::fromNms);
|
||||
+ }
|
||||
+
|
||||
+ static final class BuilderImpl implements Builder {
|
||||
@ -1203,17 +1153,16 @@ index 0000000000000000000000000000000000000000..422e1a4d606481f0dc68843fbbc8126c
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..dbf8d060ab20b9cf31f209f26a8ad4d0cf05d6db
|
||||
index 0000000000000000000000000000000000000000..ab7947bddfad12d8ae7abcda34f17c3335082a01
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java
|
||||
@@ -0,0 +1,169 @@
|
||||
@@ -0,0 +1,168 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.registry.RegistryKey;
|
||||
+import io.papermc.paper.registry.set.PaperRegistrySets;
|
||||
+import io.papermc.paper.registry.set.RegistryKeySet;
|
||||
+import io.papermc.paper.util.MCUtil;
|
||||
+import java.util.Optional;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.Holder;
|
||||
@ -1313,8 +1262,8 @@ index 0000000000000000000000000000000000000000..dbf8d060ab20b9cf31f209f26a8ad4d0
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Builder equipSound(final Key equipSound) {
|
||||
+ this.equipSound = MCUtil.keyToSound(equipSound);
|
||||
+ public Builder equipSound(final Key sound) {
|
||||
+ this.equipSound = PaperAdventure.resolveSound(sound);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
@ -1378,7 +1327,7 @@ index 0000000000000000000000000000000000000000..dbf8d060ab20b9cf31f209f26a8ad4d0
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperFireworks.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperFireworks.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d7002c97086b55af851faaf8c65ad05c75381b02
|
||||
index 0000000000000000000000000000000000000000..80189eb5054a044a76f19200eb0e5f316c30de92
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperFireworks.java
|
||||
@@ -0,0 +1,73 @@
|
||||
@ -1405,7 +1354,7 @@ index 0000000000000000000000000000000000000000..d7002c97086b55af851faaf8c65ad05c
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<FireworkEffect> effects() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.explosions(), CraftMetaFirework::getEffect);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.explosions(), CraftMetaFirework::getEffect);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -1787,7 +1736,7 @@ index 0000000000000000000000000000000000000000..47ca2b8eb1c1483b6049cf18c7d8a40d
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e65603e711ecd08039361d291a0aac761a2f9349
|
||||
index 0000000000000000000000000000000000000000..2c4ecc2d5fc925f245c691facde9c96f3b5eef85
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java
|
||||
@@ -0,0 +1,65 @@
|
||||
@ -1821,7 +1770,7 @@ index 0000000000000000000000000000000000000000..e65603e711ecd08039361d291a0aac76
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemContainerContents.Builder add(final ItemStack stack) {
|
||||
+ Preconditions.checkNotNull(stack);
|
||||
+ Preconditions.checkArgument(stack != null, "Item cannot be null");
|
||||
+ Preconditions.checkArgument(
|
||||
+ this.items.size() + 1 <= net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE,
|
||||
+ "Cannot have more than %s items, had %s",
|
||||
@ -1840,9 +1789,9 @@ index 0000000000000000000000000000000000000000..e65603e711ecd08039361d291a0aac76
|
||||
+ net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE,
|
||||
+ this.items.size() + stacks.size()
|
||||
+ );
|
||||
+ MCUtil.addAndConvert(this.items, stacks, itemStack -> {
|
||||
+ Preconditions.checkNotNull(itemStack, "Cannot pass null itemstacks!");
|
||||
+ return CraftItemStack.asNMSCopy(itemStack);
|
||||
+ MCUtil.addAndConvert(this.items, stacks, stack -> {
|
||||
+ Preconditions.checkArgument(stack != null, "Cannot pass null itemstacks!");
|
||||
+ return CraftItemStack.asNMSCopy(stack);
|
||||
+ });
|
||||
+ return this;
|
||||
+ }
|
||||
@ -1956,7 +1905,7 @@ index 0000000000000000000000000000000000000000..3cfb18f6a4868ff32e2b118c5833b1b9
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperItemLore.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperItemLore.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8f58b6869bb79428288a4be05424ace4d77c3845
|
||||
index 0000000000000000000000000000000000000000..3bb0c1aebb03c8dfd6a76ab60c26cbb104586975
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperItemLore.java
|
||||
@@ -0,0 +1,77 @@
|
||||
@ -1984,12 +1933,12 @@ index 0000000000000000000000000000000000000000..8f58b6869bb79428288a4be05424ace4
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<Component> lines() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.lines(), PaperAdventure::asAdventure);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.lines(), PaperAdventure::asAdventure);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<Component> styledLines() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.styledLines(), PaperAdventure::asAdventure);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.styledLines(), PaperAdventure::asAdventure);
|
||||
+ }
|
||||
+
|
||||
+ static final class BuilderImpl implements ItemLore.Builder {
|
||||
@ -2145,15 +2094,16 @@ index 0000000000000000000000000000000000000000..538a61eaa02c029b4d92f938e0ffde8a
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperJukeboxPlayable.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperJukeboxPlayable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..eb7209d42e7c44ae7c9b31663aa94ed6cc77f592
|
||||
index 0000000000000000000000000000000000000000..c43ccf7ccc6157389fce9f9746d5297f0eab1b6e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperJukeboxPlayable.java
|
||||
@@ -0,0 +1,58 @@
|
||||
@@ -0,0 +1,62 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import net.minecraft.world.item.EitherHolder;
|
||||
+import org.bukkit.JukeboxSong;
|
||||
+import org.bukkit.craftbukkit.CraftJukeboxSong;
|
||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
+
|
||||
+public record PaperJukeboxPlayable(
|
||||
@ -2177,7 +2127,10 @@ index 0000000000000000000000000000000000000000..eb7209d42e7c44ae7c9b31663aa94ed6
|
||||
+
|
||||
+ @Override
|
||||
+ public JukeboxSong jukeboxSong() {
|
||||
+ return this.impl.song().holder().map(CraftJukeboxSong::minecraftHolderToBukkit).orElseThrow();
|
||||
+ return this.impl.song()
|
||||
+ .unwrap(CraftRegistry.getMinecraftRegistry())
|
||||
+ .map(CraftJukeboxSong::minecraftHolderToBukkit)
|
||||
+ .orElseThrow();
|
||||
+ }
|
||||
+
|
||||
+ static final class BuilderImpl implements JukeboxPlayable.Builder {
|
||||
@ -2550,7 +2503,7 @@ index 0000000000000000000000000000000000000000..bde757b51d0ae6a36870c789d416ec0e
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperPotionContents.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperPotionContents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..196297175610644a5a4cad8e619303b4517df274
|
||||
index 0000000000000000000000000000000000000000..4712f8bbaa9f00ede895651472d7975ffa30c88d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperPotionContents.java
|
||||
@@ -0,0 +1,103 @@
|
||||
@ -2582,7 +2535,7 @@ index 0000000000000000000000000000000000000000..196297175610644a5a4cad8e619303b4
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<PotionEffect> customEffects() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.customEffects(), CraftPotionUtil::toBukkit);
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.customEffects(), CraftPotionUtil::toBukkit);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -2687,7 +2640,7 @@ index 0000000000000000000000000000000000000000..96345e051c4aa77820e857a02768b684
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperResolvableProfile.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperResolvableProfile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2c59b17f58502402c3234289b38da28672244cbb
|
||||
index 0000000000000000000000000000000000000000..7583a7efb4bfdb0157ee27a1b7cfb661eeccb02a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperResolvableProfile.java
|
||||
@@ -0,0 +1,105 @@
|
||||
@ -2734,7 +2687,7 @@ index 0000000000000000000000000000000000000000..2c59b17f58502402c3234289b38da286
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable Collection<ProfileProperty> properties() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.properties().values(), input -> new ProfileProperty(input.name(), input.value(), input.signature()));
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.properties().values(), input -> new ProfileProperty(input.name(), input.value(), input.signature()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -2863,7 +2816,7 @@ index 0000000000000000000000000000000000000000..1ee469b3b690a877e066dbca79706678
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperSuspiciousStewEffects.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperSuspiciousStewEffects.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..69801d8f22945b9818299d8e770fe80a28da7018
|
||||
index 0000000000000000000000000000000000000000..41df23c7e7e713e88eef757fda347381e151b0fc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperSuspiciousStewEffects.java
|
||||
@@ -0,0 +1,58 @@
|
||||
@ -2891,7 +2844,7 @@ index 0000000000000000000000000000000000000000..69801d8f22945b9818299d8e770fe80a
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<SuspiciousEffectEntry> effects() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.effects(), entry -> create(CraftPotionEffectType.minecraftHolderToBukkit(entry.effect()), entry.duration()));
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.effects(), entry -> create(CraftPotionEffectType.minecraftHolderToBukkit(entry.effect()), entry.duration()));
|
||||
+ }
|
||||
+
|
||||
+ static final class BuilderImpl implements Builder {
|
||||
@ -3060,10 +3013,10 @@ index 0000000000000000000000000000000000000000..c2c04506940704c2ec9a5e6bb469c477
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..563ac5345efe68cfe223853df13d5f07cc48e850
|
||||
index 0000000000000000000000000000000000000000..559343a33bada475cc5bbcd431cd88b537c8cef7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java
|
||||
@@ -0,0 +1,105 @@
|
||||
@@ -0,0 +1,103 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
@ -3076,8 +3029,6 @@ index 0000000000000000000000000000000000000000..563ac5345efe68cfe223853df13d5f07
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
+import org.jetbrains.annotations.Unmodifiable;
|
||||
+
|
||||
+import static io.papermc.paper.text.Filtered.of;
|
||||
+
|
||||
+public record PaperWritableBookContent(
|
||||
+ net.minecraft.world.item.component.WritableBookContent impl
|
||||
+) implements WritableBookContent, Handleable<net.minecraft.world.item.component.WritableBookContent> {
|
||||
@ -3089,7 +3040,7 @@ index 0000000000000000000000000000000000000000..563ac5345efe68cfe223853df13d5f07
|
||||
+
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<Filtered<String>> pages() {
|
||||
+ return MCUtil.transformUnmodifiable(impl.pages(), input -> of(input.raw(), input.filtered().orElse(null)));
|
||||
+ return MCUtil.transformUnmodifiable(this.impl.pages(), input -> Filtered.of(input.raw(), input.filtered().orElse(null)));
|
||||
+ }
|
||||
+
|
||||
+ static final class BuilderImpl implements WritableBookContent.Builder {
|
||||
@ -3171,7 +3122,7 @@ index 0000000000000000000000000000000000000000..563ac5345efe68cfe223853df13d5f07
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e6ce137806cd789586108fef5a5da508b19b7131
|
||||
index 0000000000000000000000000000000000000000..037a6695bdb8ee6e3c119fa79000c4ea28e1bef8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java
|
||||
@@ -0,0 +1,183 @@
|
||||
@ -3222,7 +3173,7 @@ index 0000000000000000000000000000000000000000..e6ce137806cd789586108fef5a5da508
|
||||
+ @Override
|
||||
+ public @Unmodifiable List<Filtered<Component>> pages() {
|
||||
+ return MCUtil.transformUnmodifiable(
|
||||
+ impl.pages(),
|
||||
+ this.impl.pages(),
|
||||
+ page -> Filtered.of(asAdventure(page.raw()), page.filtered().map(PaperAdventure::asAdventure).orElse(null))
|
||||
+ );
|
||||
+ }
|
||||
@ -3360,19 +3311,19 @@ index 0000000000000000000000000000000000000000..e6ce137806cd789586108fef5a5da508
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumableTypesBridgeImpl.java b/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumableTypesBridgeImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c96cb39cf21ebe33d09733affc3cb031d94213f2
|
||||
index 0000000000000000000000000000000000000000..e11e7b36c0b0b499a6149c44ca2ad9f331d1b863
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/consumable/ConsumableTypesBridgeImpl.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,64 @@
|
||||
+package io.papermc.paper.datacomponent.item.consumable;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.registry.set.PaperRegistrySets;
|
||||
+import io.papermc.paper.registry.set.RegistryKeySet;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import io.papermc.paper.util.MCUtil;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
@ -3416,9 +3367,7 @@ index 0000000000000000000000000000000000000000..c96cb39cf21ebe33d09733affc3cb031
|
||||
+ @Override
|
||||
+ public ConsumeEffect.PlaySound playSoundEffect(final Key sound) {
|
||||
+ return new PaperPlaySound(
|
||||
+ new net.minecraft.world.item.consume_effects.PlaySoundConsumeEffect(
|
||||
+ MCUtil.keyToSound(sound)
|
||||
+ )
|
||||
+ new net.minecraft.world.item.consume_effects.PlaySoundConsumeEffect(PaperAdventure.resolveSound(sound))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
@ -3432,7 +3381,7 @@ index 0000000000000000000000000000000000000000..c96cb39cf21ebe33d09733affc3cb031
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/consumable/PaperApplyStatusEffects.java b/src/main/java/io/papermc/paper/datacomponent/item/consumable/PaperApplyStatusEffects.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..465bec185aad849f283aae39bc23e9ba7a052371
|
||||
index 0000000000000000000000000000000000000000..0d2a4ba560f5a34139517ac2e17667c94a3c56f6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/consumable/PaperApplyStatusEffects.java
|
||||
@@ -0,0 +1,28 @@
|
||||
@ -3443,7 +3392,7 @@ index 0000000000000000000000000000000000000000..465bec185aad849f283aae39bc23e9ba
|
||||
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
+import org.bukkit.potion.PotionEffect;
|
||||
+
|
||||
+import static io.papermc.paper.datacomponent.ComponentUtils.transform;
|
||||
+import static io.papermc.paper.util.MCUtil.transformUnmodifiable;
|
||||
+
|
||||
+public record PaperApplyStatusEffects(
|
||||
+ ApplyStatusEffectsConsumeEffect impl
|
||||
@ -3451,7 +3400,7 @@ index 0000000000000000000000000000000000000000..465bec185aad849f283aae39bc23e9ba
|
||||
+
|
||||
+ @Override
|
||||
+ public List<PotionEffect> effects() {
|
||||
+ return transform(this.impl().effects(), CraftPotionUtil::toBukkit);
|
||||
+ return transformUnmodifiable(this.impl().effects(), CraftPotionUtil::toBukkit);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -3661,7 +3610,7 @@ index f8c6da955e4bd0e480c7b581d2a4325738f9dd6f..ee1fce58c6e57dd93a30ee66e7488a92
|
||||
// data-drivens
|
||||
entry(Registries.BIOME, RegistryKey.BIOME, Biome.class, CraftBiome::new).delayed(),
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index 756c73a401437566258813946fa10c7caa8f2469..bfddaa146c1bcb6a3fdd43773ec06f91a259b200 100644
|
||||
index 756c73a401437566258813946fa10c7caa8f2469..ccad5a7018f6eaacb011818e9da990c75e0d06df 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -206,7 +206,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
@ -3678,7 +3627,7 @@ index 756c73a401437566258813946fa10c7caa8f2469..bfddaa146c1bcb6a3fdd43773ec06f91
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
- return (this.handle == null) ? Material.AIR.getMaxStackSize() : this.handle.getMaxStackSize();
|
||||
+ return (this.handle == null) ? 64 : this.handle.getMaxStackSize(); // Paper - air stacks to 64
|
||||
+ return (this.handle == null) ? Item.DEFAULT_MAX_STACK_SIZE : this.handle.getMaxStackSize(); // Paper - air stacks to 64
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@ -3876,9 +3825,18 @@ index 756c73a401437566258813946fa10c7caa8f2469..bfddaa146c1bcb6a3fdd43773ec06f91
|
||||
+ // Paper end - data component API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||
index 1b57649d0d3db24ed32c78cf3d5ce1d9fb1353e0..ce1287edd7db00279ec8569d767ab6272c8ae3fb 100644
|
||||
index 1b57649d0d3db24ed32c78cf3d5ce1d9fb1353e0..674ec11b77f41905e3744c22b2ee2d828b0693ad 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||
@@ -150,7 +150,7 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
|
||||
public int getMaxStackSize() {
|
||||
// Based of the material enum air is only 0, in PerMaterialTest it is also set as special case
|
||||
// the item info itself would return 64
|
||||
- if (this == AIR) {
|
||||
+ if (false && this == AIR) { // Paper - air stacks to 64
|
||||
return 0;
|
||||
}
|
||||
return this.item.components().getOrDefault(DataComponents.MAX_STACK_SIZE, 64);
|
||||
@@ -270,4 +270,20 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
|
||||
return rarity == null ? null : org.bukkit.inventory.ItemRarity.valueOf(rarity.name());
|
||||
}
|
||||
@ -4100,10 +4058,10 @@ index 0000000000000000000000000000000000000000..4ee0491763341232844a99aa528310a3
|
||||
+}
|
||||
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..5825be69af0b949ce28d6bde28bef68935db0d45
|
||||
index 0000000000000000000000000000000000000000..06597cc8ba23e0e1e439af5b6cbc2a7fac3c4022
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java
|
||||
@@ -0,0 +1,371 @@
|
||||
@@ -0,0 +1,416 @@
|
||||
+package io.papermc.paper.item;
|
||||
+
|
||||
+import io.papermc.paper.datacomponent.DataComponentType;
|
||||
@ -4127,8 +4085,18 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+import io.papermc.paper.registry.RegistryKey;
|
||||
+import io.papermc.paper.registry.set.RegistrySet;
|
||||
+import io.papermc.paper.registry.tag.TagKey;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.function.Function;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.util.TriState;
|
||||
+import net.minecraft.core.component.DataComponents;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
+import net.minecraft.world.item.EitherHolder;
|
||||
+import net.minecraft.world.item.Items;
|
||||
+import net.minecraft.world.item.JukeboxSongs;
|
||||
+import org.bukkit.Color;
|
||||
+import org.bukkit.FireworkEffect;
|
||||
+import org.bukkit.JukeboxSong;
|
||||
@ -4140,6 +4108,7 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.block.BlockType;
|
||||
+import org.bukkit.block.DecoratedPot;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.enchantments.Enchantment;
|
||||
+import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
+import org.bukkit.inventory.ItemFlag;
|
||||
@ -4152,6 +4121,7 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+import org.bukkit.inventory.meta.Damageable;
|
||||
+import org.bukkit.inventory.meta.FireworkMeta;
|
||||
+import org.bukkit.inventory.meta.ItemMeta;
|
||||
+import org.bukkit.inventory.meta.KnowledgeBookMeta;
|
||||
+import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
+import org.bukkit.inventory.meta.MapMeta;
|
||||
+import org.bukkit.inventory.meta.Repairable;
|
||||
@ -4161,13 +4131,10 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+import org.bukkit.inventory.meta.trim.ArmorTrim;
|
||||
+import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
+import org.bukkit.support.RegistryHelper;
|
||||
+import org.bukkit.support.environment.AllFeatures;
|
||||
+import org.junit.jupiter.api.Assertions;
|
||||
+import org.junit.jupiter.api.Test;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.function.Function;
|
||||
+
|
||||
+@AllFeatures
|
||||
+class ItemStackDataComponentTest {
|
||||
@ -4437,6 +4404,42 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+ Assertions.assertTrue(decoratedPot.getSherds().values().stream().allMatch((m) -> m.asItemType() == ItemType.BRICK));
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ void testRecipes() {
|
||||
+ final ItemStack stack = new ItemStack(Material.KNOWLEDGE_BOOK);
|
||||
+ stack.setData(DataComponentTypes.RECIPES, List.of(Key.key("paper:fun_recipe")));
|
||||
+
|
||||
+ final ItemMeta itemMeta = stack.getItemMeta();
|
||||
+ Assertions.assertInstanceOf(KnowledgeBookMeta.class, itemMeta);
|
||||
+
|
||||
+ final List<NamespacedKey> recipes = ((KnowledgeBookMeta) itemMeta).getRecipes();
|
||||
+ Assertions.assertEquals(recipes, List.of(new NamespacedKey("paper", "fun_recipe")));
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ void testJukeboxWithEitherKey() {
|
||||
+ final ItemStack apiStack = CraftItemStack.asBukkitCopy(new net.minecraft.world.item.ItemStack(Items.MUSIC_DISC_5));
|
||||
+ final JukeboxPlayable data = apiStack.getData(DataComponentTypes.JUKEBOX_PLAYABLE);
|
||||
+
|
||||
+ Assertions.assertNotNull(data);
|
||||
+ Assertions.assertEquals(JukeboxSong.FIVE, data.jukeboxSong());
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ void testJukeboxWithEitherHolder() {
|
||||
+ final net.minecraft.world.item.ItemStack internalStack = new net.minecraft.world.item.ItemStack(Items.STONE);
|
||||
+ internalStack.set(DataComponents.JUKEBOX_PLAYABLE, new net.minecraft.world.item.JukeboxPlayable(
|
||||
+ new EitherHolder<>(RegistryHelper.getRegistry().lookupOrThrow(Registries.JUKEBOX_SONG).getOrThrow(JukeboxSongs.FIVE)),
|
||||
+ true
|
||||
+ ));
|
||||
+
|
||||
+ final ItemStack apiStack = CraftItemStack.asBukkitCopy(internalStack);
|
||||
+ final JukeboxPlayable data = apiStack.getData(DataComponentTypes.JUKEBOX_PLAYABLE);
|
||||
+
|
||||
+ Assertions.assertNotNull(data);
|
||||
+ Assertions.assertEquals(JukeboxSong.FIVE, data.jukeboxSong());
|
||||
+ }
|
||||
+
|
||||
+ private static <T, M extends ItemMeta> void testWithMeta(final ItemStack stack, final DataComponentType.Valued<T> type, final T value, final Class<M> metaType, final Function<M, T> metaGetter, final BiConsumer<M, T> metaSetter) {
|
||||
+ testWithMeta(stack, type, value, Function.identity(), metaType, metaGetter, metaSetter);
|
||||
+ }
|
||||
@ -4477,14 +4480,16 @@ index 0000000000000000000000000000000000000000..5825be69af0b949ce28d6bde28bef689
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/item/MetaComparisonTest.java b/src/test/java/io/papermc/paper/item/MetaComparisonTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1225ad95a204434ef6af5e6e92593cbbafc31b4a
|
||||
index 0000000000000000000000000000000000000000..7cda79980729770695451adcd03b1886f60d86e3
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/item/MetaComparisonTest.java
|
||||
@@ -0,0 +1,284 @@
|
||||
@@ -0,0 +1,281 @@
|
||||
+package io.papermc.paper.item;
|
||||
+
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
+import java.util.UUID;
|
||||
+import java.util.function.Consumer;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.event.HoverEvent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -4508,9 +4513,6 @@ index 0000000000000000000000000000000000000000..1225ad95a204434ef6af5e6e92593cbb
|
||||
+import org.junit.jupiter.api.Disabled;
|
||||
+import org.junit.jupiter.api.Test;
|
||||
+
|
||||
+import java.util.UUID;
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
+// TODO: This should technically be used to compare legacy meta vs the newly implemented
|
||||
+@AllFeatures
|
||||
+public class MetaComparisonTest {
|
||||
@ -4751,9 +4753,7 @@ index 0000000000000000000000000000000000000000..1225ad95a204434ef6af5e6e92593cbb
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ private void testSetAndGet(org.bukkit.inventory.ItemStack itemStack,
|
||||
+ Consumer<ItemMeta> set,
|
||||
+ Consumer<ItemMeta> get) {
|
||||
+ private void testSetAndGet(ItemStack itemStack, Consumer<ItemMeta> set, Consumer<ItemMeta> get) {
|
||||
+ ItemMeta craftMeta = CraftItemStack.getItemMeta(CraftItemStack.asNMSCopy(itemStack)); // TODO: This should be converted to use the old meta when this is added.
|
||||
+ ItemMeta paperMeta = CraftItemStack.getItemMeta(CraftItemStack.asNMSCopy(itemStack));
|
||||
+ // Test craft meta
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren