Update to Minecraft 1.20.3

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-12-06 03:40:00 +11:00
parent afdb1d9bc3
commit 8398e12b34
256 changed files with 2745 additions and 1911 deletions

View File

@@ -1,26 +1,25 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -163,6 +163,30 @@
@@ -165,13 +165,36 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.mojang.datafixers.util.Pair;
+import com.mojang.serialization.DynamicOps;
+import com.mojang.serialization.Dynamic;
+import com.mojang.serialization.Lifecycle;
+import java.util.Random;
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import net.minecraft.core.HolderLookup;
+import net.minecraft.nbt.DynamicOpsNBT;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.resources.RegistryOps;
+import net.minecraft.nbt.NbtException;
+import net.minecraft.nbt.ReportedNbtException;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.dedicated.DedicatedServerProperties;
+import net.minecraft.util.datafix.DataConverterRegistry;
+import net.minecraft.world.level.levelgen.WorldDimensions;
+import net.minecraft.world.level.levelgen.presets.WorldPresets;
+import net.minecraft.world.level.storage.LevelDataAndDimensions;
+import net.minecraft.world.level.storage.WorldDataServer;
+import net.minecraft.world.level.storage.WorldInfo;
+import net.minecraft.world.level.validation.ContentValidationException;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
@@ -31,7 +30,15 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger();
@@ -247,6 +271,19 @@
public static final String VANILLA_BRAND = "vanilla";
private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F;
private static final int TICK_STATS_SPAN = 100;
- private static final long OVERLOADED_THRESHOLD_NANOS = 20L * TimeRange.NANOSECONDS_PER_SECOND / 20L;
+ private static final long OVERLOADED_THRESHOLD_NANOS = 30L * TimeRange.NANOSECONDS_PER_SECOND / 20L; // CraftBukkit
private static final int OVERLOADED_TICKS_THRESHOLD = 20;
private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND;
private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100;
@@ -254,6 +277,19 @@
protected SaveData worldData;
private volatile boolean isSaving;
@@ -51,7 +58,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -260,14 +297,14 @@
@@ -267,14 +303,14 @@
thread.setPriority(8);
}
@@ -68,7 +75,7 @@
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -286,7 +323,7 @@
@@ -295,7 +331,7 @@
this.customBossEvents = new BossBattleCustomData();
this.registries = worldstem.registries();
this.worldData = worldstem.worldData();
@@ -77,7 +84,7 @@
throw new IllegalStateException("Missing Overworld dimension data");
} else {
this.proxy = proxy;
@@ -309,6 +346,33 @@
@@ -319,6 +355,33 @@
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
}
@@ -111,7 +118,7 @@
}
private void readScoreboard(WorldPersistentData worldpersistentdata) {
@@ -317,7 +381,7 @@
@@ -327,7 +390,7 @@
protected abstract boolean initServer() throws IOException;
@@ -120,7 +127,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -325,12 +389,8 @@
@@ -335,12 +398,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@@ -134,7 +141,7 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -347,23 +407,179 @@
@@ -357,23 +416,216 @@
protected void forceDifficulty() {}
@@ -223,17 +230,54 @@
+ }
+ }
+
+ Dynamic<?> dynamic;
+ if (worldSession.hasWorldData()) {
+ WorldInfo worldinfo;
+
+ try {
+ dynamic = worldSession.getDataTag();
+ worldinfo = worldSession.getSummary(dynamic);
+ } catch (NbtException | ReportedNbtException | IOException ioexception) {
+ Convertable.b convertable_b = worldSession.getLevelDirectory();
+
+ MinecraftServer.LOGGER.warn("Failed to load world data from {}", convertable_b.dataFile(), ioexception);
+ MinecraftServer.LOGGER.info("Attempting to use fallback");
+
+ try {
+ dynamic = worldSession.getDataTagFallback();
+ worldinfo = worldSession.getSummary(dynamic);
+ } catch (NbtException | ReportedNbtException | IOException ioexception1) {
+ MinecraftServer.LOGGER.error("Failed to load world data from {}", convertable_b.oldDataFile(), ioexception1);
+ MinecraftServer.LOGGER.error("Failed to load world data from {} and {}. World files may be corrupted. Shutting down.", convertable_b.dataFile(), convertable_b.oldDataFile());
+ return;
+ }
+
+ worldSession.restoreLevelDataFromOld();
+ }
+
+ if (worldinfo.requiresManualConversion()) {
+ MinecraftServer.LOGGER.info("This world must be opened in an older version (like 1.6.4) to be safely converted");
+ return;
+ }
+
+ if (!worldinfo.isCompatible()) {
+ MinecraftServer.LOGGER.info("This world was created by an incompatible version.");
+ return;
+ }
+ } else {
+ dynamic = null;
+ }
+
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
+ org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name);
+
+ WorldDataServer worlddata;
+ WorldLoader.a worldloader_a = this.worldLoader;
+ IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
+ DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen());
+ Pair<SaveData, WorldDimensions.b> pair = worldSession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
+ if (dynamic != null) {
+ LevelDataAndDimensions leveldataanddimensions = Convertable.getLevelDataAndDimensions(dynamic, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen());
+
+ if (pair != null) {
+ worlddata = (WorldDataServer) pair.getFirst();
+ worlddata = (WorldDataServer) leveldataanddimensions.worldData();
+ } else {
+ WorldSettings worldsettings;
+ WorldOptions worldoptions;
@@ -328,7 +372,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -387,30 +603,8 @@
@@ -397,30 +649,8 @@
iworlddataserver.setInitialized(true);
}
@@ -360,7 +404,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -418,6 +612,21 @@
@@ -428,6 +658,21 @@
} else {
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
@@ -382,7 +426,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -477,8 +686,11 @@
@@ -487,8 +732,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@@ -396,28 +440,28 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -487,19 +699,23 @@
@@ -497,19 +745,23 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
this.nextTickTime = SystemUtils.getMillis();
this.nextTickTimeNanos = SystemUtils.getNanos();
- chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
+ // CraftBukkit start
+ if (worldserver.getWorld().getKeepSpawnInMemory()) {
+ chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
- while (chunkproviderserver.getTickingGenerated() != 441) {
- this.nextTickTime = SystemUtils.getMillis() + 10L;
- this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.waitUntilNextTick();
+ while (chunkproviderserver.getTickingGenerated() != 441) {
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
+ // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
+ this.executeModerately();
+ }
}
- this.nextTickTime = SystemUtils.getMillis() + 10L;
- this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.waitUntilNextTick();
- Iterator iterator = this.levels.values().iterator();
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
+ // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
+ this.executeModerately();
+ // Iterator iterator = this.levels.values().iterator();
@@ -429,14 +473,14 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks");
if (forcedchunk != null) {
@@ -514,10 +730,17 @@
@@ -524,10 +776,17 @@
}
}
- this.nextTickTime = SystemUtils.getMillis() + 10L;
- this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.waitUntilNextTick();
+ // CraftBukkit start
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
+ // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
+ this.executeModerately();
+ // CraftBukkit end
worldloadlistener.stop();
@@ -450,7 +494,7 @@
}
public EnumGamemode getDefaultGameType() {
@@ -547,12 +770,16 @@
@@ -557,12 +816,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@@ -467,7 +511,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -587,18 +814,40 @@
@@ -597,18 +860,40 @@
this.stopServer();
}
@@ -508,34 +552,32 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -686,15 +935,16 @@
@@ -696,7 +981,7 @@
}
this.nextTickTime = SystemUtils.getMillis();
this.nextTickTimeNanos = SystemUtils.getNanos();
- this.statusIcon = (ServerPing.a) this.loadStatusIcon().orElse((Object) null);
+ this.statusIcon = (ServerPing.a) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
this.status = this.buildServerStatus();
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
@@ -713,6 +998,7 @@
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
long k = j / i;
- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) {
+ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
long j = i / 50L;
+ if (server.getWarnOnOverload()) // CraftBukkit
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime;
@@ -705,6 +955,7 @@
+ if (server.getWarnOnOverload()) // CraftBukkit
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k);
this.nextTickTimeNanos += k * i;
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
@@ -726,6 +1012,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
}
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
this.nextTickTime += 50L;
this.nextTickTimeNanos += i;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -743,6 +994,12 @@
@@ -770,6 +1057,12 @@
this.services.profileCache().clearExecutor();
}
@@ -548,13 +590,13 @@
this.onServerExit();
}
@@ -776,7 +1033,14 @@
@@ -803,7 +1096,14 @@
}
private boolean haveTime() {
- return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
- return this.runningTask() || SystemUtils.getNanos() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTimeNanos : this.nextTickTimeNanos);
+ // CraftBukkit start
+ return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
+ return this.forceTicks || this.runningTask() || SystemUtils.getNanos() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTimeNanos : this.nextTickTimeNanos);
+ }
+
+ private void executeModerately() {
@@ -564,7 +606,7 @@
}
protected void waitUntilNextTick() {
@@ -823,7 +1087,7 @@
@@ -850,7 +1150,7 @@
}
}
@@ -573,16 +615,20 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -876,7 +1140,7 @@
this.status = this.buildServerStatus();
@@ -909,8 +1209,10 @@
}
- if (this.tickCount % 6000 == 0) {
+ if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit
--this.ticksUntilAutosave;
- if (this.ticksUntilAutosave <= 0) {
- this.ticksUntilAutosave = this.computeNextAutosaveInterval();
+ // CraftBukkit start
+ if (this.autosavePeriod > 0 && this.ticksUntilAutosave <= 0) {
+ this.ticksUntilAutosave = this.autosavePeriod;
+ // CraftBukkit end
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -928,22 +1192,39 @@
@@ -991,22 +1293,39 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing();
});
@@ -622,7 +668,7 @@
this.profiler.push("tick");
@@ -1033,6 +1314,22 @@
@@ -1096,6 +1415,22 @@
return (WorldServer) this.levels.get(resourcekey);
}
@@ -645,7 +691,7 @@
public Set<ResourceKey<World>> levelKeys() {
return this.levels.keySet();
}
@@ -1062,7 +1359,7 @@
@@ -1125,7 +1460,7 @@
@DontObfuscate
public String getServerModName() {
@@ -654,7 +700,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1403,11 +1700,11 @@
@@ -1466,11 +1801,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@@ -668,7 +714,7 @@
}, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1422,6 +1719,7 @@
@@ -1485,6 +1820,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_reloadableresources;
@@ -676,7 +722,7 @@
this.packRepository.setSelected(collection);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
@@ -1778,7 +2076,7 @@
@@ -1853,7 +2189,7 @@
try {
label51:
{
@@ -685,7 +731,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1828,6 +2126,22 @@
@@ -1903,6 +2239,22 @@
}
@@ -708,7 +754,7 @@
private void startMetricsRecordingTick() {
if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -1954,6 +2268,11 @@
@@ -2029,6 +2381,11 @@
}