Skip to content

Commit 6051dac

Browse files
authored
Painting variant registry modification API (#11648)
1 parent edabff8 commit 6051dac

16 files changed

+391
-22
lines changed

patches/api/0472-Introduce-registry-entry-and-builders.patch

Lines changed: 148 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ From: Bjarne Koll <[email protected]>
33
Date: Thu, 13 Jun 2024 22:35:05 +0200
44
Subject: [PATCH] Introduce registry entry and builders
55

6+
Co-authored-by: kokiriglade <[email protected]>
67

78
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
89
index 647f6a1ec1f9d3c203b41f90a99bfd415bf67366..9b39e33514b15a9d07104e2ad826d0da11f569d6 100644
@@ -414,6 +415,147 @@ index 0000000000000000000000000000000000000000..980fe12b75258b51cc2498590cadb9de
414415
+ Builder range(@Range(from = 0, to = Integer.MAX_VALUE) int range);
415416
+ }
416417
+}
418+
diff --git a/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java
419+
new file mode 100644
420+
index 0000000000000000000000000000000000000000..b8d133afa82da1b5b9e7a18e1c332ae3aefea50d
421+
--- /dev/null
422+
+++ b/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java
423+
@@ -0,0 +1,135 @@
424+
+package io.papermc.paper.registry.data;
425+
+
426+
+import io.papermc.paper.registry.RegistryBuilder;
427+
+import java.util.Optional;
428+
+import net.kyori.adventure.key.Key;
429+
+import net.kyori.adventure.text.Component;
430+
+import org.bukkit.Art;
431+
+import org.jetbrains.annotations.ApiStatus;
432+
+import org.jetbrains.annotations.Contract;
433+
+import org.jetbrains.annotations.Range;
434+
+import org.jspecify.annotations.NullMarked;
435+
+import org.jspecify.annotations.Nullable;
436+
+
437+
+/**
438+
+ * A data-centric version-specific registry entry for the {@link Art} type.
439+
+ */
440+
+@ApiStatus.Experimental
441+
+@NullMarked
442+
+@ApiStatus.NonExtendable
443+
+public interface PaintingVariantRegistryEntry {
444+
+
445+
+ /**
446+
+ * Provides the width of this variant in blocks.
447+
+ *
448+
+ * @return the width
449+
+ * @see Art#getBlockWidth()
450+
+ */
451+
+ @Range(from = 1, to = 16)
452+
+ int width();
453+
+
454+
+ /**
455+
+ * Provides the height of this variant in blocks.
456+
+ *
457+
+ * @return the height
458+
+ * @see Art#getBlockHeight()
459+
+ */
460+
+ @Range(from = 1, to = 16)
461+
+ int height();
462+
+
463+
+ /**
464+
+ * Provides the title of the painting visible in the creative inventory.
465+
+ *
466+
+ * @return the title
467+
+ * @see Art#title()
468+
+ */
469+
+ @Nullable Component title();
470+
+
471+
+ /**
472+
+ * Provides the author of the painting visible in the creative inventory.
473+
+ *
474+
+ * @return the author
475+
+ * @see Art#author()
476+
+ */
477+
+ @Nullable Component author();
478+
+
479+
+ /**
480+
+ * Provides the assetId of the variant, which is the location of the sprite to use.
481+
+ *
482+
+ * @return the asset id
483+
+ * @see Art#assetId()
484+
+ */
485+
+ Key assetId();
486+
+
487+
+ /**
488+
+ * A mutable builder for the {@link PaintingVariantRegistryEntry} plugins may change in applicable registry events.
489+
+ * <p>
490+
+ * The following values are required for each builder:
491+
+ * <ul>
492+
+ * <li>{@link #width(int)}</li>
493+
+ * <li>{@link #height(int)}</li>
494+
+ * <li>{@link #assetId(Key)}</li>
495+
+ * </ul>
496+
+ */
497+
+ @ApiStatus.Experimental
498+
+ @ApiStatus.NonExtendable
499+
+ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder<Art> {
500+
+
501+
+ /**
502+
+ * Sets the width of the painting in blocks.
503+
+ *
504+
+ * @param width the width in blocks
505+
+ * @return this builder instance
506+
+ * @see PaintingVariantRegistryEntry#width()
507+
+ * @see Art#getBlockWidth()
508+
+ */
509+
+ @Contract(value = "_ -> this", mutates = "this")
510+
+ Builder width(@Range(from = 0, to = 16) int width);
511+
+
512+
+ /**
513+
+ * Sets the height of the painting in blocks.
514+
+ *
515+
+ * @param height the height in blocks
516+
+ * @return this builder instance
517+
+ * @see PaintingVariantRegistryEntry#height()
518+
+ * @see Art#getBlockHeight()
519+
+ */
520+
+ @Contract(value = "_ -> this", mutates = "this")
521+
+ Builder height(@Range(from = 0, to = 16) int height);
522+
+
523+
+ /**
524+
+ * Sets the title of the painting.
525+
+ *
526+
+ * @param title the title
527+
+ * @return this builder instance
528+
+ * @see PaintingVariantRegistryEntry#title()
529+
+ * @see Art#title()
530+
+ */
531+
+ @Contract(value = "_ -> this", mutates = "this")
532+
+ Builder title(@Nullable Component title);
533+
+
534+
+ /**
535+
+ * Sets the author of the painting.
536+
+ *
537+
+ * @param author the author
538+
+ * @return this builder instance
539+
+ * @see PaintingVariantRegistryEntry#author()
540+
+ * @see Art#author()
541+
+ */
542+
+ @Contract(value = "_ -> this", mutates = "this")
543+
+ Builder author(@Nullable Component author);
544+
+
545+
+ /**
546+
+ * Sets the assetId of the variant, which is the location of the sprite to use.
547+
+ *
548+
+ * @param assetId the asset id
549+
+ * @return this builder instance
550+
+ * @see PaintingVariantRegistryEntry#assetId()
551+
+ * @see Art#assetId()
552+
+ */
553+
+ @Contract(value = "_ -> this", mutates = "this")
554+
+ Builder assetId(Key assetId);
555+
+
556+
+ }
557+
+
558+
+}
417559
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
418560
new file mode 100644
419561
index 0000000000000000000000000000000000000000..4f8f536f437c5f483ac7bce393e664fd7bc38477
@@ -430,15 +572,17 @@ index 0000000000000000000000000000000000000000..4f8f536f437c5f483ac7bce393e664fd
430572
+ */
431573
+package io.papermc.paper.registry.data;
432574
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
433-
index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..1c8e77c7243cfedef6c4d1491cf98e6ec8f1690f 100644
575+
index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..40deffbd0930508bb04e9aedfd62ad2144855198 100644
434576
--- a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
435577
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java
436-
@@ -1,8 +1,15 @@
578+
@@ -1,8 +1,17 @@
437579
package io.papermc.paper.registry.event;
438580

439581
+import io.papermc.paper.registry.RegistryKey;
440582
+import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
441583
+import io.papermc.paper.registry.data.GameEventRegistryEntry;
584+
+import io.papermc.paper.registry.data.PaintingVariantRegistryEntry;
585+
+import org.bukkit.Art;
442586
+import org.bukkit.GameEvent;
443587
+import org.bukkit.enchantments.Enchantment;
444588
import org.jetbrains.annotations.ApiStatus;
@@ -449,12 +593,13 @@ index 91ae9c0d3ec55ce417d4b447bf3d1b0d0c174b5e..1c8e77c7243cfedef6c4d1491cf98e6e
449593
/**
450594
* Holds providers for {@link RegistryEntryAddEvent} and {@link RegistryFreezeEvent}
451595
* handlers for each applicable registry.
452-
@@ -11,6 +18,9 @@ import org.jspecify.annotations.NullMarked;
596+
@@ -11,6 +20,10 @@ import org.jspecify.annotations.NullMarked;
453597
@NullMarked
454598
public final class RegistryEvents {
455599

456600
+ public static final RegistryEventProvider<GameEvent, GameEventRegistryEntry.Builder> GAME_EVENT = create(RegistryKey.GAME_EVENT);
457601
+ public static final RegistryEventProvider<Enchantment, EnchantmentRegistryEntry.Builder> ENCHANTMENT = create(RegistryKey.ENCHANTMENT);
602+
+ public static final RegistryEventProvider<Art, PaintingVariantRegistryEntry.Builder> PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT);
458603
+
459604
private RegistryEvents() {
460605
}

patches/api/0478-Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ index 7ff6d60deb129e23b2a4d772aee123eb6c0b6433..52a2763773b234c581b2dcc6f0584f8d
228228
return key;
229229
}
230230
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
231-
index fc089b796f5a0f2e1ab081cc710e4bb5c3f5ee7b..2a86e599175549a3021a63a837f8cc9d8da5697d 100644
231+
index 3fdba38fd5e75ddcbfca9cee70a606bfa4a539bf..66219e3855aef885341132a7456af54cf315475f 100644
232232
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
233233
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
234234
@@ -1010,4 +1010,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste

patches/api/0484-Add-FeatureFlag-API.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ index eb33e8e671972aa308ad75a7ce9aa9ac526f470f..05ecf3cb38ff42c8b52405d900197e6b
247247
/**
248248
* Gets the {@link Biome} at the given {@link Location}.
249249
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
250-
index 56d16c887b7663aab7db2f7be532d9912aeb3570..2dd4c16ac107f58752c725540ab414ff79c46ff4 100644
250+
index 307439827b401acb96f0df1cf4ef31835bd1d513..e8dc8a6abebf6c31cb095ca3646eb4909e42f105 100644
251251
--- a/src/main/java/org/bukkit/UnsafeValues.java
252252
+++ b/src/main/java/org/bukkit/UnsafeValues.java
253253
@@ -111,8 +111,7 @@ public interface UnsafeValues {

patches/api/0486-Item-serialization-as-json.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Item serialization as json
55

66

77
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
8-
index 2dd4c16ac107f58752c725540ab414ff79c46ff4..79312bdda8ef0799e2d46decc52cfdac95b97d37 100644
8+
index e8dc8a6abebf6c31cb095ca3646eb4909e42f105..a491dc40093e19b8d1900443ad613223fd7f3119 100644
99
--- a/src/main/java/org/bukkit/UnsafeValues.java
1010
+++ b/src/main/java/org/bukkit/UnsafeValues.java
1111
@@ -168,6 +168,36 @@ public interface UnsafeValues {

patches/api/0492-Void-damage-configuration-API.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Void damage configuration API
55

66

77
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
8-
index adcd8161846b06fd1a7895750f98b629204a8406..ef32a937e6faf1e8a5d6b1207986715bae5a246c 100644
8+
index b462f2a9f7b6acbdc826d093b1de826ca682f25b..7a439c99fc4c5ee17d674460c8e58a9fe0c64e02 100644
99
--- a/src/main/java/org/bukkit/World.java
1010
+++ b/src/main/java/org/bukkit/World.java
1111
@@ -52,6 +52,54 @@ import org.jetbrains.annotations.Nullable;

patches/api/0495-DataComponent-API.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3916,7 +3916,7 @@ index 615eb24ffdd8f6d55ccd4f21760b809c1098bc68..c7ce8fa1ff9feda66d5a4e497112a24f
39163916
+ // Paper end - data component API
39173917
}
39183918
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
3919-
index 7cf7c6d05aa6cbf3f0c8612831404552c6a7b84a..c60e31425efd7b863941f5538faef6c0552290ae 100644
3919+
index 87907918c42b11780b285b6d82e7297628a07376..d55c33ca14257be5005520e18e465da87a58dbaf 100644
39203920
--- a/src/main/java/org/bukkit/Registry.java
39213921
+++ b/src/main/java/org/bukkit/Registry.java
39223922
@@ -376,6 +376,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: kokiriglade <[email protected]>
3+
Date: Sat, 23 Nov 2024 18:08:13 +0000
4+
Subject: [PATCH] Expanded Art API
5+
6+
7+
diff --git a/src/main/java/org/bukkit/Art.java b/src/main/java/org/bukkit/Art.java
8+
index 00a290f1bf58cdc2238c13fd5a6048a26b7871da..ed2263450e98460250e431d2ee6debd03204c175 100644
9+
--- a/src/main/java/org/bukkit/Art.java
10+
+++ b/src/main/java/org/bukkit/Art.java
11+
@@ -107,6 +107,29 @@ public interface Art extends OldEnum<Art>, Keyed {
12+
@NotNull NamespacedKey getKey();
13+
// Paper end - deprecate getKey
14+
15+
+ // Paper start - name and author components, assetId key
16+
+ /**
17+
+ * Get the painting's title.
18+
+ *
19+
+ * @return the title
20+
+ */
21+
+ net.kyori.adventure.text.@Nullable Component title();
22+
+
23+
+ /**
24+
+ * Get the painting's author.
25+
+ *
26+
+ * @return the author
27+
+ */
28+
+ net.kyori.adventure.text.@Nullable Component author();
29+
+
30+
+ /**
31+
+ * Get the painting's asset id
32+
+ *
33+
+ * @return the asset id
34+
+ */
35+
+ net.kyori.adventure.key.@NotNull Key assetId();
36+
+ // Paper end - name and author components, assetId key
37+
+
38+
/**
39+
* Get a painting by its numeric ID
40+
*

patches/server/0992-Registry-Modification-API.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public net.minecraft.resources.RegistryOps lookupProvider
1111
public net.minecraft.resources.RegistryOps$HolderLookupAdapter
1212

1313
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
14-
index c6969f968b45eff2aeb44e647712abda10c7c113..d34ffad8a36abbb215491d74ae8d9b490a0bc64f 100644
14+
index 2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91..3ec2aa5da045b62809afd2c13fc9ae74189dbdad 100644
1515
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
1616
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
1717
@@ -3,6 +3,7 @@ package io.papermc.paper.registry;

0 commit comments

Comments
 (0)