proper migration to gamerules for keep spawn loaded distance

This commit is contained in:
Jake Potrebic 2024-04-27 15:50:33 -07:00
parent dd571d89f2
commit d02bb811de
No known key found for this signature in database
GPG Key ID: ECE0B3C133C016C5
1017 changed files with 227 additions and 410 deletions

View File

@ -121,12 +121,13 @@ index 0000000000000000000000000000000000000000..042478cf7ce150f1f1bc5cddd7fa40f8
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e4762e72eff index 0000000000000000000000000000000000000000..522156e1b7578663c426fcaf7e47acb93d030486
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
@@ -0,0 +1,355 @@ @@ -0,0 +1,360 @@
+package io.papermc.paper.configuration; +package io.papermc.paper.configuration;
+ +
+import com.google.common.base.Preconditions;
+import com.mojang.logging.LogUtils; +import com.mojang.logging.LogUtils;
+import io.leangen.geantyref.TypeToken; +import io.leangen.geantyref.TypeToken;
+import io.papermc.paper.configuration.constraint.Constraint; +import io.papermc.paper.configuration.constraint.Constraint;
@ -134,6 +135,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistryAccess;
+import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.GameRules;
+import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.MustBeInvokedByOverriders; +import org.jetbrains.annotations.MustBeInvokedByOverriders;
+import org.slf4j.Logger; +import org.slf4j.Logger;
@ -141,6 +143,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+import org.spongepowered.configurate.ConfigurateException; +import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.ConfigurationNode; +import org.spongepowered.configurate.ConfigurationNode;
+import org.spongepowered.configurate.ConfigurationOptions; +import org.spongepowered.configurate.ConfigurationOptions;
+import org.spongepowered.configurate.NodePath;
+import org.spongepowered.configurate.objectmapping.ObjectMapper; +import org.spongepowered.configurate.objectmapping.ObjectMapper;
+import org.spongepowered.configurate.serialize.SerializationException; +import org.spongepowered.configurate.serialize.SerializationException;
+import org.spongepowered.configurate.util.CheckedFunction; +import org.spongepowered.configurate.util.CheckedFunction;
@ -210,9 +213,9 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+ return this.createLoaderBuilder(); + return this.createLoaderBuilder();
+ } + }
+ +
+ static <T> CheckedFunction<ConfigurationNode, T, SerializationException> creator(Class<T> type, boolean refreshNode) { + static <T> CheckedFunction<ConfigurationNode, T, SerializationException> creator(final Class<? extends T> type, final boolean refreshNode) {
+ return node -> { + return node -> {
+ T instance = node.require(type); + final T instance = node.require(type);
+ if (refreshNode) { + if (refreshNode) {
+ node.set(type, instance); + node.set(type, instance);
+ } + }
@ -300,7 +303,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+ this.applyWorldConfigTransformations(contextMap, node); + this.applyWorldConfigTransformations(contextMap, node);
+ final W instance = node.require(this.worldConfigClass); + final W instance = node.require(this.worldConfigClass);
+ node.set(this.worldConfigClass, instance); + node.set(this.worldConfigClass, instance);
+ trySaveFileNode(loader, node, configFile.toString()); + this.trySaveFileNode(loader, node, configFile.toString());
+ } + }
+ +
+ private DefaultWorldLoader createDefaultWorldLoader(final boolean requireFile, final ContextMap contextMap, final Path configFile) { + private DefaultWorldLoader createDefaultWorldLoader(final boolean requireFile, final ContextMap contextMap, final Path configFile) {
@ -335,6 +338,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+ } + }
+ +
+ protected W createWorldConfig(final ContextMap contextMap, final CheckedFunction<ConfigurationNode, W, SerializationException> creator) throws IOException { + protected W createWorldConfig(final ContextMap contextMap, final CheckedFunction<ConfigurationNode, W, SerializationException> creator) throws IOException {
+ Preconditions.checkArgument(!contextMap.isDefaultWorldContext(), "cannot create world map with default world context");
+ final Path defaultsConfigFile = this.globalFolder.resolve(this.defaultWorldConfigFileName); + final Path defaultsConfigFile = this.globalFolder.resolve(this.defaultWorldConfigFileName);
+ final YamlConfigurationLoader defaultsLoader = this.createDefaultWorldLoader(true, this.createDefaultContextMap(contextMap.require(REGISTRY_ACCESS)).build(), defaultsConfigFile).loader(); + final YamlConfigurationLoader defaultsLoader = this.createDefaultWorldLoader(true, this.createDefaultContextMap(contextMap.require(REGISTRY_ACCESS)).build(), defaultsConfigFile).loader();
+ final ConfigurationNode defaultsNode = defaultsLoader.load(); + final ConfigurationNode defaultsNode = defaultsLoader.load();
@ -360,7 +364,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+ } + }
+ this.applyWorldConfigTransformations(contextMap, worldNode); + this.applyWorldConfigTransformations(contextMap, worldNode);
+ this.applyDefaultsAwareWorldConfigTransformations(contextMap, worldNode, defaultsNode); + this.applyDefaultsAwareWorldConfigTransformations(contextMap, worldNode, defaultsNode);
+ trySaveFileNode(worldLoader, worldNode, worldConfigFile.toString()); // save before loading node NOTE: don't save the backing node after loading it, or you'll fill up the world-specific config + this.trySaveFileNode(worldLoader, worldNode, worldConfigFile.toString()); // save before loading node NOTE: don't save the backing node after loading it, or you'll fill up the world-specific config
+ worldNode.mergeFrom(defaultsNode); + worldNode.mergeFrom(defaultsNode);
+ return creator.apply(worldNode); + return creator.apply(worldNode);
+ } + }
@ -467,6 +471,7 @@ index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e47
+ public static final ContextKey<ResourceLocation> WORLD_KEY = new ContextKey<>(ResourceLocation.class, "world key"); + public static final ContextKey<ResourceLocation> WORLD_KEY = new ContextKey<>(ResourceLocation.class, "world key");
+ public static final ContextKey<Void> FIRST_DEFAULT = new ContextKey<>(Void.class, "first default"); + public static final ContextKey<Void> FIRST_DEFAULT = new ContextKey<>(Void.class, "first default");
+ public static final ContextKey<RegistryAccess> REGISTRY_ACCESS = new ContextKey<>(RegistryAccess.class, "registry access"); + public static final ContextKey<RegistryAccess> REGISTRY_ACCESS = new ContextKey<>(RegistryAccess.class, "registry access");
+ public static final ContextKey<GameRules> GAME_RULES = new ContextKey<>(GameRules.class, "game rules");
+ +
+ public record ContextKey<T>(TypeToken<T> type, String name) { + public record ContextKey<T>(TypeToken<T> type, String name) {
+ +
@ -837,10 +842,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd08e09874 index 0000000000000000000000000000000000000000..d99489e0216b24d27a19c92a1ce0c10ae10d071f
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -0,0 +1,465 @@ @@ -0,0 +1,464 @@
+package io.papermc.paper.configuration; +package io.papermc.paper.configuration;
+ +
+import com.google.common.base.Suppliers; +import com.google.common.base.Suppliers;
@ -864,6 +869,7 @@ index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd
+import io.papermc.paper.configuration.transformation.global.versioned.V29_LogIPs; +import io.papermc.paper.configuration.transformation.global.versioned.V29_LogIPs;
+import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration; +import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration;
+import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig; +import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig;
+import io.papermc.paper.configuration.transformation.world.SpawnLoadedRangeToGameRule;
+import io.papermc.paper.configuration.transformation.world.versioned.V29_ZeroWorldHeight; +import io.papermc.paper.configuration.transformation.world.versioned.V29_ZeroWorldHeight;
+import io.papermc.paper.configuration.transformation.world.versioned.V30_RenameFilterNbtFromSpawnEgg; +import io.papermc.paper.configuration.transformation.world.versioned.V30_RenameFilterNbtFromSpawnEgg;
+import io.papermc.paper.configuration.type.BooleanOrDefault; +import io.papermc.paper.configuration.type.BooleanOrDefault;
@ -893,6 +899,7 @@ index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd
+import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.item.Item; +import net.minecraft.world.item.Item;
+import net.minecraft.world.level.GameRules;
+import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils;
@ -1121,21 +1128,17 @@ index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd
+ versionedBuilder.build().apply(node); + versionedBuilder.build().apply(node);
+ } + }
+ +
+ private static final List<Transformations.DefaultsAware> DEFAULT_AWARE_TRANSFORMATIONS = List.of(FeatureSeedsGeneration::apply); + private static final List<Transformations.DefaultsAware> DEFAULT_AWARE_TRANSFORMATIONS = List.of(
+ FeatureSeedsGeneration::apply,
+ SpawnLoadedRangeToGameRule::apply
+ );
+ +
+ @Override + @Override
+ protected void applyDefaultsAwareWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode worldNode, final ConfigurationNode defaultsNode) throws ConfigurateException { + protected void applyDefaultsAwareWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode worldNode, final ConfigurationNode defaultsNode) throws ConfigurateException {
+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
+ // ADD FUTURE TRANSFORMS HERE (these transforms run after the defaults have been merged into the node) + // ADD FUTURE TRANSFORMS HERE (these transforms run after the defaults have been merged into the node)
+ DEFAULT_AWARE_TRANSFORMATIONS.forEach(transform -> transform.apply(builder, contextMap, defaultsNode)); + DEFAULT_AWARE_TRANSFORMATIONS.forEach(transform -> transform.apply(builder, contextMap, defaultsNode));
+ + builder.build().apply(worldNode);
+ ConfigurationTransformation transformation;
+ try {
+ transformation = builder.build(); // build throws IAE if no actions were provided (bad zml)
+ } catch (IllegalArgumentException ignored) {
+ return;
+ }
+ transformation.apply(worldNode);
+ } + }
+ +
+ @Override + @Override
@ -1166,16 +1169,17 @@ index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd
+ } + }
+ +
+ private static ContextMap createWorldContextMap(ServerLevel level) { + private static ContextMap createWorldContextMap(ServerLevel level) {
+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess()); + return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess(), level.getGameRules());
+ } + }
+ +
+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, SpigotWorldConfig spigotConfig, RegistryAccess registryAccess) { + public static ContextMap createWorldContextMap(final Path dir, final String levelName, final ResourceLocation worldKey, final SpigotWorldConfig spigotConfig, final RegistryAccess registryAccess, final GameRules gameRules) {
+ return ContextMap.builder() + return ContextMap.builder()
+ .put(WORLD_DIRECTORY, dir) + .put(WORLD_DIRECTORY, dir)
+ .put(WORLD_NAME, levelName) + .put(WORLD_NAME, levelName)
+ .put(WORLD_KEY, worldKey) + .put(WORLD_KEY, worldKey)
+ .put(SPIGOT_WORLD_CONFIG_CONTEXT_KEY, Suppliers.ofInstance(spigotConfig)) + .put(SPIGOT_WORLD_CONFIG_CONTEXT_KEY, Suppliers.ofInstance(spigotConfig))
+ .put(REGISTRY_ACCESS, registryAccess) + .put(REGISTRY_ACCESS, registryAccess)
+ .put(GAME_RULES, gameRules)
+ .build(); + .build();
+ } + }
+ +
@ -1308,10 +1312,10 @@ index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java diff --git a/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ede22142ef70bbdc6ede22ff4a13ed69fbce4915 index 0000000000000000000000000000000000000000..990d1bb46e0f9719f4e9af928d80ac6f8dff23b5
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java
@@ -0,0 +1,80 @@ @@ -0,0 +1,82 @@
+package io.papermc.paper.configuration; +package io.papermc.paper.configuration;
+ +
+import org.spongepowered.configurate.NodePath; +import org.spongepowered.configurate.NodePath;
@ -1368,6 +1372,8 @@ index 0000000000000000000000000000000000000000..ede22142ef70bbdc6ede22ff4a13ed69
+ path("fixes", "fix-curing-zombie-villager-discount-exploit"), + path("fixes", "fix-curing-zombie-villager-discount-exploit"),
+ path("entities", "mob-effects", "undead-immune-to-certain-effects") + path("entities", "mob-effects", "undead-immune-to-certain-effects")
+ }; + };
+ // spawn.keep-spawn-loaded and spawn.keep-spawn-loaded-range are no longer used, but kept
+ // in the world default config for compatibility with old worlds being migrated to use the gamerule
+ +
+ NodePath[] REMOVED_GLOBAL_PATHS = { + NodePath[] REMOVED_GLOBAL_PATHS = {
+ path("data-value-allowed-items"), + path("data-value-allowed-items"),
@ -1394,10 +1400,10 @@ index 0000000000000000000000000000000000000000..ede22142ef70bbdc6ede22ff4a13ed69
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..bfc10ae8e09ac07b969a38eecddfab1e3c308f5a index 0000000000000000000000000000000000000000..b3a39a0b1f54d38207fa55485318e6ca257a57ab
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -0,0 +1,553 @@ @@ -0,0 +1,550 @@
+package io.papermc.paper.configuration; +package io.papermc.paper.configuration;
+ +
+import com.google.common.collect.HashBasedTable; +import com.google.common.collect.HashBasedTable;
@ -1405,7 +1411,6 @@ index 0000000000000000000000000000000000000000..bfc10ae8e09ac07b969a38eecddfab1e
+import com.mojang.logging.LogUtils; +import com.mojang.logging.LogUtils;
+import io.papermc.paper.configuration.legacy.MaxEntityCollisionsInitializer; +import io.papermc.paper.configuration.legacy.MaxEntityCollisionsInitializer;
+import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization; +import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization;
+import io.papermc.paper.configuration.legacy.SpawnLoadedRangeInitializer;
+import io.papermc.paper.configuration.mapping.MergeMap; +import io.papermc.paper.configuration.mapping.MergeMap;
+import io.papermc.paper.configuration.serializer.NbtPathSerializer; +import io.papermc.paper.configuration.serializer.NbtPathSerializer;
+import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration; +import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration;
@ -1463,9 +1468,10 @@ index 0000000000000000000000000000000000000000..bfc10ae8e09ac07b969a38eecddfab1e
+ private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final Logger LOGGER = LogUtils.getClassLogger();
+ static final int CURRENT_VERSION = 30; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs + static final int CURRENT_VERSION = 30; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
+ +
+ private transient final SpigotWorldConfig spigotConfig; + private final transient SpigotWorldConfig spigotConfig;
+ private transient final ResourceLocation worldKey; + private final transient ResourceLocation worldKey;
+ WorldConfiguration(SpigotWorldConfig spigotConfig, ResourceLocation worldKey) { +
+ WorldConfiguration(final SpigotWorldConfig spigotConfig, final ResourceLocation worldKey) {
+ this.spigotConfig = spigotConfig; + this.spigotConfig = spigotConfig;
+ this.worldKey = worldKey; + this.worldKey = worldKey;
+ } + }
@ -1821,9 +1827,6 @@ index 0000000000000000000000000000000000000000..bfc10ae8e09ac07b969a38eecddfab1e
+ public Spawn spawn; + public Spawn spawn;
+ +
+ public class Spawn extends ConfigurationPart { + public class Spawn extends ConfigurationPart {
+ @RequiresSpigotInitialization(SpawnLoadedRangeInitializer.class)
+ public short keepSpawnLoadedRange = 10;
+ public boolean keepSpawnLoaded = true;
+ public boolean allowUsingSignsInsideSpawnProtection = false; + public boolean allowUsingSignsInsideSpawnProtection = false;
+ } + }
+ +
@ -3561,7 +3564,7 @@ index 0000000000000000000000000000000000000000..90071acf589fb2fa1c3480883165b429
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..1326aae8f95ab11f840abdee0c8c7a557705fd73 index 0000000000000000000000000000000000000000..6cdc40cb4a5f94654c874f9dbdb106fa0e4d41f3
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java +++ b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java
@@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
@ -3631,7 +3634,7 @@ index 0000000000000000000000000000000000000000..1326aae8f95ab11f840abdee0c8c7a55
+ +
+ +
+ public static void apply(final ConfigurationTransformation.Builder builder, final Configurations.ContextMap contextMap, final ConfigurationNode defaultsNode) { + public static void apply(final ConfigurationTransformation.Builder builder, final Configurations.ContextMap contextMap, final ConfigurationNode defaultsNode) {
+ if (!contextMap.isDefaultWorldContext() && defaultsNode.node(FEATURE_SEEDS_KEY, GENERATE_KEY).getBoolean(false)) { + if (defaultsNode.node(FEATURE_SEEDS_KEY, GENERATE_KEY).getBoolean(false)) {
+ builder.addAction(path(), new FeatureSeedsGeneration(contextMap.require(Configurations.WORLD_KEY))); + builder.addAction(path(), new FeatureSeedsGeneration(contextMap.require(Configurations.WORLD_KEY)));
+ } + }
+ } + }
@ -3964,6 +3967,63 @@ index 0000000000000000000000000000000000000000..edaa6ef28c1f9a223943969870889700
+ moveFromRootAndRename(builder, path("game-mechanics", oldKey), newKey, parents); + moveFromRootAndRename(builder, path("game-mechanics", oldKey), newKey, parents);
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/SpawnLoadedRangeToGameRule.java b/src/main/java/io/papermc/paper/configuration/transformation/world/SpawnLoadedRangeToGameRule.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f31c0626b6f01da6bb13942126565f844ca5faa
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/transformation/world/SpawnLoadedRangeToGameRule.java
@@ -0,0 +1,51 @@
+package io.papermc.paper.configuration.transformation.world;
+
+import io.papermc.paper.configuration.Configurations;
+import net.minecraft.world.level.GameRules;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.ConfigurationNode;
+import org.spongepowered.configurate.NodePath;
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
+import org.spongepowered.configurate.transformation.TransformAction;
+
+import static org.spongepowered.configurate.NodePath.path;
+
+public final class SpawnLoadedRangeToGameRule implements TransformAction {
+
+ private static final String SPAWN = "spawn";
+ private static final String KEEP_SPAWN_LOADED_RANGE = "keep-spawn-loaded-range";
+ private static final String KEEP_SPAWN_LOADED = "keep-spawn-loaded";
+
+ private final GameRules gameRules;
+ private final ConfigurationNode defaultsNode;
+
+ private SpawnLoadedRangeToGameRule(final GameRules gameRules, final ConfigurationNode defaultsNode) {
+ this.gameRules = gameRules;
+ this.defaultsNode = defaultsNode;
+ }
+
+ @Override
+ public Object @Nullable [] visitPath(final NodePath path, final ConfigurationNode value) {
+ final ConfigurationNode worldSpawnNode = value.node(SPAWN);
+ final ConfigurationNode worldLoadedNode = worldSpawnNode.node(KEEP_SPAWN_LOADED);
+ final boolean keepLoaded = worldLoadedNode.getBoolean(this.defaultsNode.node(SPAWN, KEEP_SPAWN_LOADED).getBoolean());
+ worldLoadedNode.raw(null);
+ final ConfigurationNode worldRangeNode = worldSpawnNode.node(KEEP_SPAWN_LOADED_RANGE);
+ final int range = worldRangeNode.getInt(this.defaultsNode.node(SPAWN, KEEP_SPAWN_LOADED_RANGE).getInt());
+ worldRangeNode.raw(null);
+ if (worldSpawnNode.empty()) {
+ worldSpawnNode.raw(null);
+ }
+ if (!keepLoaded) {
+ this.gameRules.getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS).set(0, null);
+ } else {
+ this.gameRules.getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS).set(range, null);
+ }
+ return null;
+ }
+
+ public static void apply(final ConfigurationTransformation.Builder builder, final Configurations.ContextMap contextMap, final ConfigurationNode defaultsNode) {
+ builder.addAction(path(), new SpawnLoadedRangeToGameRule(contextMap.require(Configurations.GAME_RULES), defaultsNode));
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/versioned/V29_ZeroWorldHeight.java b/src/main/java/io/papermc/paper/configuration/transformation/world/versioned/V29_ZeroWorldHeight.java diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/versioned/V29_ZeroWorldHeight.java b/src/main/java/io/papermc/paper/configuration/transformation/world/versioned/V29_ZeroWorldHeight.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..6e481d509d091e65a4909d79014ac94ea63c8455 index 0000000000000000000000000000000000000000..6e481d509d091e65a4909d79014ac94ea63c8455
@ -4934,7 +4994,7 @@ index 6d89a5414f46a0c30badb4fcd25bc6cb6d18db3a..0ec3b546db0cf3858dd9cd9ea067d1d6
} }
// CraftBukkit end // CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index d7c5e872136d0452311b316c5703050c45960230..cc5e1076bdf7b4794ee79934fb70234ba61efe15 100644 index d7c5e872136d0452311b316c5703050c45960230..b84078f8105bccc40da0c14932ad3160c96d371c 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -241,7 +241,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -241,7 +241,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -4942,7 +5002,7 @@ index d7c5e872136d0452311b316c5703050c45960230..cc5e1076bdf7b4794ee79934fb70234b
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); - super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess()))); // Paper - create paper world configs + super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules()))); // Paper - create paper world configs
this.pvpMode = minecraftserver.isPvpAllowed(); this.pvpMode = minecraftserver.isPvpAllowed();
this.convertable = convertable_conversionsession; this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());

View File

@ -17,7 +17,7 @@ Subject: [PATCH] CB fixes
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index cc5e1076bdf7b4794ee79934fb70234ba61efe15..b3caf69f9627ba2114dc9d06551ccf182debfb04 100644 index b84078f8105bccc40da0c14932ad3160c96d371c..c4bd9be9d1884be1f5040ff1417f44f8ac4b655f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -302,7 +302,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -302,7 +302,7 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -6847,7 +6847,7 @@ index 8661ed9962d07fb40390faf7f186b9cd8ce6bc62..23c39b78486b018e222af489c8edbf4e
ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos); ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos);
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b3caf69f9627ba2114dc9d06551ccf182debfb04..9332573e6948092ea1cda4efa7f3944729da91be 100644 index c4bd9be9d1884be1f5040ff1417f44f8ac4b655f..319cb644c0a42e9cc0d3ce9d1cbaa93b9c3dcd5b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -235,6 +235,98 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -235,6 +235,98 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -1111,7 +1111,7 @@ index 23c39b78486b018e222af489c8edbf4e749abff6..3f60a3289ec58d5eb3c0c5634ca62ef2
gameprofilerfiller.pop(); gameprofilerfiller.pop();
gameprofilerfiller.pop(); gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 9332573e6948092ea1cda4efa7f3944729da91be..476b513e05a8ef099a17db44732ebc8eed8a595c 100644 index 319cb644c0a42e9cc0d3ce9d1cbaa93b9c3dcd5b..a6e78b8a6ced8ec84273e2c5d18ffccacb005cb6 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@

View File

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Thu, 3 Mar 2016 03:53:43 -0600
Subject: [PATCH] Allow for toggling of spawn chunks
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 476b513e05a8ef099a17db44732ebc8eed8a595c..a72b84cdf2b5f4aea5eb7fe4dfc0faad27c46876 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -403,6 +403,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.dragonFight = null;
}
+ // Paper start - keep spawn loaded
+ if (this.paperConfig().spawn.keepSpawnLoaded && this.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS) == 0) {
+ this.getGameRules().getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS).set(this.paperConfig().spawn.keepSpawnLoadedRange, this);
+ }
+ // Paper end - keep spawn loaded
+
this.sleepStatus = new SleepStatus();
this.gameEventDispatcher = new GameEventDispatcher(this);
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Entity Origin API
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a72b84cdf2b5f4aea5eb7fe4dfc0faad27c46876..c8dadfd6441452817db858ae934b7baed5194403 100644 index a6e78b8a6ced8ec84273e2c5d18ffccacb005cb6..c476a49f69261868f74ad528a2ad746aed3094a3 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2179,6 +2179,15 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2173,6 +2173,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
entity.inWorld = true; // CraftBukkit - Mark entity as in world entity.inWorld = true; // CraftBukkit - Mark entity as in world
entity.valid = true; // CraftBukkit entity.valid = true; // CraftBukkit

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Disable thunder
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c8dadfd6441452817db858ae934b7baed5194403..b41a4d6dc7fb98b6f6fc172a2b83ea43213643b4 100644 index c476a49f69261868f74ad528a2ad746aed3094a3..b66b2cc4111073f080620a52883e1b8d6946e768 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -621,7 +621,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -615,7 +615,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
ProfilerFiller gameprofilerfiller = this.getProfiler(); ProfilerFiller gameprofilerfiller = this.getProfiler();
gameprofilerfiller.push("thunder"); gameprofilerfiller.push("thunder");

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Disable ice and snow
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b41a4d6dc7fb98b6f6fc172a2b83ea43213643b4..6440c0459248a9a0de21c8871e4f4ce399b525ec 100644 index b66b2cc4111073f080620a52883e1b8d6946e768..53e69115a2186c0124d3d8c83f6ca0aecc68c324 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -651,11 +651,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -645,11 +645,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.popPush("iceandsnow"); gameprofilerfiller.popPush("iceandsnow");

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Configurable spawn chances for skeleton horses
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 6440c0459248a9a0de21c8871e4f4ce399b525ec..2b0f4839b128d8a0cdedd0bb8f4a4c6cf02990af 100644 index 53e69115a2186c0124d3d8c83f6ca0aecc68c324..001cbed05de94cadd4862c38c414b5e039bff818 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -626,7 +626,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -620,7 +620,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (this.isRainingAt(blockposition)) { if (this.isRainingAt(blockposition)) {
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition); DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);

View File

@ -18,7 +18,7 @@ index 231fba80a25601cdfba4f6f44ac7c2888e505ed2..4dc8fcd8e118a1c2f5fac0fc291b5555
this.profiler.push(() -> { this.profiler.push(() -> {
String s = String.valueOf(worldserver); String s = String.valueOf(worldserver);
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 2b0f4839b128d8a0cdedd0bb8f4a4c6cf02990af..c37e613361a2cc8bae2442c5b4ec425df821f30e 100644 index 001cbed05de94cadd4862c38c414b5e039bff818..5b44a9e0b6d87e7caba54cb4e972099c1602393b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -226,6 +226,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -226,6 +226,7 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Entity AddTo/RemoveFrom World Events
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c37e613361a2cc8bae2442c5b4ec425df821f30e..b6bc5edad1cf6b54e1b18dddd5acf4002f3c97fd 100644 index 5b44a9e0b6d87e7caba54cb4e972099c1602393b..2e4567e34369e6a9138aa064adf64b9895e21277 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2191,6 +2191,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2185,6 +2185,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
entity.setOrigin(entity.getOriginVector().toLocation(getWorld())); entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
} }
// Paper end - Entity origin API // Paper end - Entity origin API
@ -16,7 +16,7 @@ index c37e613361a2cc8bae2442c5b4ec425df821f30e..b6bc5edad1cf6b54e1b18dddd5acf400
} }
public void onTrackingEnd(Entity entity) { public void onTrackingEnd(Entity entity) {
@@ -2261,6 +2262,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2255,6 +2256,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
} }
} }
// CraftBukkit end // CraftBukkit end

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fix Cancelling BlockPlaceEvent triggering physics
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b6bc5edad1cf6b54e1b18dddd5acf4002f3c97fd..ab91dc3c9a738097b79bdecbcbe41557aa3ed0de 100644 index 2e4567e34369e6a9138aa064adf64b9895e21277..57c13407fd20bcdd17642b0e6078f10082aea87b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1397,6 +1397,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1391,6 +1391,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@Override @Override
public void updateNeighborsAt(BlockPos pos, Block sourceBlock) { public void updateNeighborsAt(BlockPos pos, Block sourceBlock) {

View File

@ -11,10 +11,10 @@ Co-authored-by: lexikiq <noellekiq@gmail.com>
Co-authored-by: Aikar <aikar@aikar.co> Co-authored-by: Aikar <aikar@aikar.co>
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index ab91dc3c9a738097b79bdecbcbe41557aa3ed0de..f2016ed77a2239bdc597175c24ce4427a808d1a6 100644 index 57c13407fd20bcdd17642b0e6078f10082aea87b..0a7dec5ff89c94503908ad011fe7da8dd8256685 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1330,7 +1330,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1324,7 +1324,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@Override @Override
public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) { public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) {

Some files were not shown because too many files have changed in this diff Show More