Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
fix: Use WE PaperweightAdapter for seed replacement (#1440)
* Use WE PaperweightAdapter for seed replacement also, only replace when necessary * fix comments * ci: Provide basic Jenkinsfile for ghprb pipeline (#1451) Co-authored-by: Alex <mc.cache@web.de>
Dieser Commit ist enthalten in:
Ursprung
781bfc542f
Commit
5367921496
10
Jenkinsfile
vendored
Normale Datei
10
Jenkinsfile
vendored
Normale Datei
@ -0,0 +1,10 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('Build pull request') {
|
||||||
|
steps {
|
||||||
|
sh './gradlew clean build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -658,7 +658,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldGenSettings replaceSeed(ServerLevel originalWorld, long seed, WorldGenSettings originalOpts) {
|
// FAWE start - private -> public static
|
||||||
|
public static WorldGenSettings replaceSeed(ServerLevel originalWorld, long seed, WorldGenSettings originalOpts) {
|
||||||
|
// FAWE end
|
||||||
RegistryWriteOps<net.minecraft.nbt.Tag> nbtReadRegOps = RegistryWriteOps.create(
|
RegistryWriteOps<net.minecraft.nbt.Tag> nbtReadRegOps = RegistryWriteOps.create(
|
||||||
NbtOps.INSTANCE,
|
NbtOps.INSTANCE,
|
||||||
originalWorld.getServer().registryAccess()
|
originalWorld.getServer().registryAccess()
|
||||||
@ -685,8 +687,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FAWE start - private -> private static
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(
|
private static Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(
|
||||||
|
// FAWE end
|
||||||
Dynamic<net.minecraft.nbt.Tag> dynamic,
|
Dynamic<net.minecraft.nbt.Tag> dynamic,
|
||||||
long seed,
|
long seed,
|
||||||
Set<Dynamic<net.minecraft.nbt.Tag>> seen
|
Set<Dynamic<net.minecraft.nbt.Tag>> seen
|
||||||
|
@ -9,9 +9,9 @@ import com.fastasyncworldedit.core.util.TaskManager;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.Dynamic;
|
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
|
import com.sk89q.worldedit.bukkit.adapter.ext.fawe.PaperweightAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.PaperweightGetBlocks;
|
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.PaperweightGetBlocks;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||||
@ -21,12 +21,9 @@ import com.sk89q.worldedit.world.RegenOptions;
|
|||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.MappedRegistry;
|
import net.minecraft.core.MappedRegistry;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.RegistryAccess;
|
|
||||||
import net.minecraft.data.BuiltinRegistries;
|
import net.minecraft.data.BuiltinRegistries;
|
||||||
import net.minecraft.data.worldgen.biome.Biomes;
|
import net.minecraft.data.worldgen.biome.Biomes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtOps;
|
|
||||||
import net.minecraft.resources.RegistryReadOps;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@ -78,12 +75,10 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
@ -220,19 +215,11 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
|
|
||||||
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
|
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
|
||||||
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
|
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
|
||||||
RegistryReadOps<net.minecraft.nbt.Tag> nbtRegOps = RegistryReadOps.createAndLoad(
|
WorldGenSettings originalOpts = levelProperties.worldGenSettings();
|
||||||
NbtOps.INSTANCE, server.resources.getResourceManager(),
|
|
||||||
RegistryAccess.builtin()
|
WorldGenSettings newOpts = options.getSeed().isPresent()
|
||||||
);
|
? PaperweightAdapter.replaceSeed(originalServerWorld, seed, originalOpts)
|
||||||
WorldGenSettings newOpts = WorldGenSettings.CODEC
|
: originalOpts;
|
||||||
.encodeStart(nbtRegOps, levelProperties.worldGenSettings())
|
|
||||||
.flatMap(tag -> WorldGenSettings.CODEC.parse(this.recursivelySetSeed(
|
|
||||||
new Dynamic<>(nbtRegOps, tag),
|
|
||||||
seed,
|
|
||||||
new HashSet<>()
|
|
||||||
)))
|
|
||||||
.result()
|
|
||||||
.orElseThrow(() -> new IllegalStateException("Unable to map GeneratorOptions"));
|
|
||||||
LevelSettings newWorldSettings = new LevelSettings(
|
LevelSettings newWorldSettings = new LevelSettings(
|
||||||
"worldeditregentempworld",
|
"worldeditregentempworld",
|
||||||
originalWorldData.settings.gameType(),
|
originalWorldData.settings.gameType(),
|
||||||
@ -438,23 +425,6 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(
|
|
||||||
Dynamic<net.minecraft.nbt.Tag> dynamic,
|
|
||||||
long seed,
|
|
||||||
Set<Dynamic<net.minecraft.nbt.Tag>> dynamicSet
|
|
||||||
) {
|
|
||||||
return !dynamicSet.add(dynamic) ? dynamic : dynamic.updateMapValues((pair) -> {
|
|
||||||
if (pair.getFirst().asString("").equals("seed")) {
|
|
||||||
return pair.mapSecond((v) -> v.createLong(seed));
|
|
||||||
} else {
|
|
||||||
return ((Dynamic) pair.getSecond()).getValue() instanceof CompoundTag
|
|
||||||
? pair.mapSecond((v) -> this.recursivelySetSeed((Dynamic) v, seed, dynamicSet))
|
|
||||||
: pair;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private BiomeSource fastOverworldBiomeSource(BiomeSource biomeSource) throws Exception {
|
private BiomeSource fastOverworldBiomeSource(BiomeSource biomeSource) throws Exception {
|
||||||
Field legacyBiomeInitLayerField = OverworldBiomeSource.class.getDeclaredField(
|
Field legacyBiomeInitLayerField = OverworldBiomeSource.class.getDeclaredField(
|
||||||
Refraction.pickName("legacyBiomeInitLayer", "i"));
|
Refraction.pickName("legacyBiomeInitLayer", "i"));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren