mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
8c5b837e05
Firstly, the old methods all routed to the CompletableFuture method. However, the CF method could not guarantee that if the caller was off-main that the future would be "completed" on-main. Since the callback methods used the CF one, this meant that the callback methods did not guarantee that the callbacks were to be called on the main thread. Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb) so that the methods with the callback are guaranteed to invoke the callback on the main thread. The CF behavior remains unchanged; it may still appear to complete on main if invoked off-main. Secondly, remove the scheduleOnMain invocation in the async chunk completion. This unnecessarily delays the callback by 1 tick. Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which will load chunks within an area. This method is provided as a helper as keeping all chunks loaded within an area can be complicated to implement for plugins (due to the lacking ticket API), and is already implemented internally anyways. Fourthly, remove the ticket addition that occured with getChunkAt and getChunkAtAsync. The ticket addition may delay the unloading of the chunk unnecessarily. It also fixes a very rare timing bug where the future/callback would be completed after the chunk unloads.
42 lines
2.3 KiB
Diff
42 lines
2.3 KiB
Diff
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 98bc87fe5d153cc4927f7e1b4a02f61d9dd019a0..9528935a120f7d5a1fdb1a796854478e8a83f833 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 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
|
|
nbt.put("patterns", (Tag) BannerPatternLayers.CODEC.encodeStart(registries.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 registries) {
|
|
+ final Boolean wasSerialisingForNetwork = serialisingForNetwork.get();
|
|
+ try {
|
|
+ serialisingForNetwork.set(Boolean.TRUE);
|
|
return this.saveWithoutMetadata(registries);
|
|
+ } finally {
|
|
+ serialisingForNetwork.set(wasSerialisingForNetwork);
|
|
+ }
|
|
+ // Paper end - always send patterns to client
|
|
}
|
|
|
|
public BannerPatternLayers getPatterns() {
|