SPIGOT-7210: Fix structures in custom worlds
This commit is contained in:
parent
585ab5ba1b
commit
2ed3e3e6e5
@ -87,7 +87,7 @@
|
||||
WorldInfo worldinfo = convertable_conversionsession.getSummary();
|
||||
|
||||
if (worldinfo != null) {
|
||||
@@ -137,21 +165,41 @@
|
||||
@@ -137,13 +165,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,14 +116,11 @@
|
||||
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
|
||||
+ }
|
||||
+ AtomicReference<WorldLoader.a> worldLoader = new AtomicReference<>();
|
||||
+ WorldLoader.c datapackconfiguration;
|
||||
+ // CraftBukkit end
|
||||
|
||||
WorldStem worldstem;
|
||||
|
||||
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
|
||||
@@ -152,6 +198,7 @@
|
||||
|
||||
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
|
||||
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
|
||||
@ -131,7 +128,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 +211,7 @@
|
||||
@@ -163,7 +210,7 @@
|
||||
WorldOptions worldoptions;
|
||||
WorldDimensions worlddimensions;
|
||||
|
||||
@ -140,7 +137,7 @@
|
||||
worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
worldoptions = WorldOptions.DEMO_OPTIONS;
|
||||
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
|
||||
@@ -171,7 +219,7 @@
|
||||
@@ -171,7 +218,7 @@
|
||||
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
|
||||
|
||||
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
|
||||
@ -149,7 +146,7 @@
|
||||
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
}
|
||||
|
||||
@@ -187,6 +235,7 @@
|
||||
@@ -187,6 +234,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,14 +154,14 @@
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
|
||||
|
||||
if (optionset.has(optionspec4)) {
|
||||
@@ -198,21 +247,32 @@
|
||||
@@ -198,21 +246,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, datapackconfiguration, worldLoader.get(), 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);
|
||||
|
||||
+ /*
|
||||
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
|
||||
@ -192,7 +189,7 @@
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.halt(true);
|
||||
@@ -221,6 +281,7 @@
|
||||
@@ -221,6 +280,7 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@ -200,7 +197,7 @@
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
|
||||
}
|
||||
@@ -246,7 +307,7 @@
|
||||
@@ -246,7 +306,7 @@
|
||||
}
|
||||
|
||||
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry<WorldDimension> iregistry) {
|
||||
|
@ -33,12 +33,11 @@
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -247,6 +273,21 @@
|
||||
@@ -247,6 +273,20 @@
|
||||
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;
|
||||
@ -55,7 +54,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -260,14 +301,14 @@
|
||||
@@ -260,14 +300,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@ -68,11 +67,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.c datapackconfiguration, 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.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 +329,7 @@
|
||||
@@ -288,7 +328,7 @@
|
||||
this.frameTimer = new CircularTimer();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
@ -81,13 +80,12 @@
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -311,13 +352,41 @@
|
||||
@@ -311,13 +351,40 @@
|
||||
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
|
||||
@ -124,7 +122,7 @@
|
||||
ScoreboardServer scoreboardserver1 = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver1);
|
||||
@@ -326,7 +395,7 @@
|
||||
@@ -326,7 +393,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@ -133,7 +131,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -334,12 +403,8 @@
|
||||
@@ -334,12 +401,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@ -147,7 +145,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -354,25 +419,183 @@
|
||||
@@ -354,25 +417,183 @@
|
||||
|
||||
}
|
||||
|
||||
@ -298,14 +296,14 @@
|
||||
+
|
||||
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
|
||||
+
|
||||
+ 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);
|
||||
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, 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, this.registryAccess(), org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||
+ }
|
||||
+
|
||||
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
|
||||
@ -346,7 +344,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -396,29 +619,8 @@
|
||||
@@ -396,29 +617,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@ -377,7 +375,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -426,6 +628,21 @@
|
||||
@@ -426,6 +626,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@ -399,7 +397,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -485,8 +702,11 @@
|
||||
@@ -485,8 +700,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@ -413,7 +411,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -496,19 +716,23 @@
|
||||
@@ -496,19 +714,23 @@
|
||||
|
||||
chunkproviderserver.getLightEngine().setTaskPerBatch(500);
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@ -446,7 +444,7 @@
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -523,11 +747,18 @@
|
||||
@@ -523,11 +745,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +466,7 @@
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -557,12 +788,16 @@
|
||||
@@ -557,12 +786,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@ -485,7 +483,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -597,12 +832,33 @@
|
||||
@@ -597,12 +830,33 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@ -519,7 +517,7 @@
|
||||
if (this.getConnection() != null) {
|
||||
this.getConnection().stop();
|
||||
}
|
||||
@@ -612,6 +868,7 @@
|
||||
@@ -612,6 +866,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.saveAll();
|
||||
this.playerList.removeAll();
|
||||
@ -527,7 +525,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -707,9 +964,10 @@
|
||||
@@ -707,9 +962,10 @@
|
||||
while (this.running) {
|
||||
long i = SystemUtils.getMillis() - this.nextTickTime;
|
||||
|
||||
@ -539,7 +537,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 +978,7 @@
|
||||
@@ -720,6 +976,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@ -547,7 +545,7 @@
|
||||
this.nextTickTime += 50L;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -758,6 +1017,12 @@
|
||||
@@ -758,6 +1015,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@ -560,7 +558,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -791,9 +1056,16 @@
|
||||
@@ -791,9 +1054,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@ -578,7 +576,7 @@
|
||||
protected void waitUntilNextTick() {
|
||||
this.runAllTasks();
|
||||
this.managedBlock(() -> {
|
||||
@@ -838,7 +1110,7 @@
|
||||
@@ -838,7 +1108,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +585,7 @@
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -909,7 +1181,7 @@
|
||||
@@ -909,7 +1179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,7 +594,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -928,22 +1200,39 @@
|
||||
@@ -928,22 +1198,39 @@
|
||||
}
|
||||
|
||||
public void tickChildren(BooleanSupplier booleansupplier) {
|
||||
@ -636,7 +634,7 @@
|
||||
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1006,6 +1295,22 @@
|
||||
@@ -1006,6 +1293,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@ -659,7 +657,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1032,7 +1337,7 @@
|
||||
@@ -1032,7 +1335,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -668,7 +666,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1370,11 +1675,11 @@
|
||||
@@ -1370,11 +1673,11 @@
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@ -682,7 +680,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
|
||||
|
||||
@@ -1389,6 +1694,7 @@
|
||||
@@ -1389,6 +1692,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@ -690,7 +688,7 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1757,7 +2063,7 @@
|
||||
@@ -1757,7 +2061,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@ -699,7 +697,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -1807,6 +2113,22 @@
|
||||
@@ -1807,6 +2111,22 @@
|
||||
|
||||
}
|
||||
|
||||
@ -722,7 +720,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 +2255,30 @@
|
||||
@@ -1933,8 +2253,30 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -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.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);
|
||||
+ 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);
|
||||
+ // CraftBukkit end
|
||||
this.settings = dedicatedserversettings;
|
||||
this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
|
@ -36,34 +36,32 @@
|
||||
final EntityTickList entityTickList;
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
private final GameEventDispatcher gameEventDispatcher;
|
||||
@@ -197,11 +217,30 @@
|
||||
@@ -197,11 +217,28 @@
|
||||
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, IRegistryCustom registries, 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, 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());
|
||||
@ -71,7 +69,7 @@
|
||||
this.players = Lists.newArrayList();
|
||||
this.entityTickList = new EntityTickList();
|
||||
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
|
||||
@@ -215,6 +254,22 @@
|
||||
@@ -215,6 +252,22 @@
|
||||
this.customSpawners = list;
|
||||
this.serverLevelData = iworlddataserver;
|
||||
ChunkGenerator chunkgenerator = worlddimension.generator();
|
||||
@ -94,7 +92,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 +301,16 @@
|
||||
@@ -246,15 +299,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);
|
||||
@ -114,7 +112,7 @@
|
||||
}
|
||||
|
||||
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
|
||||
@@ -286,12 +342,20 @@
|
||||
@@ -286,12 +340,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
@ -138,7 +136,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -317,7 +381,7 @@
|
||||
@@ -317,7 +379,7 @@
|
||||
this.runBlockEvents();
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@ -147,7 +145,7 @@
|
||||
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
@@ -333,7 +397,7 @@
|
||||
@@ -333,7 +395,7 @@
|
||||
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
@ -156,7 +154,7 @@
|
||||
entity.discard();
|
||||
} else {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
@@ -405,7 +469,7 @@
|
||||
@@ -405,7 +467,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@ -165,7 +163,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -433,7 +497,7 @@
|
||||
@@ -433,7 +495,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@ -174,7 +172,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +506,7 @@
|
||||
@@ -442,7 +504,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@ -183,7 +181,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -456,7 +520,7 @@
|
||||
@@ -456,7 +518,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition1)) {
|
||||
@ -192,7 +190,7 @@
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@@ -471,10 +535,10 @@
|
||||
@@ -471,10 +533,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition);
|
||||
@ -205,7 +203,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,6 +735,7 @@
|
||||
@@ -671,6 +733,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@ -213,7 +211,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -689,14 +754,47 @@
|
||||
@@ -689,14 +752,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));
|
||||
}
|
||||
@ -263,7 +261,7 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -731,6 +829,7 @@
|
||||
@@ -731,6 +827,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
@ -271,7 +269,7 @@
|
||||
this.getProfiler().pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -754,6 +853,7 @@
|
||||
@@ -754,6 +851,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
@ -279,7 +277,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -778,6 +878,7 @@
|
||||
@@ -778,6 +876,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
@ -287,7 +285,7 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -795,11 +896,19 @@
|
||||
@@ -795,11 +894,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -297,7 +295,7 @@
|
||||
+
|
||||
+ serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings());
|
||||
+ serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save());
|
||||
+ convertable.saveDataTag(this.registries, this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
|
||||
+ convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@ -308,7 +306,7 @@
|
||||
}
|
||||
|
||||
this.getChunkSource().getDataStorage().save();
|
||||
@@ -864,15 +973,37 @@
|
||||
@@ -864,15 +971,37 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@ -349,7 +347,7 @@
|
||||
}
|
||||
|
||||
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
|
||||
@@ -903,24 +1034,37 @@
|
||||
@@ -903,24 +1032,37 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
@ -391,7 +389,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -934,10 +1078,32 @@
|
||||
@@ -934,10 +1076,32 @@
|
||||
entityplayer.remove(entity_removalreason);
|
||||
}
|
||||
|
||||
@ -424,7 +422,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -946,6 +1112,12 @@
|
||||
@@ -946,6 +1110,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
@ -437,7 +435,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1005,7 +1177,18 @@
|
||||
@@ -1005,7 +1175,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -457,7 +455,7 @@
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(blockposition)) {
|
||||
@@ -1062,6 +1245,11 @@
|
||||
@@ -1062,6 +1243,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);
|
||||
@ -469,7 +467,7 @@
|
||||
|
||||
if (!explosion.interactsWithBlocks()) {
|
||||
explosion.clearToBlow();
|
||||
@@ -1134,13 +1322,20 @@
|
||||
@@ -1134,13 +1320,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) {
|
||||
@ -492,7 +490,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1191,7 +1386,7 @@
|
||||
@@ -1191,7 +1384,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
|
||||
@ -501,7 +499,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
|
||||
@@ -1233,11 +1428,21 @@
|
||||
@@ -1233,11 +1426,21 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap getMapData(String s) {
|
||||
@ -524,7 +522,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(s, worldmap);
|
||||
}
|
||||
|
||||
@@ -1535,6 +1740,11 @@
|
||||
@@ -1535,6 +1738,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@ -536,7 +534,7 @@
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1554,12 +1764,12 @@
|
||||
@@ -1554,12 +1762,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@ -551,7 +549,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1582,7 +1792,7 @@
|
||||
@@ -1582,7 +1790,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@ -560,7 +558,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1591,7 +1801,7 @@
|
||||
@@ -1591,7 +1799,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@ -569,7 +567,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1602,17 +1812,33 @@
|
||||
@@ -1602,17 +1810,33 @@
|
||||
}
|
||||
|
||||
public static void makeObsidianPlatform(WorldServer worldserver) {
|
||||
@ -605,7 +603,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1728,6 +1954,7 @@
|
||||
@@ -1728,6 +1952,7 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@ -613,7 +611,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1764,6 +1991,14 @@
|
||||
@@ -1764,6 +1989,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
@ -1,13 +1,17 @@
|
||||
--- a/net/minecraft/world/level/storage/WorldDataServer.java
|
||||
+++ b/net/minecraft/world/level/storage/WorldDataServer.java
|
||||
@@ -43,6 +43,15 @@
|
||||
@@ -43,6 +43,19 @@
|
||||
import net.minecraft.world.level.timers.CustomFunctionCallbackTimers;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.IRegistry;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutServerDifficulty;
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import net.minecraft.server.level.WorldServer;
|
||||
+import net.minecraft.world.level.dimension.WorldDimension;
|
||||
+import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
+import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
@ -16,11 +20,12 @@
|
||||
public class WorldDataServer implements IWorldDataServer, SaveData {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -83,6 +92,19 @@
|
||||
@@ -83,6 +96,20 @@
|
||||
private final Set<String> knownServerBrands;
|
||||
private boolean wasModded;
|
||||
private final CustomFunctionCallbackTimerQueue<MinecraftServer> scheduledEvents;
|
||||
+ // CraftBukkit start - Add world and pdc
|
||||
+ public IRegistry<WorldDimension> customDimensions;
|
||||
+ private WorldServer world;
|
||||
+ protected NBTBase pdc;
|
||||
+
|
||||
@ -36,7 +41,7 @@
|
||||
|
||||
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set<String> set, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
|
||||
this.fixerUpper = datafixer;
|
||||
@@ -127,7 +149,8 @@
|
||||
@@ -127,7 +154,8 @@
|
||||
return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue();
|
||||
});
|
||||
|
||||
@ -46,7 +51,7 @@
|
||||
return dynamic1.asString().result().stream();
|
||||
}).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, worldoptions, worlddataserver_a, lifecycle);
|
||||
}
|
||||
@@ -147,7 +170,7 @@
|
||||
@@ -147,7 +175,7 @@
|
||||
|
||||
private void setTagData(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@ -55,16 +60,16 @@
|
||||
|
||||
Objects.requireNonNull(nbttaglist);
|
||||
stream.forEach(nbttaglist::add);
|
||||
@@ -162,7 +185,7 @@
|
||||
@@ -162,7 +190,7 @@
|
||||
nbttagcompound.put("Version", nbttagcompound2);
|
||||
nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
|
||||
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom);
|
||||
- DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom);
|
||||
+ DataResult<NBTBase> dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); // CraftBukkit - decompile error
|
||||
+ DataResult<NBTBase> dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.registryOrThrow(Registries.LEVEL_STEM))); // CraftBukkit
|
||||
Logger logger = WorldDataServer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -214,6 +237,8 @@
|
||||
@@ -214,6 +242,8 @@
|
||||
nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId);
|
||||
}
|
||||
|
||||
@ -73,7 +78,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,6 +356,20 @@
|
||||
@@ -331,6 +361,20 @@
|
||||
|
||||
@Override
|
||||
public void setThundering(boolean flag) {
|
||||
@ -94,7 +99,7 @@
|
||||
this.thundering = flag;
|
||||
}
|
||||
|
||||
@@ -351,6 +390,20 @@
|
||||
@@ -351,6 +395,20 @@
|
||||
|
||||
@Override
|
||||
public void setRaining(boolean flag) {
|
||||
@ -115,7 +120,7 @@
|
||||
this.raining = flag;
|
||||
}
|
||||
|
||||
@@ -417,6 +470,12 @@
|
||||
@@ -417,6 +475,12 @@
|
||||
@Override
|
||||
public void setDifficulty(EnumDifficulty enumdifficulty) {
|
||||
this.settings = this.settings.withDifficulty(enumdifficulty);
|
||||
@ -128,7 +133,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -548,6 +607,14 @@
|
||||
@@ -548,6 +612,14 @@
|
||||
return this.settings.copy();
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ 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;
|
||||
@ -57,7 +56,6 @@ 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;
|
||||
@ -68,7 +66,6 @@ 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;
|
||||
@ -1054,47 +1051,44 @@ public final class CraftServer implements Server {
|
||||
|
||||
boolean hardcore = creator.hardcore();
|
||||
|
||||
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());
|
||||
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());
|
||||
|
||||
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;
|
||||
if (pair != null) {
|
||||
worlddata = (WorldDataServer) pair.getFirst();
|
||||
iregistry = pair.getSecond().dimensions();
|
||||
} 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());
|
||||
|
||||
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 = new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle);
|
||||
iregistry = worlddimensions_b.dimensions();
|
||||
}
|
||||
worlddata.customDimensions = iregistry;
|
||||
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;
|
||||
}, registries.registryOrThrow(Registries.LEVEL_STEM));
|
||||
}, iregistry);
|
||||
}
|
||||
|
||||
long j = BiomeManager.obfuscateSeed(creator.seed());
|
||||
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
|
||||
WorldDimension worlddimension = registries.registryOrThrow(Registries.LEVEL_STEM).get(actualDimension);
|
||||
WorldDimension worlddimension = iregistry.get(actualDimension);
|
||||
|
||||
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.type().value());
|
||||
if (biomeProvider == null && generator != null) {
|
||||
@ -1112,7 +1106,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, registries, creator.environment(), generator, biomeProvider);
|
||||
worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
|
||||
|
||||
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user