3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-20 01:40:06 +01:00

implement 1.18 regen

Dieser Commit ist enthalten in:
SirYwell 2021-12-26 16:18:09 +01:00
Ursprung 4ab140f6a1
Commit a717df3c5f
4 geänderte Dateien mit 568 neuen und 735 gelöschten Zeilen

Datei anzeigen

@ -673,7 +673,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(
NbtOps.INSTANCE,
originalWorld.getServer().registryAccess()
@ -700,8 +702,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
);
}
// FAWE start - private -> private static
@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,
long seed,
Set<Dynamic<net.minecraft.nbt.Tag>> seen

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R1.PaperweightAdapter;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1.nbt.PaperweightLazyCompoundTag;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1.regen.PaperweightRegen;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
@ -616,8 +617,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
// return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
return false;
return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
}
@Override

Datei anzeigen

@ -5,7 +5,9 @@ import com.fastasyncworldedit.core.queue.IChunkCache;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
import com.fastasyncworldedit.core.util.MathMan;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
@ -14,6 +16,8 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.RegenOptions;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
@ -32,6 +36,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -283,19 +288,64 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
private void copyToWorld() {
//Setting Blocks
long start = System.currentTimeMillis();
boolean genbiomes = options.shouldRegenBiomes();
boolean hasBiome = options.hasBiomeType();
BiomeType biome = options.getBiomeType();
for (BlockVector3 vec : region) {
BaseBlock block = source.getFullBlock(vec);
target.setBlock(vec, block);
if (hasBiome) {
target.setBiome(vec, biome);
} else if (genbiomes) {
target.setBiome(vec, source.getBiome(vec));
}
if (!genbiomes && !hasBiome) {
target.setBlocks(region, new PlacementPattern());
}
if (hasBiome) {
target.setBlocks(region, new WithBiomePlacementPattern(ignored -> biome));
} else if (genbiomes) {
target.setBlocks(region, new WithBiomePlacementPattern(vec -> source.getBiome(vec)));
}
}
// FIXME this shouldn't be needed
private BlockStateHolder avoidReserved(BaseBlock baseBlock) {
if (baseBlock.getBlockType() == BlockTypes.__RESERVED__) {
return BlockTypes.AIR.getDefaultState();
}
return baseBlock;
}
private class PlacementPattern implements Pattern {
@Override
public BaseBlock applyBlock(final BlockVector3 position) {
return source.getFullBlock(position);
}
@Override
public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException {
return extent.setBlock(set.getX(), set.getY(), set.getZ(),
avoidReserved(source.getFullBlock(get.getX(), get.getY(), get.getZ()))
);
}
}
private class WithBiomePlacementPattern implements Pattern {
private final Function<BlockVector3, BiomeType> biomeGetter;
private WithBiomePlacementPattern(final Function<BlockVector3, BiomeType> biomeGetter) {
this.biomeGetter = biomeGetter;
}
@Override
public BaseBlock applyBlock(final BlockVector3 position) {
return source.getFullBlock(position);
}
@Override
public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException {
return extent.setBlock(set.getX(), set.getY(), set.getZ(),
avoidReserved(source.getFullBlock(get.getX(), get.getY(), get.getZ()))
)
&& extent.setBiome(set.getX(), set.getY(), set.getZ(), biomeGetter.apply(get));
}
}
//functions to be implemented by sub class