mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 12:33:54 +00:00
feat: Support for 1.18.2 (#1641)
* feat: Preliminary work for 1.18.2 * Update SpigotNames to 1.18.2 (#1642) * 1.18.2 / Biome-Holders, regeneration (#1645) * 1.18.2 / Biome-Holders, regeneration * fix: reuse old structure sets * build: Update dev bundles * fix: Don't log regen world generation * fix: Run DataConverter with CBT * fix: Override `#toNativeBinary` * fix: Exception on regen Co-Authored-By: Pierre Maurice Schwang <mail@pschwang.eu> * refactor: Minor cleanup Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: Pierre Maurice Schwang <mail@pschwang.eu>
This commit is contained in:
@ -22,6 +22,6 @@ configurations.all {
|
||||
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.17.1-R0.1-20220103.100533-207")
|
||||
paperDevBundle("1.17.1-R0.1-20220220.213420-208")
|
||||
compileOnly(libs.paperlib)
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -87,10 +85,7 @@ import com.sk89q.worldedit.world.item.ItemType;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
|
||||
import net.minecraft.resources.RegistryReadOps;
|
||||
import net.minecraft.resources.RegistryWriteOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -153,12 +148,12 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -636,7 +631,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
|
||||
long seed = options.getSeed().orElse(originalWorld.getSeed());
|
||||
WorldGenSettings newOpts = options.getSeed().isPresent()
|
||||
? replaceSeed(originalWorld, seed, originalOpts)
|
||||
? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed))
|
||||
: originalOpts;
|
||||
|
||||
LevelSettings newWorldSettings = new LevelSettings(
|
||||
@ -681,57 +676,6 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
}
|
||||
}
|
||||
|
||||
// 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(
|
||||
NbtOps.INSTANCE,
|
||||
originalWorld.getServer().registryAccess()
|
||||
);
|
||||
RegistryReadOps<net.minecraft.nbt.Tag> nbtRegOps = RegistryReadOps.createAndLoad(
|
||||
NbtOps.INSTANCE,
|
||||
originalWorld.getServer().getResourceManager(),
|
||||
originalWorld.getServer().registryAccess()
|
||||
);
|
||||
Codec<WorldGenSettings> dimCodec = WorldGenSettings.CODEC;
|
||||
return dimCodec
|
||||
.encodeStart(nbtReadRegOps, originalOpts)
|
||||
.flatMap(tag ->
|
||||
dimCodec.parse(
|
||||
recursivelySetSeed(new Dynamic<>(nbtRegOps, tag), seed, new HashSet<>())
|
||||
)
|
||||
)
|
||||
.get()
|
||||
.map(
|
||||
l -> l,
|
||||
error -> {
|
||||
throw new IllegalStateException("Unable to map GeneratorOptions: " + error.message());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// FAWE start - private -> private static
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(
|
||||
// FAWE end
|
||||
Dynamic<net.minecraft.nbt.Tag> dynamic,
|
||||
long seed,
|
||||
Set<Dynamic<net.minecraft.nbt.Tag>> seen
|
||||
) {
|
||||
if (!seen.add(dynamic)) {
|
||||
return dynamic;
|
||||
}
|
||||
return dynamic.updateMapValues(pair -> {
|
||||
if (pair.getFirst().asString("").equals("seed")) {
|
||||
return pair.mapSecond(v -> v.createLong(seed));
|
||||
}
|
||||
if (pair.getSecond().getValue() instanceof net.minecraft.nbt.CompoundTag) {
|
||||
return pair.mapSecond(v -> recursivelySetSeed((Dynamic<net.minecraft.nbt.Tag>) v, seed, seen));
|
||||
}
|
||||
return pair;
|
||||
});
|
||||
}
|
||||
|
||||
private BiomeType adapt(ServerLevel serverWorld, Biome origBiome) {
|
||||
ResourceLocation key = serverWorld.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(origBiome);
|
||||
if (key == null) {
|
||||
|
@ -215,11 +215,9 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
||||
|
||||
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
|
||||
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
|
||||
WorldGenSettings originalOpts = levelProperties.worldGenSettings();
|
||||
|
||||
WorldGenSettings newOpts = options.getSeed().isPresent()
|
||||
? PaperweightAdapter.replaceSeed(originalServerWorld, seed, originalOpts)
|
||||
: originalOpts;
|
||||
WorldGenSettings newOpts = levelProperties.worldGenSettings()
|
||||
.withSeed(originalWorldData.settings.hardcore(), options.getSeed());
|
||||
LevelSettings newWorldSettings = new LevelSettings(
|
||||
"faweregentempworld",
|
||||
originalWorldData.settings.gameType(),
|
||||
|
Reference in New Issue
Block a user