aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0707-Nameable-Banner-API.patch
blob: aab360dbed11b8ec0e9c0ae88cf2c66170e84838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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


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
index 01521f38871d821762ff7ac2d39927f8c6b861bf..98bc87fe5d153cc4927f7e1b4a02f61d9dd019a0 100644
--- 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;
 
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
index 5635230fc288fe5280bf785b42c862b8f111afb0..afed8bdb9bd6a135e9b5f7bd9bfc61964cb240f7 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
@@ -112,4 +112,26 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
     public CraftBanner copy(Location location) {
         return new CraftBanner(this, location);
     }
+
+    // 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) {
+        this.getSnapshot().name = io.papermc.paper.adventure.PaperAdventure.asVanilla(customName);
+    }
+
+    @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
 }