From ee54dcd809e1cf7426ce55984edaffe20106c942 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 24 Nov 2019 01:50:05 +0000 Subject: [PATCH] wip generatebiome will finish later --- .../bukkit/adapter/BukkitImplAdapter.java | 2 +- .../adapter/impl/FAWE_Spigot_v1_13_R2.java | 23 ++++++++++++++----- .../adapter/impl/FAWE_Spigot_v1_14_R4.java | 19 ++++++++++++--- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index c5ef1e510..f1eb275b9 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -238,7 +238,7 @@ public interface BukkitImplAdapter 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); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_13_R2.java index 0296cde34..6c3d31c26 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_13_R2.java @@ -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 diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java index 46ae43e18..acfb35a17 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java @@ -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