PaperMC/patches/server/1008-Always-send-Banner-patterns-to-the-client.patch

43 lines
2.3 KiB
Diff
Raw Permalink Normal View History

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
2024-12-03 21:03:25 +01:00
index 27fd8b88dc1433c1df1e09604a3cc546bfa0d2b9..1f3e1c7128b9a0f27f2df39a8970050c5313d7a3 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
2024-12-03 21:03:25 +01:00
@@ -57,7 +57,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
@Override
2024-10-25 12:28:34 +02:00
protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
super.saveAdditional(nbt, registries);
- if (!this.patterns.equals(BannerPatternLayers.EMPTY)) {
+ if (!this.patterns.equals(BannerPatternLayers.EMPTY) || serialisingForNetwork.get()) { // Paper - always send patterns to client
2024-10-25 12:28:34 +02:00
nbt.put("patterns", (Tag) BannerPatternLayers.CODEC.encodeStart(registries.createSerializationContext(NbtOps.INSTANCE), this.patterns).getOrThrow());
}
2024-12-03 21:03:25 +01:00
@@ -89,9 +89,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
2024-10-25 12:28:34 +02:00
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
+ final Boolean wasSerialisingForNetwork = serialisingForNetwork.get();
+ try {
+ serialisingForNetwork.set(Boolean.TRUE);
2024-10-25 12:28:34 +02:00
return this.saveWithoutMetadata(registries);
+ } finally {
+ serialisingForNetwork.set(wasSerialisingForNetwork);
+ }
+ // Paper end - always send patterns to client
}
public BannerPatternLayers getPatterns() {