aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1068-Always-send-Banner-patterns-to-the-client.patch
blob: 78daca3ba439e563ef6603e0ab31e05bcb92daf1 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 20 Oct 2024 18:23:59 +0100
Subject: [PATCH] Always send Banner patterns to the client

The mojang client will not remove patterns from a Banner when none
are sent inside of an update packet, given that this is not an expected
flow for them, this is not all too surprising. So, we shall resort to always
sending the patterns over the network for update packets.

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 60c26076e7acf869fa0e20fdc14eeec341387d99..5ddada37ad0d4c19438cd02415bad628012f7c90 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
@@ -63,7 +63,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
     @Override
     protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
         super.saveAdditional(nbt, registryLookup);
-        if (!this.patterns.equals(BannerPatternLayers.EMPTY)) {
+        if (!this.patterns.equals(BannerPatternLayers.EMPTY) || serialisingForNetwork) { // Paper - always send patterns to client
             nbt.put("patterns", (Tag) BannerPatternLayers.CODEC.encodeStart(registryLookup.createSerializationContext(NbtOps.INSTANCE), this.patterns).getOrThrow());
         }
 
@@ -95,9 +95,18 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
         return ClientboundBlockEntityDataPacket.create(this);
     }
 
+    // Paper start - always send patterns to client
+    ThreadLocal<Boolean> serialisingForNetwork = ThreadLocal.withInitial(() -> Boolean.FALSE);
     @Override
     public CompoundTag getUpdateTag(HolderLookup.Provider registryLookup) {
-        return this.saveWithoutMetadata(registryLookup);
+        final Boolean wasSerialisingForNetwork = serialisingForNetwork.get();
+        try {
+            serialisingForNetwork.set(Boolean.TRUE);
+            return this.saveWithoutMetadata(registryLookup);
+        } finally {
+            serialisingForNetwork.set(wasSerialisingForNetwork);
+        }
+        // Paper end - always send patterns to client
     }
 
     public BannerPatternLayers getPatterns() {