SPIGOT-7207: WorldCreator creates world as super flat even when normal is specified

This commit is contained in:
md_5 2022-12-14 13:47:32 +11:00
parent ab1586c2fb
commit 585ab5ba1b
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
5 changed files with 119 additions and 103 deletions

View File

@ -87,7 +87,7 @@
WorldInfo worldinfo = convertable_conversionsession.getSummary(); WorldInfo worldinfo = convertable_conversionsession.getSummary();
if (worldinfo != null) { if (worldinfo != null) {
@@ -137,13 +165,31 @@ @@ -137,21 +165,41 @@
} }
} }
@ -116,11 +116,14 @@
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex); + throw new RuntimeException("Could not initialize Bukkit datapack", ex);
+ } + }
+ AtomicReference<WorldLoader.a> worldLoader = new AtomicReference<>(); + AtomicReference<WorldLoader.a> worldLoader = new AtomicReference<>();
+ WorldLoader.c datapackconfiguration;
+ // CraftBukkit end + // CraftBukkit end
WorldStem worldstem; WorldStem worldstem;
@@ -152,6 +198,7 @@ try {
- WorldLoader.c worldloader_c = loadOrCreateConfig(dedicatedserversettings.getProperties(), convertable_conversionsession, flag, resourcepackrepository);
+ WorldLoader.c worldloader_c = datapackconfiguration = loadOrCreateConfig(dedicatedserversettings.getProperties(), convertable_conversionsession, flag, resourcepackrepository); // CraftBukkit
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> { worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> { return WorldLoader.load(worldloader_c, (worldloader_a) -> {
@ -128,7 +131,7 @@
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen());
Pair<SaveData, WorldDimensions.b> pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle()); Pair<SaveData, WorldDimensions.b> pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
@@ -163,7 +210,7 @@ @@ -163,7 +211,7 @@
WorldOptions worldoptions; WorldOptions worldoptions;
WorldDimensions worlddimensions; WorldDimensions worlddimensions;
@ -137,7 +140,7 @@
worldsettings = MinecraftServer.DEMO_SETTINGS; worldsettings = MinecraftServer.DEMO_SETTINGS;
worldoptions = WorldOptions.DEMO_OPTIONS; worldoptions = WorldOptions.DEMO_OPTIONS;
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
@@ -171,7 +218,7 @@ @@ -171,7 +219,7 @@
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
@ -146,7 +149,7 @@
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
} }
@@ -187,6 +234,7 @@ @@ -187,6 +235,7 @@
return; return;
} }
@ -154,14 +157,14 @@
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
if (optionset.has(optionspec4)) { if (optionset.has(optionspec4)) {
@@ -198,21 +246,32 @@ @@ -198,21 +247,32 @@
SaveData savedata = worldstem.worldData(); SaveData savedata = worldstem.worldData();
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
+ */ + */
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> { final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> {
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new); - DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new); + DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ /* + /*
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null); dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
@ -189,7 +192,7 @@
Thread thread = new Thread("Server Shutdown Thread") { Thread thread = new Thread("Server Shutdown Thread") {
public void run() { public void run() {
dedicatedserver.halt(true); dedicatedserver.halt(true);
@@ -221,6 +280,7 @@ @@ -221,6 +281,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);
@ -197,7 +200,7 @@
} catch (Exception exception1) { } catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
} }
@@ -246,7 +306,7 @@ @@ -246,7 +307,7 @@
} }
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry<WorldDimension> iregistry) { public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry<WorldDimension> iregistry) {

View File

@ -33,11 +33,12 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable { public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger(); public static final Logger LOGGER = LogUtils.getLogger();
@@ -247,6 +273,20 @@ @@ -247,6 +273,21 @@
protected SaveData worldData; protected SaveData worldData;
private volatile boolean isSaving; private volatile boolean isSaving;
+ // CraftBukkit start + // CraftBukkit start
+ public final WorldLoader.c datapackconfiguration;
+ public final WorldLoader.a worldLoader; + public final WorldLoader.a worldLoader;
+ public org.bukkit.craftbukkit.CraftServer server; + public org.bukkit.craftbukkit.CraftServer server;
+ public OptionSet options; + public OptionSet options;
@ -54,7 +55,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) { public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference(); AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
@@ -260,14 +300,14 @@ @@ -260,14 +301,14 @@
thread.setPriority(8); thread.setPriority(8);
} }
@ -67,11 +68,11 @@
} }
- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { - public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { + public MinecraftServer(OptionSet options, WorldLoader.c datapackconfiguration, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
super("Server"); super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler(); this.profiler = this.metricsRecorder.getProfiler();
@@ -288,7 +328,7 @@ @@ -288,7 +329,7 @@
this.frameTimer = new CircularTimer(); this.frameTimer = new CircularTimer();
this.registries = worldstem.registries(); this.registries = worldstem.registries();
this.worldData = worldstem.worldData(); this.worldData = worldstem.worldData();
@ -80,12 +81,13 @@
throw new IllegalStateException("Missing Overworld dimension data"); throw new IllegalStateException("Missing Overworld dimension data");
} else { } else {
this.proxy = proxy; this.proxy = proxy;
@@ -311,13 +351,40 @@ @@ -311,13 +352,41 @@
this.serverThread = thread; this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor(); this.executor = SystemUtils.backgroundExecutor();
} }
+ // CraftBukkit start + // CraftBukkit start
+ this.options = options; + this.options = options;
+ this.datapackconfiguration = datapackconfiguration;
+ this.worldLoader = worldLoader; + this.worldLoader = worldLoader;
+ this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit + this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit
+ // Try to see if we're actually running in a terminal, disable jline if not + // Try to see if we're actually running in a terminal, disable jline if not
@ -122,7 +124,7 @@
ScoreboardServer scoreboardserver1 = this.getScoreboard(); ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1); Objects.requireNonNull(scoreboardserver1);
@@ -326,7 +393,7 @@ @@ -326,7 +395,7 @@
protected abstract boolean initServer() throws IOException; protected abstract boolean initServer() throws IOException;
@ -131,7 +133,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) { if (!JvmProfiler.INSTANCE.isRunning()) {
; ;
} }
@@ -334,12 +401,8 @@ @@ -334,12 +403,8 @@
boolean flag = false; boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@ -145,7 +147,7 @@
if (profiledduration != null) { if (profiledduration != null) {
profiledduration.finish(); profiledduration.finish();
} }
@@ -354,25 +417,183 @@ @@ -354,25 +419,183 @@
} }
@ -296,14 +298,14 @@
+ +
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ +
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, this.registryAccess(), org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ WorldPersistentData worldpersistentdata = world.getDataStorage(); + WorldPersistentData worldpersistentdata = world.getDataStorage();
+ this.readScoreboard(worldpersistentdata); + this.readScoreboard(worldpersistentdata);
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
+ this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ } else { + } else {
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, this.registryAccess(), org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ } + }
+ +
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); + worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
@ -344,7 +346,7 @@
if (!iworlddataserver.isInitialized()) { if (!iworlddataserver.isInitialized()) {
try { try {
@@ -396,29 +617,8 @@ @@ -396,29 +619,8 @@
iworlddataserver.setInitialized(true); iworlddataserver.setInitialized(true);
} }
@ -375,7 +377,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) { if (flag1) {
@@ -426,6 +626,21 @@ @@ -426,6 +628,21 @@
} else { } else {
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
@ -397,7 +399,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) { if (i < worldserver.getMinBuildHeight()) {
@@ -485,8 +700,11 @@ @@ -485,8 +702,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR); iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
} }
@ -411,7 +413,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos(); BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -496,19 +714,23 @@ @@ -496,19 +716,23 @@
chunkproviderserver.getLightEngine().setTaskPerBatch(500); chunkproviderserver.getLightEngine().setTaskPerBatch(500);
this.nextTickTime = SystemUtils.getMillis(); this.nextTickTime = SystemUtils.getMillis();
@ -444,7 +446,7 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks"); ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
if (forcedchunk != null) { if (forcedchunk != null) {
@@ -523,11 +745,18 @@ @@ -523,11 +747,18 @@
} }
} }
@ -466,7 +468,7 @@
} }
public EnumGamemode getDefaultGameType() { public EnumGamemode getDefaultGameType() {
@@ -557,12 +786,16 @@ @@ -557,12 +788,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
} }
@ -483,7 +485,7 @@
if (flag1) { if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator(); Iterator iterator1 = this.getAllLevels().iterator();
@@ -597,12 +830,33 @@ @@ -597,12 +832,33 @@
this.stopServer(); this.stopServer();
} }
@ -517,7 +519,7 @@
if (this.getConnection() != null) { if (this.getConnection() != null) {
this.getConnection().stop(); this.getConnection().stop();
} }
@@ -612,6 +866,7 @@ @@ -612,6 +868,7 @@
MinecraftServer.LOGGER.info("Saving players"); MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll(); this.playerList.saveAll();
this.playerList.removeAll(); this.playerList.removeAll();
@ -525,7 +527,7 @@
} }
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
@@ -707,9 +962,10 @@ @@ -707,9 +964,10 @@
while (this.running) { while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime; long i = SystemUtils.getMillis() - this.nextTickTime;
@ -537,7 +539,7 @@
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L; this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime; this.lastOverloadWarning = this.nextTickTime;
@@ -720,6 +976,7 @@ @@ -720,6 +978,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
} }
@ -545,7 +547,7 @@
this.nextTickTime += 50L; this.nextTickTime += 50L;
this.startMetricsRecordingTick(); this.startMetricsRecordingTick();
this.profiler.push("tick"); this.profiler.push("tick");
@@ -758,6 +1015,12 @@ @@ -758,6 +1017,12 @@
this.services.profileCache().clearExecutor(); this.services.profileCache().clearExecutor();
} }
@ -558,7 +560,7 @@
this.onServerExit(); this.onServerExit();
} }
@@ -791,9 +1054,16 @@ @@ -791,9 +1056,16 @@
} }
private boolean haveTime() { private boolean haveTime() {
@ -576,7 +578,7 @@
protected void waitUntilNextTick() { protected void waitUntilNextTick() {
this.runAllTasks(); this.runAllTasks();
this.managedBlock(() -> { this.managedBlock(() -> {
@@ -838,7 +1108,7 @@ @@ -838,7 +1110,7 @@
} }
} }
@ -585,7 +587,7 @@
this.getProfiler().incrementCounter("runTask"); this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask); super.doRunTask(ticktask);
} }
@@ -909,7 +1179,7 @@ @@ -909,7 +1181,7 @@
} }
} }
@ -594,7 +596,7 @@
MinecraftServer.LOGGER.debug("Autosave started"); MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save"); this.profiler.push("save");
this.saveEverything(true, false, false); this.saveEverything(true, false, false);
@@ -928,22 +1198,39 @@ @@ -928,22 +1200,39 @@
} }
public void tickChildren(BooleanSupplier booleansupplier) { public void tickChildren(BooleanSupplier booleansupplier) {
@ -634,7 +636,7 @@
this.profiler.push("tick"); this.profiler.push("tick");
@@ -1006,6 +1293,22 @@ @@ -1006,6 +1295,22 @@
return (WorldServer) this.levels.get(resourcekey); return (WorldServer) this.levels.get(resourcekey);
} }
@ -657,7 +659,7 @@
public Set<ResourceKey<World>> levelKeys() { public Set<ResourceKey<World>> levelKeys() {
return this.levels.keySet(); return this.levels.keySet();
} }
@@ -1032,7 +1335,7 @@ @@ -1032,7 +1337,7 @@
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
@ -666,7 +668,7 @@
} }
public SystemReport fillSystemReport(SystemReport systemreport) { public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1370,11 +1673,11 @@ @@ -1370,11 +1675,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) { public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE); IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -680,7 +682,7 @@
}, this).thenCompose((immutablelist) -> { }, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1389,6 +1692,7 @@ @@ -1389,6 +1694,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> { }).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close(); this.resources.close();
this.resources = minecraftserver_reloadableresources; this.resources = minecraftserver_reloadableresources;
@ -688,7 +690,7 @@
this.packRepository.setSelected(collection); this.packRepository.setSelected(collection);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures()); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
@@ -1757,7 +2061,7 @@ @@ -1757,7 +2063,7 @@
try { try {
label51: label51:
{ {
@ -697,7 +699,7 @@
try { try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules()); arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1807,6 +2111,22 @@ @@ -1807,6 +2113,22 @@
} }
@ -720,7 +722,7 @@
private void startMetricsRecordingTick() { private void startMetricsRecordingTick() {
if (this.willStartRecordingMetrics) { if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -1933,8 +2253,30 @@ @@ -1933,8 +2255,30 @@
} }

View File

@ -24,8 +24,8 @@
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { - public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); - super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit start - Signature changed + // CraftBukkit start - Signature changed
+ public DedicatedServer(joptsimple.OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { + public DedicatedServer(joptsimple.OptionSet options, WorldLoader.c datapackconfiguration, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); + super(options, datapackconfiguration, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit end + // CraftBukkit end
this.settings = dedicatedserversettings; this.settings = dedicatedserversettings;
this.rconConsoleSource = new RemoteControlCommandListener(this); this.rconConsoleSource = new RemoteControlCommandListener(this);

View File

@ -36,32 +36,34 @@
final EntityTickList entityTickList; final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager; public final PersistentEntitySectionManager<Entity> entityManager;
private final GameEventDispatcher gameEventDispatcher; private final GameEventDispatcher gameEventDispatcher;
@@ -197,11 +217,28 @@ @@ -197,11 +217,30 @@
private final StructureCheck structureCheck; private final StructureCheck structureCheck;
private final boolean tickTime; private final boolean tickTime;
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1) { - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Holder holder = worlddimension.type(); - Holder holder = worlddimension.type();
+ // CraftBukkit start + // CraftBukkit start
+ private final IRegistryCustom registries;
+ public final Convertable.ConversionSession convertable; + public final Convertable.ConversionSession convertable;
+ public final UUID uuid; + public final UUID uuid;
+ +
+ public Chunk getChunkIfLoaded(int x, int z) { + public Chunk getChunkIfLoaded(int x, int z) {
+ return this.chunkSource.getChunk(x, z, false); + return this.chunkSource.getChunk(x, z, false);
+ } + }
+
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
+ @Override + @Override
+ public ResourceKey<WorldDimension> getTypeKey() { + public ResourceKey<WorldDimension> getTypeKey() {
+ return convertable.dimensionType; + return convertable.dimensionType;
+ } + }
+
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer + // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, IRegistryCustom registries, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ // Holder holder = worlddimension.type(); // CraftBukkit - decompile error + // Holder holder = worlddimension.type(); // CraftBukkit - decompile error
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
+ super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); + super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
+ this.registries = registries;
+ this.pvpMode = minecraftserver.isPvpAllowed(); + this.pvpMode = minecraftserver.isPvpAllowed();
+ convertable = convertable_conversionsession; + convertable = convertable_conversionsession;
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); + uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
@ -69,7 +71,7 @@
this.players = Lists.newArrayList(); this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList(); this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -215,6 +252,22 @@ @@ -215,6 +254,22 @@
this.customSpawners = list; this.customSpawners = list;
this.serverLevelData = iworlddataserver; this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator(); ChunkGenerator chunkgenerator = worlddimension.generator();
@ -92,7 +94,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites(); boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper(); DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -246,15 +299,16 @@ @@ -246,15 +301,16 @@
long l = minecraftserver.getWorldData().worldGenOptions().seed(); long l = minecraftserver.getWorldData().worldGenOptions().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -112,7 +114,7 @@
} }
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -286,12 +340,20 @@ @@ -286,12 +342,20 @@
long j; long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -136,7 +138,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle(); this.resetWeatherCycle();
} }
@@ -317,7 +379,7 @@ @@ -317,7 +381,7 @@
this.runBlockEvents(); this.runBlockEvents();
this.handlingTick = false; this.handlingTick = false;
gameprofilerfiller.pop(); gameprofilerfiller.pop();
@ -145,7 +147,7 @@
if (flag) { if (flag) {
this.resetEmptyTime(); this.resetEmptyTime();
@@ -333,7 +395,7 @@ @@ -333,7 +397,7 @@
this.entityTickList.forEach((entity) -> { this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) { if (!entity.isRemoved()) {
@ -154,7 +156,7 @@
entity.discard(); entity.discard();
} else { } else {
gameprofilerfiller.push("checkDespawn"); gameprofilerfiller.push("checkDespawn");
@@ -405,7 +467,7 @@ @@ -405,7 +469,7 @@
private void wakeUpAllPlayers() { private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers(); this.sleepStatus.removeAllSleepers();
@ -163,7 +165,7 @@
entityplayer.stopSleepInBed(false, false); entityplayer.stopSleepInBed(false, false);
}); });
} }
@@ -433,7 +495,7 @@ @@ -433,7 +497,7 @@
entityhorseskeleton.setTrap(true); entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0); entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -172,7 +174,7 @@
} }
} }
@@ -442,7 +504,7 @@ @@ -442,7 +506,7 @@
if (entitylightning != null) { if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1); entitylightning.setVisualOnly(flag1);
@ -181,7 +183,7 @@
} }
} }
} }
@@ -456,7 +518,7 @@ @@ -456,7 +520,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value(); BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) { if (biomebase.shouldFreeze(this, blockposition1)) {
@ -190,7 +192,7 @@
} }
if (flag) { if (flag) {
@@ -471,10 +533,10 @@ @@ -471,10 +535,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition);
@ -203,7 +205,7 @@
} }
} }
@@ -671,6 +733,7 @@ @@ -671,6 +735,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
} }
@ -211,7 +213,7 @@
if (this.oRainLevel != this.rainLevel) { if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
} }
@@ -689,14 +752,47 @@ @@ -689,14 +754,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
@ -261,7 +263,7 @@
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -731,6 +827,7 @@ @@ -731,6 +829,7 @@
}); });
gameprofilerfiller.incrementCounter("tickNonPassenger"); gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick(); entity.tick();
@ -269,7 +271,7 @@
this.getProfiler().pop(); this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator(); Iterator iterator = entity.getPassengers().iterator();
@@ -754,6 +851,7 @@ @@ -754,6 +853,7 @@
}); });
gameprofilerfiller.incrementCounter("tickPassenger"); gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick(); entity1.rideTick();
@ -277,7 +279,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator(); Iterator iterator = entity1.getPassengers().iterator();
@@ -778,6 +876,7 @@ @@ -778,6 +878,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource(); ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) { if (!flag1) {
@ -285,7 +287,7 @@
if (iprogressupdate != null) { if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
} }
@@ -795,11 +894,19 @@ @@ -795,11 +896,19 @@
} }
} }
@ -295,7 +297,7 @@
+ +
+ serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); + serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings());
+ serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); + serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save());
+ convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); + convertable.saveDataTag(this.registries, this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
+ // CraftBukkit end + // CraftBukkit end
} }
@ -306,7 +308,7 @@
} }
this.getChunkSource().getDataStorage().save(); this.getChunkSource().getDataStorage().save();
@@ -864,15 +971,37 @@ @@ -864,15 +973,37 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {
@ -347,7 +349,7 @@
} }
public void addDuringCommandTeleport(EntityPlayer entityplayer) { public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -903,24 +1032,37 @@ @@ -903,24 +1034,37 @@
this.entityManager.addNewEntity(entityplayer); this.entityManager.addNewEntity(entityplayer);
} }
@ -389,7 +391,7 @@
return true; return true;
} }
} }
@@ -934,10 +1076,32 @@ @@ -934,10 +1078,32 @@
entityplayer.remove(entity_removalreason); entityplayer.remove(entity_removalreason);
} }
@ -422,7 +424,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -946,6 +1110,12 @@ @@ -946,6 +1112,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY(); double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ(); double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -435,7 +437,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
} }
@@ -1005,7 +1175,18 @@ @@ -1005,7 +1177,18 @@
Iterator iterator = this.navigatingMobs.iterator(); Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -455,7 +457,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation(); NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) { if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1062,6 +1243,11 @@ @@ -1062,6 +1245,11 @@
@Override @Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) { public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) {
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false); Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false);
@ -467,7 +469,7 @@
if (!explosion.interactsWithBlocks()) { if (!explosion.interactsWithBlocks()) {
explosion.clearToBlow(); explosion.clearToBlow();
@@ -1134,13 +1320,20 @@ @@ -1134,13 +1322,20 @@
} }
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -490,7 +492,7 @@
++j; ++j;
} }
} }
@@ -1191,7 +1384,7 @@ @@ -1191,7 +1386,7 @@
@Nullable @Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) { public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -499,7 +501,7 @@
return null; return null;
} else { } else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey); Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
@@ -1233,11 +1426,21 @@ @@ -1233,11 +1428,21 @@
@Nullable @Nullable
@Override @Override
public WorldMap getMapData(String s) { public WorldMap getMapData(String s) {
@ -522,7 +524,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap); this.getServer().overworld().getDataStorage().set(s, worldmap);
} }
@@ -1535,6 +1738,11 @@ @@ -1535,6 +1740,11 @@
@Override @Override
public void blockUpdated(BlockPosition blockposition, Block block) { public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) { if (!this.isDebug()) {
@ -534,7 +536,7 @@
this.updateNeighborsAt(blockposition, block); this.updateNeighborsAt(blockposition, block);
} }
@@ -1554,12 +1762,12 @@ @@ -1554,12 +1764,12 @@
} }
public boolean isFlat() { public boolean isFlat() {
@ -549,7 +551,7 @@
} }
@Nullable @Nullable
@@ -1582,7 +1790,7 @@ @@ -1582,7 +1792,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) { private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try { try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap(); Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -558,7 +560,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
T t0 = iterator.next(); T t0 = iterator.next();
@@ -1591,7 +1799,7 @@ @@ -1591,7 +1801,7 @@
object2intopenhashmap.addTo(s, 1); object2intopenhashmap.addTo(s, 1);
} }
@ -567,7 +569,7 @@
String s1 = (String) entry.getKey(); String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue(); return s1 + ":" + entry.getIntValue();
@@ -1602,17 +1810,33 @@ @@ -1602,17 +1812,33 @@
} }
public static void makeObsidianPlatform(WorldServer worldserver) { public static void makeObsidianPlatform(WorldServer worldserver) {
@ -603,7 +605,7 @@
} }
@Override @Override
@@ -1728,6 +1952,7 @@ @@ -1728,6 +1954,7 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -611,7 +613,7 @@
} }
public void onTrackingEnd(Entity entity) { public void onTrackingEnd(Entity entity) {
@@ -1764,6 +1989,14 @@ @@ -1764,6 +1991,14 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -49,6 +49,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import jline.console.ConsoleReader; import jline.console.ConsoleReader;
import net.minecraft.SystemUtils;
import net.minecraft.advancements.Advancement; import net.minecraft.advancements.Advancement;
import net.minecraft.commands.CommandDispatcher; import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.CommandListenerWrapper; import net.minecraft.commands.CommandListenerWrapper;
@ -56,6 +57,7 @@ import net.minecraft.commands.arguments.ArgumentEntity;
import net.minecraft.core.BlockPosition; import net.minecraft.core.BlockPosition;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.DynamicOpsNBT;
@ -66,6 +68,7 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerCommand; import net.minecraft.server.ServerCommand;
import net.minecraft.server.WorldLoader; import net.minecraft.server.WorldLoader;
import net.minecraft.server.WorldStem;
import net.minecraft.server.bossevents.BossBattleCustom; import net.minecraft.server.bossevents.BossBattleCustom;
import net.minecraft.server.commands.CommandReload; import net.minecraft.server.commands.CommandReload;
import net.minecraft.server.dedicated.DedicatedPlayerList; import net.minecraft.server.dedicated.DedicatedPlayerList;
@ -1051,14 +1054,15 @@ public final class CraftServer implements Server {
boolean hardcore = creator.hardcore(); boolean hardcore = creator.hardcore();
WorldDataServer worlddata; WorldLoader.c worldloader_c = console.datapackconfiguration;
WorldLoader.a worldloader_a = console.worldLoader; WorldStem worldstem = SystemUtils.blockUntilDone((executor) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); 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()); Pair<SaveData, WorldDimensions.b> pair = worldSession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
if (pair != null) { if (pair != null) {
worlddata = (WorldDataServer) pair.getFirst(); return new WorldLoader.b<>(pair.getFirst(), pair.getSecond().dimensionsRegistryAccess());
} else { } else {
WorldSettings worldsettings; WorldSettings worldsettings;
WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false); WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
@ -1072,20 +1076,25 @@ public final class CraftServer implements Server {
WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry); WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry);
Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle()); Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle());
worlddata = new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle); return new WorldLoader.b<>(new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle), worlddimensions_b.dimensionsRegistryAccess());
} }
}, WorldStem::new, SystemUtils.backgroundExecutor(), executor);
}).join();
IRegistryCustom registries = worldstem.registries().compositeAccess();
WorldDataServer worlddata = (WorldDataServer) worldstem.worldData();
worlddata.checkName(name); worlddata.checkName(name);
worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified()); worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified());
if (console.options.has("forceUpgrade")) { if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> { net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> {
return true; return true;
}, iregistry); }, registries.registryOrThrow(Registries.LEVEL_STEM));
} }
long j = BiomeManager.obfuscateSeed(creator.seed()); long j = BiomeManager.obfuscateSeed(creator.seed());
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
WorldDimension worlddimension = this.getServer().registries().compositeAccess().registryOrThrow(Registries.LEVEL_STEM).get(actualDimension); WorldDimension worlddimension = registries.registryOrThrow(Registries.LEVEL_STEM).get(actualDimension);
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.type().value()); WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.type().value());
if (biomeProvider == null && generator != null) { if (biomeProvider == null && generator != null) {
@ -1103,7 +1112,7 @@ public final class CraftServer implements Server {
} }
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11), WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11),
worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, registries, creator.environment(), generator, biomeProvider);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
return null; return null;