wip generatebiome

will finish later
This commit is contained in:
Jesse Boyd 2019-11-24 01:50:05 +00:00
parent 4f34d1b5d1
commit ee54dcd809
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 34 additions and 10 deletions

View File

@ -238,7 +238,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
throw new UnsupportedOperationException("Cannot send fake chunks");
}
default boolean regenerate(org.bukkit.World world, Region region, EditSession editSession) {
default boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
return editSession.regenerate(region);
}

View File

@ -48,6 +48,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -92,6 +93,7 @@ import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.io.File;
@ -383,7 +385,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
}
@Override
public boolean regenerate(org.bukkit.World world, Region region, EditSession editSession) {
public boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
WorldServer originalWorld = ((CraftWorld) world).getHandle();
ChunkProviderServer provider = originalWorld.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
@ -398,18 +400,27 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
CraftServer server = originalWorld.getServer();
IDataManager originalDataManager = originalWorld.getDataManager();
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.i());
ChunkGenerator originalGen = world.getGenerator();
ChunkGenerator generator = world.getGenerator();
org.bukkit.World.Environment environment = world.getEnvironment();
if (seed != null) {
if (biome == BiomeTypes.NETHER) {
environment = org.bukkit.World.Environment.NETHER;
} else if (biome == BiomeTypes.THE_END) {
environment = org.bukkit.World.Environment.THE_END;
} else {
environment = org.bukkit.World.Environment.NORMAL;
}
generator = null;
}
try (WorldServer freshWorld = new WorldServer(server.getServer(),
saveHandler,
originalWorld.worldMaps,
originalWorld.worldData,
originalWorld.worldProvider.getDimensionManager(),
originalWorld.methodProfiler,
world.getEnvironment(),
originalGen
)
) {
environment,
generator)) {
SingleThreadQueueExtent extent = new SingleThreadQueueExtent();
extent.init(null, (x, z) -> new BukkitGetBlocks_1_13(freshWorld, x, z) {
@Override

View File

@ -54,6 +54,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -387,7 +388,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
}
@Override
public boolean regenerate(org.bukkit.World world, Region region, EditSession editSession) {
public boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
WorldServer originalWorld = ((CraftWorld) world).getHandle();
ChunkProviderServer provider = originalWorld.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
@ -404,14 +405,26 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.getDataFixer());
ChunkGenerator originalGen = world.getGenerator();
ChunkGenerator generator = world.getGenerator();
org.bukkit.World.Environment environment = world.getEnvironment();
if (seed != null) {
if (biome == BiomeTypes.NETHER) {
environment = org.bukkit.World.Environment.NETHER;
} else if (biome == BiomeTypes.THE_END) {
environment = org.bukkit.World.Environment.THE_END;
} else {
environment = org.bukkit.World.Environment.NORMAL;
}
generator = null;
}
try (WorldServer freshWorld = new WorldServer(server.getServer(),
server.getServer().executorService, saveHandler,
originalWorld.worldData,
originalWorld.worldProvider.getDimensionManager(),
originalWorld.getMethodProfiler(),
server.getServer().worldLoadListenerFactory.create(11),
world.getEnvironment(),
originalGen)) {
environment,
generator)) {
// Pre-gen all the chunks
// We need to also pull one more chunk in every direction