Paper/patches/server/0717-Nameable-Banner-API.patch

51 lines
2.4 KiB
Diff
Raw Normal View History

2022-06-16 05:54:54 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Thu, 7 Apr 2022 17:49:25 -0400
Subject: [PATCH] Nameable Banner API
2024-04-26 06:27:19 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
2024-04-30 00:16:07 +02:00
index 925608bfa9c848ed6285de5e35d60aa66e12004a..60c26076e7acf869fa0e20fdc14eeec341387d99 100644
2024-04-26 06:27:19 +02:00
--- a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
@@ -29,7 +29,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
public static final int MAX_PATTERNS = 6;
private static final String TAG_PATTERNS = "patterns";
@Nullable
- private Component name;
+ public Component name; // Paper - public
public DyeColor baseColor;
private BannerPatternLayers patterns;
2022-06-16 05:54:54 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
2024-04-26 06:27:19 +02:00
index 26ae3fe910964193c7fb22b8b644d5c0476f8d3d..65a9213ce8197d50a58f94edfd60c25c2be848be 100644
2022-06-16 05:54:54 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
2024-04-24 22:32:38 +02:00
@@ -110,4 +110,26 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
public CraftBanner copy(Location location) {
return new CraftBanner(this, location);
2022-06-16 05:54:54 +02:00
}
+
2022-06-16 05:54:54 +02:00
+ // Paper start
+ @Override
+ public net.kyori.adventure.text.Component customName() {
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCustomName());
+ }
+
+ @Override
+ public void customName(net.kyori.adventure.text.Component customName) {
2024-04-26 06:27:19 +02:00
+ this.getSnapshot().name = io.papermc.paper.adventure.PaperAdventure.asVanilla(customName);
2022-06-16 05:54:54 +02:00
+ }
+
+ @Override
+ public String getCustomName() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(this.customName());
+ }
+
+ @Override
+ public void setCustomName(String name) {
+ this.customName(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(name));
+ }
+ // Paper end
}