More more work

This commit is contained in:
KennyTV 2021-06-13 14:43:56 +02:00
parent 19da14ee00
commit 5d9882a976
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
9 changed files with 44 additions and 64 deletions

View File

@ -85,7 +85,7 @@ index c8a59de4673d430fc8ec2e53315f107293122e7e..40e48c3f1199b127066732e3c8a6d40c
// CraftBukkit start
// this.updateSpawnFlags();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 940e6587125df1f203cdeeefc31658635badea81..420ecc61be194486d335c44fc743894023d3f115 100644
index 940e6587125df1f203cdeeefc31658635badea81..74a5dcde184c20129cb5fdcfb34ef1c3aecb1842 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -61,6 +61,7 @@ import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket;
@ -174,7 +174,7 @@ index 940e6587125df1f203cdeeefc31658635badea81..420ecc61be194486d335c44fc7438940
public void setDefaultSpawnPos(BlockPos pos, float angle) {
- ChunkPos chunkcoordintpair = new ChunkPos(new BlockPos(this.levelData.getXSpawn(), 0, this.levelData.getZSpawn()));
+ // Paper - configurable spawn radius
+ BlockPos prevSpawn = this.getSpawn();
+ BlockPos prevSpawn = this.getSharedSpawnPos();
+ //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
this.levelData.setSpawn(pos, angle);

View File

@ -5,26 +5,26 @@ Subject: [PATCH] ChunkMapDistance CME
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 0b8cbf75ff01b9825141be00d63679f7bcc58a9f..89e90806b78d94d5c1d781113da420dafa47930a 100644
index 00f5cd29170e3594fe2ac194e04e403cef685912..84831fc611589c19320b5e3af107080596b1fbdc 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -44,6 +44,7 @@ public class ChunkHolder {
private static final CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> UNLOADED_LEVEL_CHUNK_FUTURE = CompletableFuture.completedFuture(ChunkHolder.UNLOADED_LEVEL_CHUNK);
private static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.getStatusList();
private static final ChunkHolder.FullChunkStatus[] FULL_CHUNK_STATUSES = ChunkHolder.FullChunkStatus.values();
@@ -73,6 +73,7 @@ public class ChunkHolder {
private boolean resendLight;
private CompletableFuture<Void> pendingFullStateConfirmation;
+ boolean isUpdateQueued = false; // Paper
private final AtomicReferenceArray<CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> futures;
private volatile CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage
private volatile CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> tickingChunkFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage
private final ChunkMap chunkMap; // Paper
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index 8f993f15ae02c2e4af9cc732cd1b040cce0a67e8..71a51cc99e26579e765f88340588e23956888929 100644
index 48bb57d3a431ea466425eb7da821c0aea900bd4c..45c7ebe67019cdbe88b6617a95d5c40d3a68286c 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -39,7 +39,16 @@ public abstract class DistanceManager {
@@ -47,7 +47,16 @@ public abstract class DistanceManager {
private final DistanceManager.ChunkTicketTracker ticketTracker = new DistanceManager.ChunkTicketTracker();
private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8);
private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(33);
- private final Set<ChunkHolder> chunksToUpdateFutures = Sets.newHashSet();
- final Set<ChunkHolder> chunksToUpdateFutures = Sets.newHashSet();
+ // Paper start use a queue, but still keep unique requirement
+ public final java.util.Queue<ChunkHolder> pendingChunkUpdates = new java.util.ArrayDeque<ChunkHolder>() {
+ @Override
@ -35,10 +35,10 @@ index 8f993f15ae02c2e4af9cc732cd1b040cce0a67e8..71a51cc99e26579e765f88340588e239
+ }
+ };
+ // Paper end
private final ChunkTaskPriorityQueueSorter ticketThrottler;
private final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> ticketThrottlerInput;
private final ProcessorHandle<ChunkTaskPriorityQueueSorter.Release> ticketThrottlerReleaser;
@@ -100,26 +109,14 @@ public abstract class DistanceManager {
final ChunkTaskPriorityQueueSorter ticketThrottler;
final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> ticketThrottlerInput;
final ProcessorHandle<ChunkTaskPriorityQueueSorter.Release> ticketThrottlerReleaser;
@@ -108,26 +117,14 @@ public abstract class DistanceManager {
;
}
@ -52,7 +52,7 @@ index 8f993f15ae02c2e4af9cc732cd1b040cce0a67e8..71a51cc99e26579e765f88340588e239
- iter.remove();
- expectedSize--;
-
- playerchunk.updateFutures(chunkStorage);
- playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor);
-
- // Reset iterator if set was modified using add()
- if (this.chunksToUpdateFutures.size() != expectedSize) {
@ -67,13 +67,13 @@ index 8f993f15ae02c2e4af9cc732cd1b040cce0a67e8..71a51cc99e26579e765f88340588e239
+ while(!this.pendingChunkUpdates.isEmpty()) {
+ ChunkHolder remove = this.pendingChunkUpdates.remove();
+ remove.isUpdateQueued = false;
+ remove.updateFutures(chunkStorage);
+ remove.updateFutures(playerchunkmap, this.mainThreadExecutor);
+ }
+ // Paper end
return true;
} else {
if (!this.ticketsToRelease.isEmpty()) {
@@ -342,7 +339,7 @@ public abstract class DistanceManager {
@@ -385,7 +382,7 @@ public abstract class DistanceManager {
if (k != level) {
playerchunk = DistanceManager.this.updateChunkScheduling(id, level, playerchunk, k);
if (playerchunk != null) {
@ -82,12 +82,3 @@ index 8f993f15ae02c2e4af9cc732cd1b040cce0a67e8..71a51cc99e26579e765f88340588e239
}
}
@@ -373,7 +370,7 @@ public abstract class DistanceManager {
ObjectIterator objectiterator = this.chunks.long2ByteEntrySet().iterator();
while (objectiterator.hasNext()) {
- it.unimi.dsi.fastutil.longs.Long2ByteMap.Entry it_unimi_dsi_fastutil_longs_long2bytemap_entry = (it.unimi.dsi.fastutil.longs.Long2ByteMap.Entry) objectiterator.next();
+ Long2ByteMap.Entry it_unimi_dsi_fastutil_longs_long2bytemap_entry = (Long2ByteMap.Entry) objectiterator.next(); // Paper - decompile fix
byte b0 = it_unimi_dsi_fastutil_longs_long2bytemap_entry.getByteValue();
long j = it_unimi_dsi_fastutil_longs_long2bytemap_entry.getLongKey();

View File

@ -49,11 +49,11 @@ index 0000000000000000000000000000000000000000..9a516520d975f52169e346adc4ec6d9d
+ }
+}
diff --git a/src/main/java/net/minecraft/world/level/block/SoundType.java b/src/main/java/net/minecraft/world/level/block/SoundType.java
index 1d3acbbc80a38998fb38e0ce37af52103f677721..44394adbe60b5e9c4654ee2f437d465bef5909a8 100644
index 46042087ef1e01cb9ca1f00137c436c6afa15599..74149f372b50e50fd735801324247787ad55d8b8 100644
--- a/src/main/java/net/minecraft/world/level/block/SoundType.java
+++ b/src/main/java/net/minecraft/world/level/block/SoundType.java
@@ -54,10 +54,10 @@ public class SoundType {
public static final SoundType GILDED_BLACKSTONE = new SoundType(1.0F, 1.0F, SoundEvents.GILDED_BLACKSTONE_BREAK, SoundEvents.GILDED_BLACKSTONE_STEP, SoundEvents.GILDED_BLACKSTONE_PLACE, SoundEvents.GILDED_BLACKSTONE_HIT, SoundEvents.GILDED_BLACKSTONE_FALL);
@@ -82,10 +82,10 @@ public class SoundType {
public static final SoundType POLISHED_DEEPSLATE = new SoundType(1.0F, 1.0F, SoundEvents.POLISHED_DEEPSLATE_BREAK, SoundEvents.POLISHED_DEEPSLATE_STEP, SoundEvents.POLISHED_DEEPSLATE_PLACE, SoundEvents.POLISHED_DEEPSLATE_HIT, SoundEvents.POLISHED_DEEPSLATE_FALL);
public final float volume;
public final float pitch;
- public final SoundEvent breakSound;
@ -66,12 +66,12 @@ index 1d3acbbc80a38998fb38e0ce37af52103f677721..44394adbe60b5e9c4654ee2f437d465b
public SoundType(float volume, float pitch, SoundEvent breakSound, SoundEvent stepSound, SoundEvent placeSound, SoundEvent hitSound, SoundEvent fallSound) {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index d73086970db19531db66c2e8af52da91d0b1ea28..5bff313dbbb3049105874846d995883e827fbc00 100644
index ca03ed4b1581df2b7db272d6f330174a9d277153..0a9ed9992a2fc97472a06591a5d129a767ce21af 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -747,4 +747,11 @@ public class CraftBlock implements Block {
@@ -749,4 +749,11 @@ public class CraftBlock implements Block {
AABB aabb = shape.bounds();
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
return new BoundingBox(this.getX() + aabb.minX, this.getY() + aabb.minY, this.getZ() + aabb.minZ, this.getX() + aabb.maxX, this.getY() + aabb.maxY, this.getZ() + aabb.maxZ);
}
+
+ // Paper start

View File

@ -32,7 +32,7 @@ https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528273&page=com.atlass
https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528577&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-528577
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 8fd716bf2e1402694798b8be03fd85821153be44..53dd6c18de8e80378852bbb141016d9574d42162 100644
index 1fa190e098079522e0fe3593fa261c1b7ad4e24b..71ffa66973d8994e2a480435ac1ada3fe61600a4 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -6,13 +6,15 @@ import com.google.common.collect.ImmutableSet;
@ -212,10 +212,10 @@ index 8fd716bf2e1402694798b8be03fd85821153be44..53dd6c18de8e80378852bbb141016d95
* Ported from MinecraftForge - author: LexManos <LexManos@gmail.com> - License: LGPLv2.1
*/
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 1fecc81b25109592907623741225a6222a8c5ccc..a16551c81a444685f6337a65b6d7862b8c0dc684 100644
index 0df3961919f04f27eb265ab316aa5a0f15a70854..e31dbb1346ba6755bc367a3eab6f87574b4eb3c4 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -9,13 +9,27 @@ import net.minecraft.core.BlockPos;
@@ -8,13 +8,27 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
@ -243,7 +243,7 @@ index 1fecc81b25109592907623741225a6222a8c5ccc..a16551c81a444685f6337a65b6d7862b
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftWorld;
@@ -24,8 +38,11 @@ import org.spigotmc.AsyncCatcher;
@@ -23,8 +37,11 @@ import org.spigotmc.AsyncCatcher;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -255,11 +255,10 @@ index 1fecc81b25109592907623741225a6222a8c5ccc..a16551c81a444685f6337a65b6d7862b
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
@@ -531,4 +548,170 @@ public final class MCUtil {
@@ -530,6 +547,172 @@ public final class MCUtil {
return null;
}
+
+ public static ChunkStatus getChunkStatus(ChunkHolder chunk) {
+ List<ChunkStatus> statuses = ServerChunkCache.getPossibleChunkStatuses();
+ for (int i = statuses.size() - 1; i >= 0; --i) {
@ -425,25 +424,15 @@ index 1fecc81b25109592907623741225a6222a8c5ccc..a16551c81a444685f6337a65b6d7862b
+ out.print(fileData);
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 89e90806b78d94d5c1d781113da420dafa47930a..a89b9dab043ad4536014141d5a942670b4152a95 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -53,7 +53,7 @@ public class ChunkHolder {
public int oldTicketLevel;
private int ticketLevel;
private int queueLevel;
- private final ChunkPos pos;
+ final ChunkPos pos; // Paper - private -> package
private boolean hasChangedSections;
private final ShortSet[] changedBlocksPerSection;
private int blockChangedLightSectionFilter;
+
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/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 5d87a282042d7112415b7d7175031f734219f2c9..7585b6f87b72f53deccbcb8627a13503921fc682 100644
index 95ac30f56a9268f14d2518974c5a52e08f40ea18..25826b41812f2d9ac29806ad7a9242e5674376fc 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -104,7 +104,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -110,7 +110,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final Long2ObjectLinkedOpenHashMap<ChunkHolder> updatingChunkMap = new Long2ObjectLinkedOpenHashMap();
public volatile Long2ObjectLinkedOpenHashMap<ChunkHolder> visibleChunkMap;
private final Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads;
@ -453,10 +442,10 @@ index 5d87a282042d7112415b7d7175031f734219f2c9..7585b6f87b72f53deccbcb8627a13503
private final ThreadedLevelLightEngine lightEngine;
private final BlockableEventLoop<Runnable> mainThreadExecutor;
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index a7122a0411f4a8656efd4facde3403c8093bc8a6..6d33c1ee44bc732b58d18a8f6b0fd4bbdcb2dcd6 100644
index 71ac5cf0fdedcfe422bf6f5e6ffb15ce4138aa04..77bb2fb280293da4a38f9acc6503e84997ecb399 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -46,7 +46,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
@@ -49,7 +49,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
public class ServerChunkCache extends ChunkSource {
@ -464,13 +453,13 @@ index a7122a0411f4a8656efd4facde3403c8093bc8a6..6d33c1ee44bc732b58d18a8f6b0fd4bb
+ private static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.getStatusList(); public static final List<ChunkStatus> getPossibleChunkStatuses() { return ServerChunkCache.CHUNK_STATUSES; } // Paper - OBFHELPER
private final DistanceManager distanceManager;
public final ChunkGenerator generator;
private final ServerLevel level;
final ServerLevel level;
diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java
index 0c118d482e304c567fe7fe778c6ff386f960bdde..c6b5f32153b63ac92df9c4b31b8de168481f79f2 100644
index b346fa94b23d81da7da073f71dd12e672e0f079c..95f5050518109c4ae0b6846be65204cc29afc723 100644
--- a/src/main/java/net/minecraft/server/level/Ticket.java
+++ b/src/main/java/net/minecraft/server/level/Ticket.java
@@ -6,8 +6,8 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
@@ -5,8 +5,8 @@ import java.util.Objects;
public final class Ticket<T> implements Comparable<Ticket<?>> {
private final TicketType<T> type;
private final int ticketLevel;
- public final T key;