Painting variant registry modification API (#11648)
This commit is contained in:
parent
edabff8a35
commit
6051dac82b
16 changed files with 391 additions and 22 deletions
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3916,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> {
|
||||
|
|
40
patches/api/0500-Expanded-Art-API.patch
Normal file
40
patches/api/0500-Expanded-Art-API.patch
Normal file
|
@ -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
|
||||
*
|
Loading…
Add table
Add a link
Reference in a new issue