mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-11 02:02:04 -07:00
More more work
This commit is contained in:
@@ -1404,7 +1404,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ *
|
+ *
|
||||||
+ * @return Name of the sender
|
+ * @return Name of the sender
|
||||||
+ */
|
+ */
|
||||||
+ public @NotNull Component name();
|
+ public @NotNull net.kyori.adventure.text.Component name();
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
|
+ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
|
||||||
|
@@ -4985,6 +4985,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getTicketLevelFor(net.minecraft.world.level.chunk.ChunkStatus status) {
|
||||||
|
+ return net.minecraft.server.level.ChunkMap.MAX_VIEW_DISTANCE + net.minecraft.world.level.chunk.ChunkStatus.getDistance(status);
|
||||||
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@@ -5076,6 +5080,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
if (!ChunkHolder.getFullChunkStatus(this.oldTicketLevel).isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
|
if (!ChunkHolder.getFullChunkStatus(this.oldTicketLevel).isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
|
||||||
return this.getFullChunkUnchecked();
|
return this.getFullChunkUnchecked();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ public ChunkAccess getAvailableChunkNow() {
|
||||||
|
+ // TODO can we just getStatusFuture(EMPTY)?
|
||||||
|
+ for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) {
|
||||||
|
+ CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = this.getFutureIfPresentUnchecked(curr);
|
||||||
|
+ Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = future.getNow(null);
|
||||||
|
+ if (either == null || !either.left().isPresent()) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ return either.left().get();
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getFutureIfPresentUnchecked(ChunkStatus leastStatus) {
|
||||||
|
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(leastStatus.getIndex());
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
||||||
return ChunkHolder.getStatus(this.ticketLevel).isOrAfter(leastStatus) ? this.getFutureIfPresentUnchecked(leastStatus) : ChunkHolder.UNLOADED_CHUNK_FUTURE;
|
return ChunkHolder.getStatus(this.ticketLevel).isOrAfter(leastStatus) ? this.getFutureIfPresentUnchecked(leastStatus) : ChunkHolder.UNLOADED_CHUNK_FUTURE;
|
||||||
}
|
}
|
||||||
@@ -5105,6 +5131,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ public ChunkStatus getChunkHolderStatus() {
|
||||||
|
+ for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) {
|
||||||
|
+ CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = this.getFutureIfPresentUnchecked(curr);
|
||||||
|
+ Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = future.getNow(null);
|
||||||
|
+ if (either == null || !either.left().isPresent()) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ return curr;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@Nullable
|
||||||
|
public ChunkAccess getLastAvailable() {
|
||||||
|
for (int i = ChunkHolder.CHUNK_STATUSES.size() - 1; i >= 0; --i) {
|
||||||
|
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
- public CompletableFuture<ChunkAccess> getChunkToSave() {
|
- public CompletableFuture<ChunkAccess> getChunkToSave() {
|
||||||
+ public final CompletableFuture<ChunkAccess> getChunkToSave() { // Paper - final for inline
|
+ public final CompletableFuture<ChunkAccess> getChunkToSave() { // Paper - final for inline
|
||||||
return this.chunkToSave;
|
return this.chunkToSave;
|
||||||
@@ -5545,6 +5593,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
|
+ @Nullable
|
||||||
|
+ public ChunkAccess getChunkAtImmediately(int x, int z) {
|
||||||
|
+ ChunkHolder holder = this.chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z));
|
||||||
|
+ if (holder == null) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return holder.getLastAvailable();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // this will try to avoid chunk neighbours for lighting
|
+ // this will try to avoid chunk neighbours for lighting
|
||||||
+ public final ChunkAccess getFullStatusChunkAt(int chunkX, int chunkZ) {
|
+ public final ChunkAccess getFullStatusChunkAt(int chunkX, int chunkZ) {
|
||||||
+ LevelChunk ifLoaded = this.getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
+ LevelChunk ifLoaded = this.getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
||||||
@@ -5634,6 +5692,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }, this.mainThreadProcessor);
|
+ }, this.mainThreadProcessor);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ public <T> void addTicketAtLevel(TicketType<T> ticketType, ChunkPos chunkPos, int ticketLevel, T identifier) {
|
||||||
|
+ this.distanceManager.addTicketAtLevel(ticketType, chunkPos, ticketLevel, identifier);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public <T> void removeTicketAtLevel(TicketType<T> ticketType, ChunkPos chunkPos, int ticketLevel, T identifier) {
|
||||||
|
+ this.distanceManager.removeTicketAtLevel(ticketType, chunkPos, ticketLevel, identifier);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ void chunkLoadAccept(int chunkX, int chunkZ, ChunkAccess chunk, java.util.function.Consumer<ChunkAccess> consumer) {
|
+ void chunkLoadAccept(int chunkX, int chunkZ, ChunkAccess chunk, java.util.function.Consumer<ChunkAccess> consumer) {
|
||||||
+ try {
|
+ try {
|
||||||
+ consumer.accept(chunk);
|
+ consumer.accept(chunk);
|
||||||
|
Reference in New Issue
Block a user