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();
if (worldinfo != null) {
@@ -137,13 +165,31 @@
@@ -137,21 +165,41 @@
}
}
@ -116,11 +116,14 @@
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
+ }
+ AtomicReference<WorldLoader.a> worldLoader = new AtomicReference<>();
+ WorldLoader.c datapackconfiguration;
+ // CraftBukkit end
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) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
@ -128,7 +131,7 @@
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 = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
@@ -163,7 +210,7 @@
@@ -163,7 +211,7 @@
WorldOptions worldoptions;
WorldDimensions worlddimensions;
@ -137,7 +140,7 @@
worldsettings = MinecraftServer.DEMO_SETTINGS;
worldoptions = WorldOptions.DEMO_OPTIONS;
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
@@ -171,7 +218,7 @@
@@ -171,7 +219,7 @@
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
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());
}
@@ -187,6 +234,7 @@
@@ -187,6 +235,7 @@
return;
}
@ -154,14 +157,14 @@
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
if (optionset.has(optionspec4)) {
@@ -198,21 +246,32 @@
@@ -198,21 +247,32 @@
SaveData savedata = worldstem.worldData();
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
+ */
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(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);
@ -189,7 +192,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.halt(true);
@@ -221,6 +280,7 @@
@@ -221,6 +281,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -197,7 +200,7 @@
} catch (Exception 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) {

View File

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

View File

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

View File

@ -49,6 +49,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import jline.console.ConsoleReader;
import net.minecraft.SystemUtils;
import net.minecraft.advancements.Advancement;
import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.CommandListenerWrapper;
@ -56,6 +57,7 @@ import net.minecraft.commands.arguments.ArgumentEntity;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.DynamicOpsNBT;
@ -66,6 +68,7 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerCommand;
import net.minecraft.server.WorldLoader;
import net.minecraft.server.WorldStem;
import net.minecraft.server.bossevents.BossBattleCustom;
import net.minecraft.server.commands.CommandReload;
import net.minecraft.server.dedicated.DedicatedPlayerList;
@ -1051,41 +1054,47 @@ public final class CraftServer implements Server {
boolean hardcore = creator.hardcore();
WorldDataServer worlddata;
WorldLoader.a worldloader_a = console.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());
WorldLoader.c worldloader_c = console.datapackconfiguration;
WorldStem worldstem = SystemUtils.blockUntilDone((executor) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
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 (pair != null) {
worlddata = (WorldDataServer) pair.getFirst();
} else {
WorldSettings worldsettings;
WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
WorldDimensions worlddimensions;
if (pair != null) {
return new WorldLoader.b<>(pair.getFirst(), pair.getSecond().dimensionsRegistryAccess());
} else {
WorldSettings worldsettings;
WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
WorldDimensions worlddimensions;
DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT));
DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT));
worldsettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), worldloader_a.dataConfiguration());
worlddimensions = properties.create(worldloader_a.datapackWorldgen());
worldsettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), worldloader_a.dataConfiguration());
worlddimensions = properties.create(worldloader_a.datapackWorldgen());
WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry);
Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle());
WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry);
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.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified());
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> {
return true;
}, iregistry);
}, registries.registryOrThrow(Registries.LEVEL_STEM));
}
long j = BiomeManager.obfuscateSeed(creator.seed());
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());
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),
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)))) {
return null;