mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
#1039: Use correct ops in GeneratorSettings
By: Martoph <sager1018@gmail.com>
This commit is contained in:
parent
813ab8f174
commit
c9a265249c
1 changed files with 62 additions and 0 deletions
|
@ -0,0 +1,62 @@
|
|||
--- a/net/minecraft/world/level/levelgen/GeneratorSettings.java
|
||||
+++ b/net/minecraft/world/level/levelgen/GeneratorSettings.java
|
||||
@@ -22,6 +22,7 @@
|
||||
import net.minecraft.core.IRegistryWritable;
|
||||
import net.minecraft.core.RegistryCodecs;
|
||||
import net.minecraft.core.RegistryMaterials;
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
public class GeneratorSettings {
|
||||
|
||||
- public static final Codec<GeneratorSettings> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
+ public static final Codec<GeneratorSettings> CODEC = RecordCodecBuilder.<GeneratorSettings>create((instance) -> { // CraftBukkit - decompile error
|
||||
return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(GeneratorSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(GeneratorSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(GeneratorSettings::generateBonusChest), RegistryCodecs.dataPackAwareCodec(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), WorldDimension.CODEC).xmap(WorldDimension::sortMap, Function.identity()).fieldOf("dimensions").forGetter(GeneratorSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((generatorsettings) -> {
|
||||
return generatorsettings.legacyCustomOptions;
|
||||
})).apply(instance, instance.stable(GeneratorSettings::new));
|
||||
@@ -132,7 +133,7 @@
|
||||
public static IRegistry<WorldDimension> withOverworld(IRegistry<WorldDimension> iregistry, Holder<DimensionManager> holder, ChunkGenerator chunkgenerator) {
|
||||
IRegistryWritable<WorldDimension> iregistrywritable = new RegistryMaterials<>(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.experimental(), (Function) null);
|
||||
|
||||
- iregistrywritable.register(WorldDimension.OVERWORLD, (Object) (new WorldDimension(holder, chunkgenerator)), Lifecycle.stable());
|
||||
+ iregistrywritable.register(WorldDimension.OVERWORLD, new WorldDimension(holder, chunkgenerator), Lifecycle.stable()); // CraftBukkit - decompile error
|
||||
Iterator iterator = iregistry.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -140,7 +141,7 @@
|
||||
ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
|
||||
|
||||
if (resourcekey != WorldDimension.OVERWORLD) {
|
||||
- iregistrywritable.register(resourcekey, (Object) ((WorldDimension) entry.getValue()), iregistry.lifecycle((WorldDimension) entry.getValue()));
|
||||
+ iregistrywritable.register(resourcekey, entry.getValue(), iregistry.lifecycle(entry.getValue())); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,13 +231,13 @@
|
||||
|
||||
switch (b0) {
|
||||
case 0:
|
||||
- Dynamic<JsonElement> dynamic = new Dynamic(JsonOps.INSTANCE, dedicatedserverproperties_a.generatorSettings());
|
||||
+ Dynamic<JsonElement> dynamic = new Dynamic(RegistryOps.create(JsonOps.INSTANCE, iregistrycustom), dedicatedserverproperties_a.generatorSettings()); // CraftBukkit - Incorrect Ops
|
||||
boolean flag = dedicatedserverproperties_a.generateStructures();
|
||||
DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(dynamic);
|
||||
Logger logger = GeneratorSettings.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
- return new GeneratorSettings(i, flag, false, withOverworld(iregistry, iregistry3, new ChunkProviderFlat(iregistry2, (GeneratorSettingsFlat) dataresult.resultOrPartial(logger::error).orElseGet(() -> {
|
||||
+ return new GeneratorSettings(i, flag, false, withOverworld(iregistry, iregistry3, new ChunkProviderFlat(iregistry2, (GeneratorSettingsFlat) dataresult.resultOrPartial(s1 -> logger.error(String.valueOf(s1))).orElseGet(() -> { // CraftBukkit - decompile error
|
||||
return GeneratorSettingsFlat.getDefault(iregistry1, iregistry2);
|
||||
}))));
|
||||
case 1:
|
||||
@@ -263,7 +264,7 @@
|
||||
Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next();
|
||||
ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
|
||||
|
||||
- iregistrywritable.register(resourcekey, (Object) (new WorldDimension(((WorldDimension) entry.getValue()).typeHolder(), ((WorldDimension) entry.getValue()).generator().withSeed(j))), this.dimensions.lifecycle((WorldDimension) entry.getValue()));
|
||||
+ iregistrywritable.register(resourcekey, new WorldDimension(entry.getValue().typeHolder(), entry.getValue().generator().withSeed(j)), this.dimensions.lifecycle(entry.getValue())); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
object = iregistrywritable;
|
Loading…
Reference in a new issue