mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 18:15:54 +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.
51 lines
2.4 KiB
Diff
51 lines
2.4 KiB
Diff
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
|
|
}
|