Archiviert
13
0

Merge remote-tracking branch 'upstream/master' into 1.21.1-update

Dieser Commit ist enthalten in:
Chaoscaot 2024-11-24 19:00:12 +01:00
Commit 72d0796227
33 geänderte Dateien mit 1232 neuen und 544 gelöschten Zeilen

Datei anzeigen

@ -319,7 +319,7 @@ index 0000000000000000000000000000000000000000..80e3e64f47ac55a4978c9e5b430e2f2d
+}
diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java
new file mode 100644
index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188c43d148f
index 0000000000000000000000000000000000000000..81bee5224196008662ddda528b5dcb8dd7cb9f21
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java
@@ -0,0 +1,45 @@
@ -337,7 +337,7 @@ index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188
+ */
+@ApiStatus.Experimental
+@NullMarked
+public sealed interface TypedKey<T> extends Keyed permits TypedKeyImpl {
+public sealed interface TypedKey<T> extends Key permits TypedKeyImpl {
+
+ /**
+ * Gets the key for the value in the registry.
@ -370,10 +370,10 @@ index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188
+}
diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..99375deaa6b90b33cd6a77e0df651236d304874e
index 0000000000000000000000000000000000000000..3e29f7007500582cdc3f84b91f11ebeb58f68bbf
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
@@ -0,0 +1,8 @@
@@ -0,0 +1,23 @@
+package io.papermc.paper.registry;
+
+import net.kyori.adventure.key.Key;
@ -381,6 +381,21 @@ index 0000000000000000000000000000000000000000..99375deaa6b90b33cd6a77e0df651236
+
+@NullMarked
+record TypedKeyImpl<T>(Key key, RegistryKey<T> registryKey) implements TypedKey<T> {
+ // Wrap key methods to make this easier to use
+ @Override
+ public String namespace() {
+ return this.key.namespace();
+ }
+
+ @Override
+ public String value() {
+ return this.key.value();
+ }
+
+ @Override
+ public String asString() {
+ return this.key.asString();
+ }
+}
diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java
index b7845523e8587e13b86516c0012fe097d904846c..d92a75f610cb2a95203b3f22dc67bdbfb5c3405a 100644

Datei anzeigen

@ -206,8 +206,45 @@ index 3470755c65a2db38e679adc35d3d43f7fef5468d..1fe3a5e2f5c15fddfbcd503a061ebf75
public static <T extends Keyed> Registry<T> getRegistry(@NotNull Class<T> tClass) {
return server.getRegistry(tClass);
}
diff --git a/src/main/java/org/bukkit/Particle.java b/src/main/java/org/bukkit/Particle.java
index 37e7862be843da4f48ac061fb1625854fd671b2a..cdc09d18088af3100cb731702edb7e6bffdeb502 100644
--- a/src/main/java/org/bukkit/Particle.java
+++ b/src/main/java/org/bukkit/Particle.java
@@ -162,28 +162,23 @@ public enum Particle implements Keyed {
private final NamespacedKey key;
private final Class<?> dataType;
- final boolean register;
+ // Paper - all particles are registered
Particle(String key) {
this(key, Void.class);
}
- Particle(String key, boolean register) {
- this(key, Void.class, register);
- }
+ // Paper - all particles are registered
Particle(String key, /*@NotNull*/ Class<?> data) {
- this(key, data, true);
- }
-
- Particle(String key, /*@NotNull*/ Class<?> data, boolean register) {
+ // Paper - all particles are registered
if (key != null) {
this.key = NamespacedKey.minecraft(key);
} else {
this.key = null;
}
dataType = data;
- this.register = register;
+ // Paper - all particles are registered
}
/**
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d40654a132b9b 100644
index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..d03bdf6617ce66950e335f0afb52c19b2e2a14e2 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -86,26 +86,32 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@ -256,7 +293,7 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d4065
/**
* Custom boss bars.
*
@@ -155,13 +161,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -155,25 +161,29 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @see Cat.Type
*/
@ -274,7 +311,11 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d4065
/**
* Server entity types.
*
@@ -172,8 +180,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see EntityType
*/
- Registry<EntityType> ENTITY_TYPE = new SimpleRegistry<>(EntityType.class, (entity) -> entity != EntityType.UNKNOWN);
+ Registry<EntityType> ENTITY_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.ENTITY_TYPE); // Paper
/**
* Server instruments.
*
* @see MusicInstrument
@ -295,7 +336,7 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d4065
/**
* Default server loot tables.
*
@@ -200,13 +210,13 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -200,25 +210,25 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see MenuType
*/
@ApiStatus.Experimental
@ -311,6 +352,20 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d4065
/**
* Server particles.
*
* @see Particle
*/
- Registry<Particle> PARTICLE_TYPE = new SimpleRegistry<>(Particle.class, (par) -> par.register);
+ Registry<Particle> PARTICLE_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.PARTICLE_TYPE); // Paper
/**
* Server potions.
*
* @see PotionType
*/
- Registry<PotionType> POTION = new SimpleRegistry<>(PotionType.class);
+ Registry<PotionType> POTION = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.POTION); // Paper
/**
* Server statistics.
*
@@ -229,58 +239,67 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* Server structures.
*
@ -428,6 +483,15 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d4065
/**
* Get the object by its key.
*
@@ -396,7 +417,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
return (namespacedKey != null) ? get(namespacedKey) : null;
}
- static final class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {
+ class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> { // Paper - remove final
private final Class<T> type;
private final Map<NamespacedKey, T> map;
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 6bc43f3a5748a1b83aa4c4d462df3cbc9220c267..cad9c18dbe56ffcef377f0b1162bc880fc56aa6c 100644
--- a/src/main/java/org/bukkit/Server.java

Datei anzeigen

@ -809,7 +809,7 @@ index 0000000000000000000000000000000000000000..bf49125acc8a0508bf59674bba3ed350
+ }
+}
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index 67b9ab322baecf5b2453df4795106514cb073108..7cf7c6d05aa6cbf3f0c8612831404552c6a7b84a 100644
index c3d49f9c640eb390f507f9521a389cb7c172983a..87907918c42b11780b285b6d82e7297628a07376 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -384,6 +384,27 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@ -875,38 +875,3 @@ index 67b9ab322baecf5b2453df4795106514cb073108..7cf7c6d05aa6cbf3f0c8612831404552
/**
* Get the object by its key.
*
@@ -561,5 +610,23 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
return value.getKey();
}
// Paper end - improve Registry
+
+ // Paper start - RegistrySet API
+ @SuppressWarnings("deprecation")
+ @Override
+ public boolean hasTag(final io.papermc.paper.registry.tag.@NotNull TagKey<T> key) {
+ return Bukkit.getUnsafe().getTag(key) != null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public io.papermc.paper.registry.tag.@NotNull Tag<T> getTag(final io.papermc.paper.registry.tag.@NotNull TagKey<T> key) {
+ final io.papermc.paper.registry.tag.Tag<T> tag = Bukkit.getUnsafe().getTag(key);
+ if (tag == null) {
+ throw new java.util.NoSuchElementException("No tag " + key + " found");
+ }
+ return tag;
+ }
+ // Paper end - RegistrySet API
}
}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index b503b5e13c51580367d53939ad4c19a7718c22ce..5b13617e497e847ef66214f9140aea0cd41f4c4f 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -281,4 +281,6 @@ public interface UnsafeValues {
// Paper end - lifecycle event API
@NotNull java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines
+
+ <A extends Keyed, M> io.papermc.paper.registry.tag.@Nullable Tag<A> getTag(io.papermc.paper.registry.tag.@NotNull TagKey<A> tagKey); // Paper - hack to get tags for non-server backed registries
}

Datei anzeigen

@ -3,6 +3,7 @@ From: Bjarne Koll <git@lynxplay.dev>
Date: Thu, 13 Jun 2024 22:35:05 +0200
Subject: [PATCH] Introduce registry entry and builders
Co-authored-by: kokiriglade <git@kokirigla.de>
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
index 647f6a1ec1f9d3c203b41f90a99bfd415bf67366..9b39e33514b15a9d07104e2ad826d0da11f569d6 100644
@ -414,6 +415,147 @@ index 0000000000000000000000000000000000000000..980fe12b75258b51cc2498590cadb9de
+ Builder range(@Range(from = 0, to = Integer.MAX_VALUE) int range);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8d133afa82da1b5b9e7a18e1c332ae3aefea50d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java
@@ -0,0 +1,135 @@
+package io.papermc.paper.registry.data;
+
+import io.papermc.paper.registry.RegistryBuilder;
+import java.util.Optional;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.text.Component;
+import org.bukkit.Art;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Range;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+/**
+ * A data-centric version-specific registry entry for the {@link Art} type.
+ */
+@ApiStatus.Experimental
+@NullMarked
+@ApiStatus.NonExtendable
+public interface PaintingVariantRegistryEntry {
+
+ /**
+ * Provides the width of this variant in blocks.
+ *
+ * @return the width
+ * @see Art#getBlockWidth()
+ */
+ @Range(from = 1, to = 16)
+ int width();
+
+ /**
+ * Provides the height of this variant in blocks.
+ *
+ * @return the height
+ * @see Art#getBlockHeight()
+ */
+ @Range(from = 1, to = 16)
+ int height();
+
+ /**
+ * Provides the title of the painting visible in the creative inventory.
+ *
+ * @return the title
+ * @see Art#title()
+ */
+ @Nullable Component title();
+
+ /**
+ * Provides the author of the painting visible in the creative inventory.
+ *
+ * @return the author
+ * @see Art#author()
+ */
+ @Nullable Component author();
+
+ /**
+ * Provides the assetId of the variant, which is the location of the sprite to use.
+ *
+ * @return the asset id
+ * @see Art#assetId()
+ */
+ Key assetId();
+
+ /**
+ * A mutable builder for the {@link PaintingVariantRegistryEntry} plugins may change in applicable registry events.
+ * <p>
+ * The following values are required for each builder:
+ * <ul>
+ * <li>{@link #width(int)}</li>
+ * <li>{@link #height(int)}</li>
+ * <li>{@link #assetId(Key)}</li>
+ * </ul>
+ */
+ @ApiStatus.Experimental
+ @ApiStatus.NonExtendable
+ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder<Art> {
+
+ /**
+ * Sets the width of the painting in blocks.
+ *
+ * @param width the width in blocks
+ * @return this builder instance
+ * @see PaintingVariantRegistryEntry#width()
+ * @see Art#getBlockWidth()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder width(@Range(from = 0, to = 16) int width);
+
+ /**
+ * Sets the height of the painting in blocks.
+ *
+ * @param height the height in blocks
+ * @return this builder instance
+ * @see PaintingVariantRegistryEntry#height()
+ * @see Art#getBlockHeight()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder height(@Range(from = 0, to = 16) int height);
+
+ /**
+ * Sets the title of the painting.
+ *
+ * @param title the title
+ * @return this builder instance
+ * @see PaintingVariantRegistryEntry#title()
+ * @see Art#title()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder title(@Nullable Component title);
+
+ /**
+ * Sets the author of the painting.
+ *
+ * @param author the author
+ * @return this builder instance
+ * @see PaintingVariantRegistryEntry#author()
+ * @see Art#author()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder author(@Nullable Component author);
+
+ /**
+ * Sets the assetId of the variant, which is the location of the sprite to use.
+ *
+ * @param assetId the asset id
+ * @return this builder instance
+ * @see PaintingVariantRegistryEntry#assetId()
+ * @see Art#assetId()
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ Builder assetId(Key assetId);
+
+ }
+
+}
diff --git a/src/main/java/io/papermc/paper/registry/data/package-info.java b/src/main/java/io/papermc/paper/registry/data/package-info.java
new file mode 100644
index 0000000000000000000000000000000000000000..4f8f536f437c5f483ac7bce393e664fd7bc38477
@ -430,15 +572,17 @@ index 0000000000000000000000000000000000000000..4f8f536f437c5f483ac7bce393e664fd
+ */
+package io.papermc.paper.registry.data;
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..1c8e77c7243cfedef6c4d1491cf98e6ec8f1690f 100644
index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..40deffbd0930508bb04e9aedfd62ad2144855198 100644
--- a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
@@ -1,8 +1,15 @@
@@ -1,8 +1,17 @@
package io.papermc.paper.registry.event;
+import io.papermc.paper.registry.RegistryKey;
+import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
+import io.papermc.paper.registry.data.GameEventRegistryEntry;
+import io.papermc.paper.registry.data.PaintingVariantRegistryEntry;
+import org.bukkit.Art;
+import org.bukkit.GameEvent;
+import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.ApiStatus;
@ -449,12 +593,13 @@ index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..1c8e77c7243cfedef6c4d1491cf98e6e
/**
* Holds providers for {@link RegistryEntryAddEvent} and {@link RegistryFreezeEvent}
* handlers for each applicable registry.
@@ -11,6 +18,9 @@ import org.jspecify.annotations.NullMarked;
@@ -11,6 +20,10 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
public final class RegistryEvents {
+ public static final RegistryEventProvider<GameEvent, GameEventRegistryEntry.Builder> GAME_EVENT = create(RegistryKey.GAME_EVENT);
+ public static final RegistryEventProvider<Enchantment, EnchantmentRegistryEntry.Builder> ENCHANTMENT = create(RegistryKey.ENCHANTMENT);
+ public static final RegistryEventProvider<Art, PaintingVariantRegistryEntry.Builder> PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT);
+
private RegistryEvents() {
}

Datei anzeigen

@ -5,13 +5,13 @@ Subject: [PATCH] Proxy ItemStack to CraftItemStack
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 5b13617e497e847ef66214f9140aea0cd41f4c4f..56d16c887b7663aab7db2f7be532d9912aeb3570 100644
index b503b5e13c51580367d53939ad4c19a7718c22ce..307439827b401acb96f0df1cf4ef31835bd1d513 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -283,4 +283,6 @@ public interface UnsafeValues {
@NotNull java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines
@@ -281,4 +281,6 @@ public interface UnsafeValues {
// Paper end - lifecycle event API
<A extends Keyed, M> io.papermc.paper.registry.tag.@Nullable Tag<A> getTag(io.papermc.paper.registry.tag.@NotNull TagKey<A> tagKey); // Paper - hack to get tags for non-server backed registries
@NotNull java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines
+
+ ItemStack createEmptyStack(); // Paper - proxy ItemStack
}

Datei anzeigen

@ -228,7 +228,7 @@ index 7ff6d60deb129e23b2a4d772aee123eb6c0b6433..52a2763773b234c581b2dcc6f0584f8d
return key;
}
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index fc089b796f5a0f2e1ab081cc710e4bb5c3f5ee7b..2a86e599175549a3021a63a837f8cc9d8da5697d 100644
index 3fdba38fd5e75ddcbfca9cee70a606bfa4a539bf..66219e3855aef885341132a7456af54cf315475f 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -1010,4 +1010,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste

Datei anzeigen

@ -247,7 +247,7 @@ index eb33e8e671972aa308ad75a7ce9aa9ac526f470f..05ecf3cb38ff42c8b52405d900197e6b
/**
* Gets the {@link Biome} at the given {@link Location}.
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 56d16c887b7663aab7db2f7be532d9912aeb3570..2dd4c16ac107f58752c725540ab414ff79c46ff4 100644
index 307439827b401acb96f0df1cf4ef31835bd1d513..e8dc8a6abebf6c31cb095ca3646eb4909e42f105 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -111,8 +111,7 @@ public interface UnsafeValues {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Item serialization as json
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 2dd4c16ac107f58752c725540ab414ff79c46ff4..79312bdda8ef0799e2d46decc52cfdac95b97d37 100644
index e8dc8a6abebf6c31cb095ca3646eb4909e42f105..a491dc40093e19b8d1900443ad613223fd7f3119 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -168,6 +168,36 @@ public interface UnsafeValues {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Void damage configuration API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index adcd8161846b06fd1a7895750f98b629204a8406..ef32a937e6faf1e8a5d6b1207986715bae5a246c 100644
index b462f2a9f7b6acbdc826d093b1de826ca682f25b..7a439c99fc4c5ee17d674460c8e58a9fe0c64e02 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -52,6 +52,54 @@ import org.jetbrains.annotations.Nullable;

Datei anzeigen

@ -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 {
@ -3932,7 +3916,7 @@ index 615eb24ffdd8f6d55ccd4f21760b809c1098bc68..c7ce8fa1ff9feda66d5a4e497112a24f
+ // Paper end - data component API
}
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index 7cf7c6d05aa6cbf3f0c8612831404552c6a7b84a..c60e31425efd7b863941f5538faef6c0552290ae 100644
index 87907918c42b11780b285b6d82e7297628a07376..d55c33ca14257be5005520e18e465da87a58dbaf 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -376,6 +376,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {

Datei anzeigen

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kokiriglade <60290002+celerry@users.noreply.github.com>
Date: Sat, 23 Nov 2024 18:08:13 +0000
Subject: [PATCH] Expanded Art API
diff --git a/src/main/java/org/bukkit/Art.java b/src/main/java/org/bukkit/Art.java
index 00a290f1bf58cdc2238c13fd5a6048a26b7871da..ed2263450e98460250e431d2ee6debd03204c175 100644
--- a/src/main/java/org/bukkit/Art.java
+++ b/src/main/java/org/bukkit/Art.java
@@ -107,6 +107,29 @@ public interface Art extends OldEnum<Art>, Keyed {
@NotNull NamespacedKey getKey();
// Paper end - deprecate getKey
+ // Paper start - name and author components, assetId key
+ /**
+ * Get the painting's title.
+ *
+ * @return the title
+ */
+ net.kyori.adventure.text.@Nullable Component title();
+
+ /**
+ * Get the painting's author.
+ *
+ * @return the author
+ */
+ net.kyori.adventure.text.@Nullable Component author();
+
+ /**
+ * Get the painting's asset id
+ *
+ * @return the asset id
+ */
+ net.kyori.adventure.key.@NotNull Key assetId();
+ // Paper end - name and author components, assetId key
+
/**
* Get a painting by its numeric ID
*

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -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));
+ }

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Remap reflection calls in plugins using internals
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
diff --git a/build.gradle.kts b/build.gradle.kts
index 24f3d0c96fe9d70b1a7cf528e09ebfc4366577ed..7aee6d9849f0a9c64db0368d2faa03c0633a72a4 100644
index 8678e5bd59a7e085cb1b4e38f29e06ce36d2c1de..8d05216e246bfaec5945cdd55d08b6a388a769e8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -62,6 +62,12 @@ dependencies {
@ -23,7 +23,7 @@ index 24f3d0c96fe9d70b1a7cf528e09ebfc4366577ed..7aee6d9849f0a9c64db0368d2faa03c0
paperweight {
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java
index 893ad5e7c2d32ccd64962d95d146bbd317c28ab8..3d73ea0e63c97b2b08e719b7be7af3894fb2d4e8 100644
index b61935052154e76b1b8cb49868c96c52f34a41d1..a2fe12513b93ded71517955ef3e52c925f56f7d1 100644
--- a/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java
+++ b/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableBiMap;
@ -32,9 +32,9 @@ index 893ad5e7c2d32ccd64962d95d146bbd317c28ab8..3d73ea0e63c97b2b08e719b7be7af389
import io.papermc.paper.configuration.serializer.collections.MapSerializer;
+import io.papermc.paper.util.MappingEnvironment;
import io.papermc.paper.util.ObfHelper;
import net.minecraft.network.protocol.Packet;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -69,7 +70,7 @@ public final class PacketClassSerializer extends ScalarSerializer<Class<? extend
import java.lang.reflect.Type;
import java.util.List;
@@ -68,7 +69,7 @@ public final class PacketClassSerializer extends ScalarSerializer<Class<? extend
@Override
protected @Nullable Object serialize(final Class<? extends Packet<?>> packetClass, final Predicate<Class<?>> typeSupported) {
final String name = packetClass.getName();

Datei anzeigen

@ -12,12 +12,13 @@ public net.minecraft.server.RegistryLayer STATIC_ACCESS
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
new file mode 100644
index 0000000000000000000000000000000000000000..c6969f968b45eff2aeb44e647712abda10c7c113
index 0000000000000000000000000000000000000000..2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
@@ -0,0 +1,156 @@
@@ -0,0 +1,157 @@
+package io.papermc.paper.registry;
+
+import com.google.common.base.Preconditions;
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.registry.entry.RegistryEntry;
+import java.util.Collections;
@ -125,16 +126,16 @@ index 0000000000000000000000000000000000000000..c6969f968b45eff2aeb44e647712abda
+ entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new).delayed(),
+
+ // api-only
+ apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, () -> org.bukkit.Registry.ENTITY_TYPE),
+ apiOnly(Registries.PARTICLE_TYPE, RegistryKey.PARTICLE_TYPE, () -> org.bukkit.Registry.PARTICLE_TYPE),
+ apiOnly(Registries.POTION, RegistryKey.POTION, () -> org.bukkit.Registry.POTION),
+ apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, PaperSimpleRegistry::entityType),
+ apiOnly(Registries.PARTICLE_TYPE, RegistryKey.PARTICLE_TYPE, PaperSimpleRegistry::particleType),
+ apiOnly(Registries.POTION, RegistryKey.POTION, PaperSimpleRegistry::potion),
+ apiOnly(Registries.MEMORY_MODULE_TYPE, RegistryKey.MEMORY_MODULE_TYPE, () -> (org.bukkit.Registry<MemoryKey<?>>) (org.bukkit.Registry) org.bukkit.Registry.MEMORY_MODULE_TYPE)
+ );
+ final Map<RegistryKey<?>, RegistryEntry<?, ?>> byRegistryKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size());
+ final Map<ResourceKey<?>, RegistryEntry<?, ?>> byResourceKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size());
+ for (final RegistryEntry<?, ?> entry : REGISTRY_ENTRIES) {
+ byRegistryKey.put(entry.apiKey(), entry);
+ byResourceKey.put(entry.mcKey(), entry);
+ Preconditions.checkState(byRegistryKey.put(entry.apiKey(), entry) == null, "Duplicate api registry key: %s", entry.apiKey());
+ Preconditions.checkState(byResourceKey.put(entry.mcKey(), entry) == null, "Duplicate mc registry key: %s", entry.mcKey());
+ }
+ BY_REGISTRY_KEY = Collections.unmodifiableMap(byRegistryKey);
+ BY_RESOURCE_KEY = Collections.unmodifiableMap(byResourceKey);
@ -305,6 +306,50 @@ index 0000000000000000000000000000000000000000..35b6a7c5bac9640332a833bd3627f2bc
+ return (RegistryKey<T>) LegacyRegistryIdentifiers.CLASS_TO_KEY_MAP.get(type);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java b/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..6d134ace042758da722960cbcb48e52508dafd61
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java
@@ -0,0 +1,38 @@
+package io.papermc.paper.registry;
+
+import java.util.function.Predicate;
+import net.minecraft.core.registries.BuiltInRegistries;
+import org.bukkit.Keyed;
+import org.bukkit.Particle;
+import org.bukkit.Registry;
+import org.bukkit.entity.EntityType;
+import org.bukkit.potion.PotionType;
+import org.jspecify.annotations.NullMarked;
+
+@NullMarked
+public class PaperSimpleRegistry<T extends Enum<T> & Keyed, M> extends Registry.SimpleRegistry<T> {
+
+ static Registry<EntityType> entityType() {
+ return new PaperSimpleRegistry<>(EntityType.class, entity -> entity != EntityType.UNKNOWN, BuiltInRegistries.ENTITY_TYPE);
+ }
+
+ static Registry<Particle> particleType() {
+ return new PaperSimpleRegistry<>(Particle.class, BuiltInRegistries.PARTICLE_TYPE);
+ }
+
+ static Registry<PotionType> potion() {
+ return new PaperSimpleRegistry<>(PotionType.class, BuiltInRegistries.POTION);
+ }
+
+ private final net.minecraft.core.Registry<M> nmsRegistry;
+
+ protected PaperSimpleRegistry(final Class<T> type, final net.minecraft.core.Registry<M> nmsRegistry) {
+ super(type);
+ this.nmsRegistry = nmsRegistry;
+ }
+
+ public PaperSimpleRegistry(final Class<T> type, final Predicate<T> predicate, final net.minecraft.core.Registry<M> nmsRegistry) {
+ super(type, predicate);
+ this.nmsRegistry = nmsRegistry;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/RegistryHolder.java b/src/main/java/io/papermc/paper/registry/RegistryHolder.java
new file mode 100644
index 0000000000000000000000000000000000000000..a31bdd9f02fe75a87fceb2ebe8c36b3232a561cc

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add onboarding message for initial server start
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
index d9502ba028a96f9cc846f9ed428bd8066b857ca3..87e5f614ba988547a827486740db217e28585773 100644
index 007e01d329a31acf7f4ed4c6dc4de7ad54ccad04..8cf720f08514e8e4f62f4ad196f1277bd761c6b2 100644
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
@@ -129,6 +129,7 @@ public abstract class Configurations<G, W> {
@@ -127,6 +127,7 @@ public abstract class Configurations<G, W> {
if (Files.notExists(configFile)) {
node = CommentedConfigurationNode.root(loader.defaultOptions());
node.node(Configuration.VERSION_FIELD).raw(this.globalConfigVersion());
@ -17,7 +17,7 @@ index d9502ba028a96f9cc846f9ed428bd8066b857ca3..87e5f614ba988547a827486740db217e
node = loader.load();
this.verifyGlobalConfigVersion(node);
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 56798215644d8bca1695856b3a941e8089f49e48..46c37c8db8ecf3cc808fcf59f6bee5fe6ca49b75 100644
index e0cef37664b64f5db95943c5c118424436163e06..5e9c471ab20b0391e7e41351c65d96745fc8ce4a 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -25,6 +25,7 @@ public class GlobalConfiguration extends ConfigurationPart {

Datei anzeigen

@ -48,3 +48,16 @@ index d08eec460a67fbd0b2ed2e0dd6d557dc629f4dfe..555d1b05ef6278567de598488b9486db
}
public CombatTracker getCombatTracker() {
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index fc19bd326f00d1e8bd08ef6cc430c555337a6e3d..fb84ee1225cd762ef306d1fc3e1baed42c034a3c 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -388,7 +388,7 @@ public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder<Hol
}
}
- return false; // CraftBukkit
+ return true; // CraftBukkit // Paper - return false ONLY if event was cancelled
}
private boolean canArmorAbsorb(DamageSource source) {

Datei anzeigen

@ -11,18 +11,18 @@ public net.minecraft.resources.RegistryOps lookupProvider
public net.minecraft.resources.RegistryOps$HolderLookupAdapter
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
index c6969f968b45eff2aeb44e647712abda10c7c113..d34ffad8a36abbb215491d74ae8d9b490a0bc64f 100644
index 2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91..3ec2aa5da045b62809afd2c13fc9ae74189dbdad 100644
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
@@ -2,6 +2,7 @@ package io.papermc.paper.registry;
@@ -3,6 +3,7 @@ package io.papermc.paper.registry;
import com.google.common.base.Preconditions;
import io.papermc.paper.adventure.PaperAdventure;
import io.papermc.paper.registry.entry.RegistryEntry;
+import io.papermc.paper.registry.tag.TagKey;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
@@ -68,6 +69,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@@ -69,6 +70,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
import static io.papermc.paper.registry.entry.RegistryEntry.entry;
@ -30,7 +30,7 @@ index c6969f968b45eff2aeb44e647712abda10c7c113..d34ffad8a36abbb215491d74ae8d9b49
@DefaultQualifier(NonNull.class)
public final class PaperRegistries {
@@ -151,6 +153,15 @@ public final class PaperRegistries {
@@ -152,6 +154,15 @@ public final class PaperRegistries {
return ResourceKey.create((ResourceKey<? extends Registry<M>>) PaperRegistries.registryToNms(typedKey.registryKey()), PaperAdventure.asVanilla(typedKey.key()));
}
@ -286,6 +286,38 @@ index 0000000000000000000000000000000000000000..69e946173407eb05b18a2b19b0d45cbb
+ return this.freezeEventTypes.getOrCreate(type.registryKey(), RegistryLifecycleEventType::new);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java b/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java
index 6d134ace042758da722960cbcb48e52508dafd61..cc39bc68d29055ef6429f08f975412bd9fe68dbc 100644
--- a/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java
+++ b/src/main/java/io/papermc/paper/registry/PaperSimpleRegistry.java
@@ -1,6 +1,10 @@
package io.papermc.paper.registry;
+import io.papermc.paper.registry.set.NamedRegistryKeySetImpl;
+import io.papermc.paper.registry.tag.Tag;
+import io.papermc.paper.registry.tag.TagKey;
import java.util.function.Predicate;
+import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.BuiltInRegistries;
import org.bukkit.Keyed;
import org.bukkit.Particle;
@@ -35,4 +39,16 @@ public class PaperSimpleRegistry<T extends Enum<T> & Keyed, M> extends Registry.
super(type, predicate);
this.nmsRegistry = nmsRegistry;
}
+
+ @Override
+ public boolean hasTag(final TagKey<T> key) {
+ final net.minecraft.tags.TagKey<M> nmsKey = PaperRegistries.toNms(key);
+ return this.nmsRegistry.get(nmsKey).isPresent();
+ }
+
+ @Override
+ public Tag<T> getTag(final TagKey<T> key) {
+ final HolderSet.Named<M> namedHolderSet = this.nmsRegistry.get(PaperRegistries.toNms(key)).orElseThrow();
+ return new NamedRegistryKeySetImpl<>(key, namedHolderSet);
+ }
}
diff --git a/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java b/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..78317c7ab42a666f19634593a8f3b696700764c8
@ -1174,7 +1206,7 @@ index 4638ba98dbbdb0f880337347be85a6e0fbed2191..bc448f8511c629d1f13d4baf717a11e6
}
}
diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b68f8daaf8 100644
index 61774165a25209ee6d26cf8d80149b220c3874e6..c5e279216f6cb880397ea2768ee6e99a8798e3e1 100644
--- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java
+++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
@@ -130,7 +130,7 @@ public class RegistryDataLoader {
@ -1195,7 +1227,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6
}
private static RegistryAccess.Frozen load(
@@ -148,9 +148,11 @@ public class RegistryDataLoader {
@@ -148,7 +148,8 @@ public class RegistryDataLoader {
Map<ResourceKey<?>, Exception> map = new HashMap<>();
List<RegistryDataLoader.Loader<?>> list = entries.stream().map(entry -> entry.create(Lifecycle.stable(), map)).collect(Collectors.toUnmodifiableList());
RegistryOps.RegistryInfoLookup registryInfoLookup = createContext(registries, list);
@ -1204,11 +1236,8 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6
+ list.forEach(loader -> loadable.apply((RegistryDataLoader.Loader<?>)loader, registryInfoLookup, conversions));
list.forEach(loader -> {
Registry<?> registry = loader.registry();
+ io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(loader.registry.key(), conversions); // Paper - run pre-freeze listeners
try {
registry.freeze();
@@ -238,13 +240,13 @@ public class RegistryDataLoader {
@@ -238,13 +239,13 @@ public class RegistryDataLoader {
}
private static <E> void loadElementFromResource(
@ -1224,7 +1253,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6
}
}
@@ -253,7 +255,8 @@ public class RegistryDataLoader {
@@ -253,7 +254,8 @@ public class RegistryDataLoader {
RegistryOps.RegistryInfoLookup infoGetter,
WritableRegistry<E> registry,
Decoder<E> elementDecoder,
@ -1234,7 +1263,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6
) {
String string = Registries.elementsDirPath(registry.key());
FileToIdConverter fileToIdConverter = FileToIdConverter.json(string);
@@ -266,7 +269,7 @@ public class RegistryDataLoader {
@@ -266,7 +268,7 @@ public class RegistryDataLoader {
RegistrationInfo registrationInfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo());
try {
@ -1243,6 +1272,14 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6
} catch (Exception var15) {
errors.put(
resourceKey,
@@ -275,6 +277,7 @@ public class RegistryDataLoader {
}
}
+ io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(registry.key(), conversions); // Paper - run pre-freeze listeners
TagLoader.loadTagsForRegistry(resourceManager, registry);
}
@@ -284,7 +287,8 @@ public class RegistryDataLoader {
RegistryOps.RegistryInfoLookup infoGetter,
WritableRegistry<E> registry,
@ -1360,32 +1397,6 @@ index 45c78c113e881b277e1216293ad918ee40b44325..8314059455d91f01b986c5c0a239f418
+ }
+ // Paper end - RegistrySet API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index f0556a207f6d9d1766ef0d9753355f7fa5052dc1..f55733b7a56ac21cb297971b9e854ef54001ca26 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -666,6 +666,21 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
// Paper end - lifecycle event API
+ // Paper start - hack to get tags for non server-backed registries
+ @Override
+ public <A extends Keyed, M> io.papermc.paper.registry.tag.Tag<A> getTag(final io.papermc.paper.registry.tag.TagKey<A> tagKey) { // TODO remove Keyed
+ if (tagKey.registryKey() != io.papermc.paper.registry.RegistryKey.ENTITY_TYPE && tagKey.registryKey() != io.papermc.paper.registry.RegistryKey.FLUID) {
+ throw new UnsupportedOperationException(tagKey.registryKey() + " doesn't have tags");
+ }
+ final net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<M>> nmsKey = io.papermc.paper.registry.PaperRegistries.registryToNms(tagKey.registryKey());
+ final net.minecraft.core.Registry<M> nmsRegistry = org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry().lookupOrThrow(nmsKey);
+ return nmsRegistry
+ .get(io.papermc.paper.registry.PaperRegistries.toNms(tagKey))
+ .map(named -> new io.papermc.paper.registry.set.NamedRegistryKeySetImpl<>(tagKey, named))
+ .orElse(null);
+ }
+ // Paper end - hack to get tags for non server-backed registries
+
/**
* This helper class represents the different NBT Tags.
* <p>
diff --git a/src/main/resources/META-INF/services/io.papermc.paper.registry.event.RegistryEventTypeProvider b/src/main/resources/META-INF/services/io.papermc.paper.registry.event.RegistryEventTypeProvider
new file mode 100644
index 0000000000000000000000000000000000000000..8bee1a5ed877a04e4d027593df1f42cefdd824e7

Datei anzeigen

@ -6,19 +6,20 @@ Subject: [PATCH] Add registry entry and builders
Feature patch
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
index d34ffad8a36abbb215491d74ae8d9b490a0bc64f..f8c6da955e4bd0e480c7b581d2a4325738f9dd6f 100644
index 3ec2aa5da045b62809afd2c13fc9ae74189dbdad..31d660bbbe62cd2c26715e8d90fef58b8e024e34 100644
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
@@ -1,6 +1,8 @@
package io.papermc.paper.registry;
@@ -2,6 +2,9 @@ package io.papermc.paper.registry;
import com.google.common.base.Preconditions;
import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry;
+import io.papermc.paper.registry.data.PaperGameEventRegistryEntry;
+import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry;
import io.papermc.paper.registry.entry.RegistryEntry;
import io.papermc.paper.registry.tag.TagKey;
import java.util.Collections;
@@ -80,7 +82,7 @@ public final class PaperRegistries {
@@ -81,7 +84,7 @@ public final class PaperRegistries {
static {
REGISTRY_ENTRIES = List.of(
// built-ins
@ -27,7 +28,7 @@ index d34ffad8a36abbb215491d74ae8d9b490a0bc64f..f8c6da955e4bd0e480c7b581d2a43257
entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new),
entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new),
entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new),
@@ -102,7 +104,7 @@ public final class PaperRegistries {
@@ -103,10 +106,10 @@ public final class PaperRegistries {
entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(),
entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(),
entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(),
@ -35,7 +36,11 @@ index d34ffad8a36abbb215491d74ae8d9b490a0bc64f..f8c6da955e4bd0e480c7b581d2a43257
+ writable(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new, PaperEnchantmentRegistryEntry.PaperBuilder::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(),
entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(),
entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(),
entry(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, Art.class, CraftArt::new).delayed(),
- entry(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, Art.class, CraftArt::new).delayed(),
+ writable(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, Art.class, CraftArt::new, PaperPaintingVariantRegistryEntry.PaperBuilder::new).delayed(),
entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new).delayed(),
// api-only
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..481f5f0cfae1fada3bc3f873fb7e04c3086ea9bf
@ -339,6 +344,132 @@ index 0000000000000000000000000000000000000000..18f9463ae23ba2d9c65ffb7531a87c92
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..21cb8c28c0027b4b2446279f6cf9dbedfc8945d5
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java
@@ -0,0 +1,120 @@
+package io.papermc.paper.registry.data;
+
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.registry.PaperRegistryBuilder;
+import io.papermc.paper.registry.TypedKey;
+import io.papermc.paper.registry.data.util.Conversions;
+import java.util.Optional;
+import java.util.OptionalInt;
+import net.kyori.adventure.key.Key;
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.entity.decoration.PaintingVariant;
+import org.bukkit.Art;
+import org.jetbrains.annotations.Range;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+import static io.papermc.paper.registry.data.util.Checks.asArgument;
+import static io.papermc.paper.registry.data.util.Checks.asArgumentRange;
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
+
+@NullMarked
+public class PaperPaintingVariantRegistryEntry implements PaintingVariantRegistryEntry {
+
+ protected OptionalInt width = OptionalInt.empty();
+ protected OptionalInt height = OptionalInt.empty();
+ protected @Nullable Component title;
+ protected @Nullable Component author;
+ protected @Nullable ResourceLocation assetId;
+
+ protected final Conversions conversions;
+
+ public PaperPaintingVariantRegistryEntry(
+ final Conversions conversions,
+ final TypedKey<Art> ignoredKey,
+ final @Nullable PaintingVariant nms
+ ) {
+ this.conversions = conversions;
+ if(nms == null) return;
+
+ this.width = OptionalInt.of(nms.width());
+ this.height = OptionalInt.of(nms.height());
+ this.title = nms.title().orElse(null);
+ this.author = nms.title().orElse(null);
+ this.assetId = nms.assetId();
+ }
+
+ @Override
+ public @Range(from = 1, to = 16) int width() {
+ return asConfigured(this.width, "width");
+ }
+
+ @Override
+ public @Range(from = 1, to = 16) int height() {
+ return asConfigured(this.height, "height");
+ }
+
+ @Override
+ public net.kyori.adventure.text.@Nullable Component title() {
+ return this.title == null ? null : this.conversions.asAdventure(this.title);
+ }
+
+ @Override
+ public net.kyori.adventure.text.@Nullable Component author() {
+ return this.author == null ? null : this.conversions.asAdventure(this.author);
+ }
+
+ @Override
+ public Key assetId() {
+ return PaperAdventure.asAdventure(asConfigured(this.assetId, "assetId"));
+ }
+
+ public static final class PaperBuilder extends PaperPaintingVariantRegistryEntry implements PaintingVariantRegistryEntry.Builder, PaperRegistryBuilder<PaintingVariant, Art> {
+
+ public PaperBuilder(final Conversions conversions, final TypedKey<Art> key, final @Nullable PaintingVariant nms) {
+ super(conversions, key, nms);
+ }
+
+ @Override
+ public Builder width(@Range(from = 0, to = 16) final int width) {
+ this.width = OptionalInt.of(asArgumentRange(width, "width", 1, 16));
+ return this;
+ }
+
+ @Override
+ public Builder height(@Range(from = 0, to = 16) final int height) {
+ this.height = OptionalInt.of(asArgumentRange(height, "height", 1, 16));
+ return this;
+ }
+
+ @Override
+ public Builder title(final net.kyori.adventure.text.@Nullable Component title) {
+ this.title = this.conversions.asVanilla(title);
+ return this;
+ }
+
+ @Override
+ public Builder author(final net.kyori.adventure.text.@Nullable Component author) {
+ this.author = this.conversions.asVanilla(author);
+ return this;
+ }
+
+ @Override
+ public Builder assetId(final Key assetId) {
+ this.assetId = PaperAdventure.asVanilla(asArgument(assetId, "assetId"));
+ return this;
+ }
+
+ @Override
+ public PaintingVariant build() {
+ return new PaintingVariant(
+ this.width(),
+ this.height(),
+ asConfigured(this.assetId, "assetId"),
+ Optional.ofNullable(this.title),
+ Optional.ofNullable(this.author)
+ );
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/data/util/Checks.java b/src/main/java/io/papermc/paper/registry/data/util/Checks.java
new file mode 100644
index 0000000000000000000000000000000000000000..3241a94731fe8163876614efdcf30f8b551535af

Datei anzeigen

@ -205,12 +205,12 @@ index 6cc9d7a9e6d4bfdc27e52fc581b2bb832616f121..6930d0afb230a88aa813b02e4d55c95d
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index f55733b7a56ac21cb297971b9e854ef54001ca26..8af9ac9e22a15457da12f0746d0e411942c278fb 100644
index f0556a207f6d9d1766ef0d9753355f7fa5052dc1..2539802c0a02b6a564bdbd58e93ffe5685e775b9 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -681,6 +681,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
@@ -666,6 +666,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
// Paper end - hack to get tags for non server-backed registries
// Paper end - lifecycle event API
+ // Paper start - proxy ItemStack
+ @Override

Datei anzeigen

@ -284,7 +284,7 @@ index 6cf790c9fa23ea313423fdaeb7c181bf530828c6..0bcb9df1103050441f8922a688b163dc
public static PotionEffectType minecraftHolderToBukkit(Holder<MobEffect> minecraft) {
return CraftPotionEffectType.minecraftToBukkit(minecraft.value());
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 8af9ac9e22a15457da12f0746d0e411942c278fb..f4ccdd848dd64e97796ef952d2aeacb3219da1bd 100644
index 2539802c0a02b6a564bdbd58e93ffe5685e775b9..44c9127c71402afd6f98215b9e66fe5b848db50b 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -48,7 +48,7 @@ import org.bukkit.attribute.Attribute;

Datei anzeigen

@ -461,13 +461,13 @@ index 0000000000000000000000000000000000000000..d6d4bfc6f45d646afeace422a038c670
+) {
+}
diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
index fdc88e52235a152dbe3cca273990b4b68f8daaf8..13797035494a1e010e1da529fb46040f8a6e859f 100644
index c5e279216f6cb880397ea2768ee6e99a8798e3e1..46bf2b95658ca3bbd3048df5f8adf1bdcc2d3571 100644
--- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java
+++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
@@ -278,7 +278,7 @@ public class RegistryDataLoader {
}
}
io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(registry.key(), conversions); // Paper - run pre-freeze listeners
- TagLoader.loadTagsForRegistry(resourceManager, registry);
+ TagLoader.loadTagsForRegistry(resourceManager, registry, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - tag lifecycle - add cause
}

Datei anzeigen

@ -28,7 +28,7 @@ index c80fd4960dfbb0fde37363e7df25b0a5411bdb11..ff7f6916f65466c25a7bde35d64682c1
public static final Codec<CustomData> CODEC_WITH_ID = CODEC.validate(
component -> component.getUnsafe().contains("id", 8) ? DataResult.success(component) : DataResult.error(() -> "Missing id for entity in: " + component)
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index f4ccdd848dd64e97796ef952d2aeacb3219da1bd..29d5fa49730d2161bb1b024995a533a08c57939b 100644
index 44c9127c71402afd6f98215b9e66fe5b848db50b..4c82dae4c2d764c8310832b1a209846d4352bae9 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -527,6 +527,39 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -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
@ -3640,19 +3589,19 @@ index 0000000000000000000000000000000000000000..62aa1061c35d5358e6dec16a52574b42
+
+import org.jspecify.annotations.NullMarked;
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
index f8c6da955e4bd0e480c7b581d2a4325738f9dd6f..ee1fce58c6e57dd93a30ee66e7488a92f9da2fe3 100644
index 31d660bbbe62cd2c26715e8d90fef58b8e024e34..7e5d1d4f563dfd4beef9cd73b3670714c96bacaf 100644
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
@@ -1,6 +1,8 @@
package io.papermc.paper.registry;
@@ -2,6 +2,8 @@ package io.papermc.paper.registry;
import com.google.common.base.Preconditions;
import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.datacomponent.DataComponentType;
+import io.papermc.paper.datacomponent.PaperComponentType;
import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry;
import io.papermc.paper.registry.data.PaperGameEventRegistryEntry;
import io.papermc.paper.registry.entry.RegistryEntry;
@@ -96,6 +98,7 @@ public final class PaperRegistries {
import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry;
@@ -98,6 +100,7 @@ public final class PaperRegistries {
entry(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, Attribute.class, CraftAttribute::new),
entry(Registries.FLUID, RegistryKey.FLUID, Fluid.class, CraftFluid::new),
entry(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, Sound.class, CraftSound::new),
@ -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

Datei anzeigen

@ -30384,7 +30384,7 @@ index b54a3741cd3ba615c83c98985cb4b3c4c586ed7a..b148cf247acdd36f856d0495cde4cc5a
return nbttagcompound;
});
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 29d5fa49730d2161bb1b024995a533a08c57939b..83020837e29ee627b1081daddb4bdee147b95af3 100644
index 4c82dae4c2d764c8310832b1a209846d4352bae9..507f908916cbeb592496f963b46e4c2121a7b5e3 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -523,7 +523,7 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -38,7 +38,7 @@ index f1999729cd1c00071c5e1835ee49ea5fcafa7b05..4896c3ba81ead769972fa9efdbe563d4
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 38ac7fd8e68f535a5e9bdd816997e865b7694af1..b1ecc218034944533967375d11297705c3fc01a3 100644
index 10a9406e96ab0ab2404c0e0a9bef08e86a6a12a2..078a14ee8956a56b129be92a26d19c1c536c9589 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -492,7 +492,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon

Datei anzeigen

@ -37,7 +37,7 @@ index 4896c3ba81ead769972fa9efdbe563d4006e4401..5b3a886c624b36557cbfaccdc3fb05a4
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index b1ecc218034944533967375d11297705c3fc01a3..aaaadb7be8abf867624a1ca83371595bef4ab633 100644
index 078a14ee8956a56b129be92a26d19c1c536c9589..61a73a234d9bdd22958ae261b7d0359179f7a57b 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -555,7 +555,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon

Datei anzeigen

@ -13,7 +13,7 @@ public net.minecraft.world.item.ItemStackLinkedSet TYPE_AND_TAG
diff --git a/src/main/java/io/papermc/paper/inventory/recipe/ItemOrExact.java b/src/main/java/io/papermc/paper/inventory/recipe/ItemOrExact.java
new file mode 100644
index 0000000000000000000000000000000000000000..5bcc814d5a1b88991e9c1324b88a919ca199fcda
index 0000000000000000000000000000000000000000..caaad8f54fb892dfd6c7d4e02ab9c32997f89a6a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/inventory/recipe/ItemOrExact.java
@@ -0,0 +1,63 @@
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..5bcc814d5a1b88991e9c1324b88a919c
+
+ int getMaxStackSize();
+
+ boolean is(ItemStack stack);
+ boolean matches(ItemStack stack);
+
+ record Item(Holder<net.minecraft.world.item.Item> item) implements ItemOrExact {
+
@ -40,8 +40,8 @@ index 0000000000000000000000000000000000000000..5bcc814d5a1b88991e9c1324b88a919c
+ }
+
+ @Override
+ public boolean is(final ItemStack stack) {
+ return stack.is(this.item);
+ public boolean matches(final ItemStack stack) {
+ return stack.is(this.item) && stack.getComponentsPatch().isEmpty();
+ }
+
+ @Override
@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..5bcc814d5a1b88991e9c1324b88a919c
+ }
+
+ @Override
+ public boolean is(final ItemStack stack) {
+ public boolean matches(final ItemStack stack) {
+ return ItemStack.isSameItemSameComponents(this.stack, stack);
+ }
+
@ -196,7 +196,7 @@ index 462a970ffa610bc1eb3c813dafb768c014d077d1..1afb544fb028b645821063ba1eaa9e3c
if (i == -1) {
return -1;
diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java
index ad82e5aeb565b23c3ec565fa60e1f31d1710bd4e..0e214d502998e9eb959952b257844529992df0df 100644
index ad82e5aeb565b23c3ec565fa60e1f31d1710bd4e..0990bcf65f484b9a019c91fcdae1783bac6388da 100644
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
@@ -201,11 +201,11 @@ public class Inventory implements Container, Nameable {
@ -209,7 +209,7 @@ index ad82e5aeb565b23c3ec565fa60e1f31d1710bd4e..0e214d502998e9eb959952b257844529
ItemStack itemstack = (ItemStack) this.items.get(i);
- if (!itemstack.isEmpty() && itemstack.is(item) && Inventory.isUsableForCrafting(itemstack)) {
+ if (!itemstack.isEmpty() && item.is(itemstack) && (!(item instanceof io.papermc.paper.inventory.recipe.ItemOrExact.Item) || isUsableForCrafting(itemstack))) { // Paper - Improve exact choice recipe ingredients
+ if (!itemstack.isEmpty() && item.matches(itemstack) && (!(item instanceof io.papermc.paper.inventory.recipe.ItemOrExact.Item) || isUsableForCrafting(itemstack))) { // Paper - Improve exact choice recipe ingredients
return i;
}
}

Datei anzeigen

@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Raneri <kevin.raneri@gmail.com>
Date: Mon, 30 Sep 2024 09:50:55 -0700
Subject: [PATCH] Configurable Entity Despawn Time
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8be1b051543cda2b2e9e3d337834757e53f442de..ed5b00620527c1776722d25b1b45f1544802a341 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -432,6 +432,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
private UUID originWorld;
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
public boolean fixedPose = false; // Paper - Expand Pose API
+ private final int despawnTime; // Paper - entity despawn time limit
public void setOrigin(@javax.annotation.Nonnull Location location) {
this.origin = location.toVector();
@@ -614,6 +615,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
+ this.despawnTime = type == EntityType.PLAYER ? -1 : world.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit
this.passengers = ImmutableList.of();
this.deltaMovement = Vec3.ZERO;
this.bb = Entity.INITIAL_AABB;
@@ -912,6 +914,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
public void tick() {
+ // Paper start - entity despawn time limit
+ if (this.despawnTime >= 0 && this.tickCount >= this.despawnTime) {
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
+ return;
+ }
+ // Paper end - entity despawn time limit
this.baseTick();
}

Datei anzeigen

@ -0,0 +1,53 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kokiriglade <60290002+celerry@users.noreply.github.com>
Date: Sat, 23 Nov 2024 18:58:49 +0000
Subject: [PATCH] Expanded Art API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java
index 40af940193d0df66bbcdcf5f46132e304016a4d7..932118f5e5bfc765c852acaf21f9721d8fa5fb6a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftArt.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java
@@ -42,6 +42,9 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
private final NamespacedKey key;
private final PaintingVariant paintingVariant;
+ private final net.kyori.adventure.text.@org.jspecify.annotations.Nullable Component adventureTitle; // Paper - name and author components, assetId key
+ private final net.kyori.adventure.text.@org.jspecify.annotations.Nullable Component adventureAuthor; // Paper - name and author components, assetId key
+ private final net.kyori.adventure.key.@org.jspecify.annotations.NonNull Key adventureAssetId; // Paper - name and author components, assetId key
private final String name;
private final int ordinal;
@@ -58,6 +61,9 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
this.name = key.toString();
}
this.ordinal = CraftArt.count++;
+ this.adventureTitle = paintingVariant.title().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).orElse(null); // Paper - name and author components, assetId key
+ this.adventureAuthor = paintingVariant.author().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).orElse(null); // Paper - name and author components, assetId key
+ this.adventureAssetId = io.papermc.paper.adventure.PaperAdventure.asAdventure(paintingVariant.assetId()); // Paper - name and author components, assetId key
}
@Override
@@ -75,6 +81,22 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
return this.paintingVariant.height();
}
+ // Paper start - name and author components, assetId key
+ @Override
+ public net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component title() {
+ return this.adventureTitle;
+ }
+
+ @Override
+ public net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component author() {
+ return this.adventureAuthor;
+ }
+
+ public net.kyori.adventure.key.@org.jspecify.annotations.NonNull Key assetId() {
+ return this.adventureAssetId;
+ }
+ // Paper end - name and author components, assetId key
+
@Override
public int getId() {
return CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getId(this.paintingVariant);

Datei anzeigen

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <git@lynxplay.dev>
Date: Sat, 23 Nov 2024 22:48:26 +0100
Subject: [PATCH] Call ProjectileHitEvent for entity hits
A simple bugfix replacing a new vanilla call to
Projectile#hitTargetOrDeflectSelf with the bukkit replacement to call
the event.
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
index accc246f441c8bf5e1a755cfc0db8f97c0c01c6b..571f0699772eecbe02d71845da82a142321f2142 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -309,7 +309,7 @@ public abstract class AbstractArrow extends Projectile {
continue;
}
- ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(movingobjectpositionentity);
+ ProjectileDeflection projectiledeflection = this.preHitTargetOrDeflectSelf(movingobjectpositionentity); // Paper - also call projectile hit event
this.hasImpulse = true;
if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) {