mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-18 01:46:11 +00:00
Merge pull request #707 from IronApollo/biome-regen
Implement biome-specific regen
This commit is contained in:
commit
28f5a7072d
@ -11,6 +11,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.RegenOptions;
|
import com.sk89q.worldedit.world.RegenOptions;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
@ -266,9 +267,13 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
|
|||||||
//Setting Blocks
|
//Setting Blocks
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
boolean genbiomes = options.shouldRegenBiomes();
|
boolean genbiomes = options.shouldRegenBiomes();
|
||||||
|
boolean hasBiome = options.hasBiomeType();
|
||||||
|
BiomeType biome = options.getBiomeType();
|
||||||
for (BlockVector3 vec : region) {
|
for (BlockVector3 vec : region) {
|
||||||
target.setBlock(vec, source.getBlock(vec));
|
target.setBlock(vec, source.getBlock(vec));
|
||||||
if (genbiomes) {
|
if (hasBiome) {
|
||||||
|
target.setBiome(vec, biome);
|
||||||
|
} else if (genbiomes) {
|
||||||
target.setBiome(vec, source.getBiome(vec));
|
target.setBiome(vec, source.getBiome(vec));
|
||||||
}
|
}
|
||||||
// realExtent.setSkyLight(vec, extent.getSkyLight(vec));
|
// realExtent.setSkyLight(vec, extent.getSkyLight(vec));
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.beta.IChunkCache;
|
import com.boydti.fawe.beta.IChunkCache;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_15_2.BukkitGetBlocks_1_15_2;
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.BukkitGetBlocks_1_15_2;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -53,6 +54,7 @@ import net.minecraft.server.v1_15_R1.IChunkAccess;
|
|||||||
import net.minecraft.server.v1_15_R1.IRegistry;
|
import net.minecraft.server.v1_15_R1.IRegistry;
|
||||||
import net.minecraft.server.v1_15_R1.LightEngineThreaded;
|
import net.minecraft.server.v1_15_R1.LightEngineThreaded;
|
||||||
import net.minecraft.server.v1_15_R1.LinearCongruentialGenerator;
|
import net.minecraft.server.v1_15_R1.LinearCongruentialGenerator;
|
||||||
|
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NoiseGeneratorPerlin;
|
import net.minecraft.server.v1_15_R1.NoiseGeneratorPerlin;
|
||||||
@ -182,6 +184,16 @@ public class Regen_v1_15_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final BiomeBase singleBiome = options.hasBiomeType() ? IRegistry.BIOME.get(MinecraftKey.a(options.getBiomeType().getId())) : null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase a(int i, int k, int j) {
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
return singleBiome;
|
||||||
|
}
|
||||||
|
return this.getChunkProvider().getChunkGenerator().getWorldChunkManager().getBiome(i, j, k);
|
||||||
|
}
|
||||||
}).get();
|
}).get();
|
||||||
freshNMSWorld.savingDisabled = true;
|
freshNMSWorld.savingDisabled = true;
|
||||||
removeWorldFromWorldsMap();
|
removeWorldFromWorldsMap();
|
||||||
@ -358,15 +370,34 @@ public class Regen_v1_15_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
//init new WorldChunkManagerOverworld
|
//init new WorldChunkManagerOverworld
|
||||||
BiomeLayoutOverworldConfiguration biomeconfig = new BiomeLayoutOverworldConfiguration(freshNMSWorld.getWorldData())
|
BiomeLayoutOverworldConfiguration biomeconfig = new BiomeLayoutOverworldConfiguration(freshNMSWorld.getWorldData())
|
||||||
.a((GeneratorSettingsOverworld) originalChunkProvider.getChunkGenerator().getSettings());
|
.a((GeneratorSettingsOverworld) originalChunkProvider.getChunkGenerator().getSettings());
|
||||||
chunkManager = new WorldChunkManagerOverworld(biomeconfig);
|
|
||||||
|
|
||||||
//replace genLayer
|
|
||||||
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, biomeconfig.b(), biomeconfig.c(), (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, biomeconfig.b(), biomeconfig.c(), (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
BiomeBase biome = IRegistry.BIOME.get(MinecraftKey.a(options.getBiomeType().getId()));
|
||||||
|
chunkManager = new SingleBiomeWorldChunkManagerOverworld(biome);
|
||||||
|
} else {
|
||||||
|
chunkManager = new WorldChunkManagerOverworld(biomeconfig);
|
||||||
|
//replace genlayer
|
||||||
genLayerField.set(chunkManager, new FastGenLayer(factory));
|
genLayerField.set(chunkManager, new FastGenLayer(factory));
|
||||||
|
}
|
||||||
|
|
||||||
return chunkManager;
|
return chunkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SingleBiomeWorldChunkManagerOverworld extends WorldChunkManager {
|
||||||
|
|
||||||
|
private final BiomeBase biome;
|
||||||
|
|
||||||
|
public SingleBiomeWorldChunkManagerOverworld(BiomeBase biome) {
|
||||||
|
super(ImmutableSet.of(biome));
|
||||||
|
this.biome = biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase getBiome(int i, int i1, int i2) {
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.beta.IChunkGet;
|
|||||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitGetBlocks_1_16_1;
|
import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitGetBlocks_1_16_1;
|
||||||
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.Dynamic;
|
import com.mojang.serialization.Dynamic;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
||||||
@ -17,6 +18,7 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Field;
|
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.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -53,15 +55,14 @@ import net.minecraft.server.v1_16_R1.GeneratorSettings;
|
|||||||
import net.minecraft.server.v1_16_R1.GeneratorSettingsFlat;
|
import net.minecraft.server.v1_16_R1.GeneratorSettingsFlat;
|
||||||
import net.minecraft.server.v1_16_R1.IChunkAccess;
|
import net.minecraft.server.v1_16_R1.IChunkAccess;
|
||||||
import net.minecraft.server.v1_16_R1.IRegistry;
|
import net.minecraft.server.v1_16_R1.IRegistry;
|
||||||
import net.minecraft.server.v1_16_R1.IRegistryCustom;
|
|
||||||
import net.minecraft.server.v1_16_R1.LightEngineThreaded;
|
import net.minecraft.server.v1_16_R1.LightEngineThreaded;
|
||||||
import net.minecraft.server.v1_16_R1.LinearCongruentialGenerator;
|
import net.minecraft.server.v1_16_R1.LinearCongruentialGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R1.MinecraftKey;
|
||||||
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_16_R1.NBTBase;
|
import net.minecraft.server.v1_16_R1.NBTBase;
|
||||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_16_R1.NoiseGeneratorPerlin;
|
import net.minecraft.server.v1_16_R1.NoiseGeneratorPerlin;
|
||||||
import net.minecraft.server.v1_16_R1.ProtoChunk;
|
import net.minecraft.server.v1_16_R1.ProtoChunk;
|
||||||
import net.minecraft.server.v1_16_R1.RegistryReadOps;
|
|
||||||
import net.minecraft.server.v1_16_R1.ResourceKey;
|
import net.minecraft.server.v1_16_R1.ResourceKey;
|
||||||
import net.minecraft.server.v1_16_R1.World;
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
import net.minecraft.server.v1_16_R1.WorldChunkManager;
|
import net.minecraft.server.v1_16_R1.WorldChunkManager;
|
||||||
@ -201,6 +202,16 @@ public class Regen_v1_16_R1 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final BiomeBase singleBiome = options.hasBiomeType() ? IRegistry.BIOME.get(MinecraftKey.a(options.getBiomeType().getId())) : null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase a(int i, int j, int k) {
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
return singleBiome;
|
||||||
|
}
|
||||||
|
return this.getChunkProvider().getChunkGenerator().getWorldChunkManager().getBiome(i, j, k);
|
||||||
|
}
|
||||||
}).get();
|
}).get();
|
||||||
freshNMSWorld.savingDisabled = true;
|
freshNMSWorld.savingDisabled = true;
|
||||||
removeWorldFromWorldsMap();
|
removeWorldFromWorldsMap();
|
||||||
@ -398,16 +409,41 @@ public class Regen_v1_16_R1 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
|
|
||||||
//init new WorldChunkManagerOverworld
|
//init new WorldChunkManagerOverworld
|
||||||
boolean legacyBiomeInitLayer = legacyBiomeInitLayerField.getBoolean(chunkManager);
|
boolean legacyBiomeInitLayer = legacyBiomeInitLayerField.getBoolean(chunkManager);
|
||||||
boolean largebiomes = largeBiomesField.getBoolean(chunkManager);
|
boolean largeBiomes = largeBiomesField.getBoolean(chunkManager);
|
||||||
chunkManager = new WorldChunkManagerOverworld(seed, legacyBiomeInitLayer, largebiomes);
|
|
||||||
|
|
||||||
|
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, legacyBiomeInitLayer, largeBiomes ? 6 : 4, 4, (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
BiomeBase biome = IRegistry.BIOME.get(MinecraftKey.a(options.getBiomeType().getId()));
|
||||||
|
chunkManager = new SingleBiomeWorldChunkManagerOverworld(biome);
|
||||||
|
} else {
|
||||||
|
chunkManager = new WorldChunkManagerOverworld(seed, legacyBiomeInitLayer, largeBiomes);
|
||||||
//replace genLayer
|
//replace genLayer
|
||||||
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, legacyBiomeInitLayer, largebiomes ? 6 : 4, 4, (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
|
||||||
genLayerField.set(chunkManager, new FastGenLayer(factory));
|
genLayerField.set(chunkManager, new FastGenLayer(factory));
|
||||||
|
}
|
||||||
|
|
||||||
return chunkManager;
|
return chunkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SingleBiomeWorldChunkManagerOverworld extends WorldChunkManager {
|
||||||
|
|
||||||
|
private final BiomeBase biome;
|
||||||
|
|
||||||
|
public SingleBiomeWorldChunkManagerOverworld(BiomeBase biome) {
|
||||||
|
super(Arrays.asList(biome));
|
||||||
|
this.biome = biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends WorldChunkManager> a() {
|
||||||
|
return WorldChunkManagerOverworld.e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase getBiome(int i, int i1, int i2) {
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.beta.IChunkGet;
|
|||||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitGetBlocks_1_16_2;
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitGetBlocks_1_16_2;
|
||||||
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.Dynamic;
|
import com.mojang.serialization.Dynamic;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
import com.sk89q.worldedit.bukkit.adapter.Regenerator;
|
||||||
@ -28,6 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import java.util.function.LongFunction;
|
import java.util.function.LongFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.server.v1_16_R2.Area;
|
import net.minecraft.server.v1_16_R2.Area;
|
||||||
import net.minecraft.server.v1_16_R2.AreaContextTransformed;
|
import net.minecraft.server.v1_16_R2.AreaContextTransformed;
|
||||||
@ -56,11 +58,14 @@ import net.minecraft.server.v1_16_R2.IRegistry;
|
|||||||
import net.minecraft.server.v1_16_R2.IRegistryCustom;
|
import net.minecraft.server.v1_16_R2.IRegistryCustom;
|
||||||
import net.minecraft.server.v1_16_R2.LightEngineThreaded;
|
import net.minecraft.server.v1_16_R2.LightEngineThreaded;
|
||||||
import net.minecraft.server.v1_16_R2.LinearCongruentialGenerator;
|
import net.minecraft.server.v1_16_R2.LinearCongruentialGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
||||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||||
import net.minecraft.server.v1_16_R2.NBTBase;
|
import net.minecraft.server.v1_16_R2.NBTBase;
|
||||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_16_R2.NoiseGeneratorPerlin;
|
import net.minecraft.server.v1_16_R2.NoiseGeneratorPerlin;
|
||||||
import net.minecraft.server.v1_16_R2.ProtoChunk;
|
import net.minecraft.server.v1_16_R2.ProtoChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.RegistryGeneration;
|
||||||
|
import net.minecraft.server.v1_16_R2.RegistryMaterials;
|
||||||
import net.minecraft.server.v1_16_R2.RegistryReadOps;
|
import net.minecraft.server.v1_16_R2.RegistryReadOps;
|
||||||
import net.minecraft.server.v1_16_R2.ResourceKey;
|
import net.minecraft.server.v1_16_R2.ResourceKey;
|
||||||
import net.minecraft.server.v1_16_R2.World;
|
import net.minecraft.server.v1_16_R2.World;
|
||||||
@ -202,6 +207,16 @@ public class Regen_v1_16_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
public void doTick(BooleanSupplier booleansupplier) { //no ticking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final BiomeBase singleBiome = options.hasBiomeType() ? RegistryGeneration.WORLDGEN_BIOME.get(MinecraftKey.a(options.getBiomeType().getId())) : null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase a(int i, int j, int k) {
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
return singleBiome;
|
||||||
|
}
|
||||||
|
return this.getChunkProvider().getChunkGenerator().getWorldChunkManager().getBiome(i, j, k);
|
||||||
|
}
|
||||||
}).get();
|
}).get();
|
||||||
freshNMSWorld.savingDisabled = true;
|
freshNMSWorld.savingDisabled = true;
|
||||||
removeWorldFromWorldsMap();
|
removeWorldFromWorldsMap();
|
||||||
@ -395,8 +410,6 @@ public class Regen_v1_16_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
largeBiomesField.setAccessible(true);
|
largeBiomesField.setAccessible(true);
|
||||||
Field biomeRegistryField = WorldChunkManagerOverworld.class.getDeclaredField("k");
|
Field biomeRegistryField = WorldChunkManagerOverworld.class.getDeclaredField("k");
|
||||||
biomeRegistryField.setAccessible(true);
|
biomeRegistryField.setAccessible(true);
|
||||||
Field genLayerField = WorldChunkManagerOverworld.class.getDeclaredField("f");
|
|
||||||
genLayerField.setAccessible(true);
|
|
||||||
Field areaLazyField = GenLayer.class.getDeclaredField("b");
|
Field areaLazyField = GenLayer.class.getDeclaredField("b");
|
||||||
areaLazyField.setAccessible(true);
|
areaLazyField.setAccessible(true);
|
||||||
Method initAreaFactoryMethod = GenLayers.class.getDeclaredMethod("a", boolean.class, int.class, int.class, LongFunction.class);
|
Method initAreaFactoryMethod = GenLayers.class.getDeclaredMethod("a", boolean.class, int.class, int.class, LongFunction.class);
|
||||||
@ -405,16 +418,52 @@ public class Regen_v1_16_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
//init new WorldChunkManagerOverworld
|
//init new WorldChunkManagerOverworld
|
||||||
boolean legacyBiomeInitLayer = legacyBiomeInitLayerField.getBoolean(chunkManager);
|
boolean legacyBiomeInitLayer = legacyBiomeInitLayerField.getBoolean(chunkManager);
|
||||||
boolean largebiomes = largeBiomesField.getBoolean(chunkManager);
|
boolean largebiomes = largeBiomesField.getBoolean(chunkManager);
|
||||||
IRegistry<BiomeBase> biomeRegistry = (IRegistry<BiomeBase>) biomeRegistryField.get(chunkManager);
|
IRegistry<BiomeBase> biomeRegistrynms = (IRegistry<BiomeBase>) biomeRegistryField.get(chunkManager);
|
||||||
chunkManager = new WorldChunkManagerOverworld(seed, legacyBiomeInitLayer, largebiomes, biomeRegistry);
|
IRegistry<BiomeBase> biomeRegistry;
|
||||||
|
if (options.hasBiomeType()) {
|
||||||
|
BiomeBase biome = RegistryGeneration.WORLDGEN_BIOME.get(MinecraftKey.a(options.getBiomeType().getId()));
|
||||||
|
biomeRegistry = new RegistryMaterials<>(ResourceKey.a(new MinecraftKey("fawe_biomes")), Lifecycle.experimental());
|
||||||
|
((RegistryMaterials) biomeRegistry).a(0, RegistryGeneration.WORLDGEN_BIOME.c(biome).get(), biome, Lifecycle.experimental());
|
||||||
|
} else {
|
||||||
|
biomeRegistry = biomeRegistrynms;
|
||||||
|
}
|
||||||
|
chunkManager = new FastWorldChunkManagerOverworld(seed, legacyBiomeInitLayer, largebiomes, biomeRegistry);
|
||||||
|
|
||||||
//replace genLayer
|
//replace genLayer
|
||||||
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, legacyBiomeInitLayer, largebiomes ? 6 : 4, 4, (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
AreaFactory<FastAreaLazy> factory = (AreaFactory<FastAreaLazy>) initAreaFactoryMethod.invoke(null, legacyBiomeInitLayer, largebiomes ? 6 : 4, 4, (LongFunction) (l -> new FastWorldGenContextArea(seed, l)));
|
||||||
genLayerField.set(chunkManager, new FastGenLayer(factory));
|
((FastWorldChunkManagerOverworld) chunkManager).genLayer = new FastGenLayer(factory);
|
||||||
|
|
||||||
return chunkManager;
|
return chunkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class FastWorldChunkManagerOverworld extends WorldChunkManager {
|
||||||
|
|
||||||
|
private GenLayer genLayer;
|
||||||
|
private final IRegistry<BiomeBase> k;
|
||||||
|
private final boolean isSingleRegistry;
|
||||||
|
|
||||||
|
public FastWorldChunkManagerOverworld(long seed, boolean legacyBiomeInitLayer, boolean largeBiomes, IRegistry<BiomeBase> biomeRegistry) {
|
||||||
|
super(biomeRegistry.g().collect(Collectors.toList()));
|
||||||
|
this.k = biomeRegistry;
|
||||||
|
this.isSingleRegistry = biomeRegistry.d().size() == 1;
|
||||||
|
this.genLayer = GenLayers.a(seed, legacyBiomeInitLayer, largeBiomes ? 6 : 4, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends WorldChunkManager> a() {
|
||||||
|
return WorldChunkManagerOverworld.e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase getBiome(int i, int i1, int i2) {
|
||||||
|
if (this.isSingleRegistry) {
|
||||||
|
return this.k.fromId(0);
|
||||||
|
}
|
||||||
|
return this.genLayer.a(this.k, i, i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
private static class FastWorldGenContextArea implements AreaContextTransformed<FastAreaLazy> {
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, Integer> sharedAreaMap = new ConcurrentHashMap<>();
|
||||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.util.SideEffect;
|
|||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.world.AbstractWorld;
|
import com.sk89q.worldedit.world.AbstractWorld;
|
||||||
|
import com.sk89q.worldedit.world.RegenOptions;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -242,6 +243,11 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
return parent.regenerate(region, session);
|
return parent.regenerate(region, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean regenerate(Region region, Extent extent, RegenOptions options) {
|
||||||
|
return parent.regenerate(region, extent, options);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||||
return TaskManager.IMP.sync(() -> {
|
return TaskManager.IMP.sync(() -> {
|
||||||
|
@ -63,7 +63,9 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
|
import com.sk89q.worldedit.world.RegenOptions;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
@ -609,15 +611,26 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.regen")
|
@CommandPermissions("worldedit.regen")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void regenerateChunk(Actor actor, World world, LocalSession session, EditSession editSession,
|
void regenerate(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region) throws WorldEditException {
|
@Selection Region region,
|
||||||
|
@Arg(desc = "The seed to regenerate with, otherwise uses world seed", def = "")
|
||||||
|
Long seed,
|
||||||
|
@Switch(name = 'b', desc = "Regenerate biomes as well")
|
||||||
|
boolean regenBiomes,
|
||||||
|
@Arg(desc = "Biome to apply for this regeneration (only works in overworld)", def = "")
|
||||||
|
BiomeType biomeType) throws WorldEditException {
|
||||||
Mask mask = session.getMask();
|
Mask mask = session.getMask();
|
||||||
boolean success;
|
boolean success;
|
||||||
try {
|
try {
|
||||||
session.setMask((Mask) null);
|
session.setMask(null);
|
||||||
session.setSourceMask((Mask) null);
|
session.setSourceMask(null);
|
||||||
actor.printInfo(TranslatableComponent.of("fawe.regen.time"));
|
actor.printInfo(TranslatableComponent.of("fawe.regen.time"));
|
||||||
success = world.regenerate(region, editSession);
|
RegenOptions options = RegenOptions.builder()
|
||||||
|
.seed(seed)
|
||||||
|
.regenBiomes(regenBiomes)
|
||||||
|
.biomeType(biomeType)
|
||||||
|
.build();
|
||||||
|
success = world.regenerate(region, editSession, options);
|
||||||
} finally {
|
} finally {
|
||||||
session.setMask(mask);
|
session.setMask(mask);
|
||||||
session.setSourceMask(mask);
|
session.setSourceMask(mask);
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.world;
|
|||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -38,7 +39,7 @@ public abstract class RegenOptions {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
*/
|
*/
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new AutoValue_RegenOptions.Builder().seed(OptionalLong.empty()).regenBiomes(false);
|
return new AutoValue_RegenOptions.Builder().seed(OptionalLong.empty()).regenBiomes(false).biomeType(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AutoValue.Builder
|
@AutoValue.Builder
|
||||||
@ -69,6 +70,13 @@ public abstract class RegenOptions {
|
|||||||
*/
|
*/
|
||||||
public abstract Builder regenBiomes(boolean regenBiomes);
|
public abstract Builder regenBiomes(boolean regenBiomes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the {@code BiomeType} the regenerator should use for regeneration. Defaults to {@code null}.
|
||||||
|
* @param biomeType the {@code BiomeType} to be used for regeneration
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public abstract Builder biomeType(@Nullable BiomeType biomeType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the options object.
|
* Build the options object.
|
||||||
*
|
*
|
||||||
@ -99,4 +107,10 @@ public abstract class RegenOptions {
|
|||||||
return isRegenBiomes();
|
return isRegenBiomes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable public abstract BiomeType getBiomeType();
|
||||||
|
|
||||||
|
public boolean hasBiomeType() {
|
||||||
|
return getBiomeType() != null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user