Skip to content

Commit

Permalink
Merge pull request #69 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 2.5.0
  • Loading branch information
tastybento authored Apr 2, 2024
2 parents 510ca29 + 3c74d3e commit ef08a3d
Show file tree
Hide file tree
Showing 8 changed files with 1,099 additions and 118 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>2.4.0</build.version>
<build.version>2.5.0</build.version>

<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
85 changes: 33 additions & 52 deletions src/main/java/world/bentobox/boxed/Boxed.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ public class Boxed extends GameModeAddon {
private static final String SEED = "seed";
private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
private static final String BASE = "_base";

// Settings
private Settings settings;
private AbstractBoxedChunkGenerator chunkGenerator;
private AbstractBoxedChunkGenerator worldGen;
private BoxedSeedChunkGenerator seedGen;
private AbstractBoxedChunkGenerator netherGen;
private BoxedSeedChunkGenerator netherSeedGen;


private final Config<Settings> configObject = new Config<>(this, Settings.class);
private AdvancementsManager advManager;
private AbstractBoxedChunkGenerator netherChunkGenerator;
private World seedWorld;
private final Map<World, ChunkGenerator> generatorMap = new HashMap<>();
//private World seedWorldEnd;
private final Map<String, ChunkGenerator> generatorMaps = new HashMap<>();
private BiomeProvider boxedBiomeProvider;

@Override
Expand Down Expand Up @@ -101,8 +104,21 @@ private boolean loadSettings() {
return false;
}
// Initialize the Generator because createWorlds will be run after onLoad
this.chunkGenerator = new BoxedChunkGenerator(this);
this.netherChunkGenerator = new BoxedChunkGenerator(this);
this.worldGen = new BoxedChunkGenerator(this);
generatorMaps.put(settings.getWorldName(), worldGen);

seedGen = new BoxedSeedChunkGenerator(this, Environment.NORMAL,
new SeedBiomeGenerator(this));
generatorMaps.put(settings.getWorldName() + "/" + SEED, seedGen);

// Nether generators
this.netherGen = new BoxedChunkGenerator(this);
generatorMaps.put(settings.getWorldName() + NETHER, netherGen);

netherSeedGen = new BoxedSeedChunkGenerator(this, Environment.NETHER,
new NetherSeedBiomeGenerator(this));
generatorMaps.put(settings.getWorldName() + "/" + SEED + NETHER, netherSeedGen);

return true;
}

Expand Down Expand Up @@ -180,35 +196,18 @@ public void createWorlds() {
private void createNether(String worldName) {
// Create vanilla seed nether world
log("Creating Boxed Seed Nether world ...");
// This creates a vanilla base world with biomes
AbstractBoxedChunkGenerator seedBaseGen = new BoxedSeedChunkGenerator(this, Environment.NETHER);
World baseWorldNether = WorldCreator
.name(worldName + "/" + SEED + NETHER + BASE)
.generator(seedBaseGen)
.environment(Environment.NETHER)
.seed(getSettings().getSeed())
.createWorld();
baseWorldNether.setDifficulty(Difficulty.PEACEFUL);
baseWorldNether.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());
generatorMap.put(baseWorldNether, seedBaseGen);
getPlugin().getIWM().addWorld(baseWorldNether, this);
copyChunks(baseWorldNether, seedBaseGen);
// Create seed world
// This copies a base world with custom biomes
log("Creating Boxed Biomed Nether world ...");
BoxedSeedChunkGenerator seedWorldNetherGenerator = new BoxedSeedChunkGenerator(this, Environment.NETHER, new NetherSeedBiomeGenerator(this, seedBaseGen));
World seedWorldNether = WorldCreator
.name(worldName + "/" + SEED + NETHER)
.generator(seedWorldNetherGenerator)
.generator(netherSeedGen)
.environment(Environment.NETHER)
.seed(getSettings().getSeed())
.createWorld();
seedWorldNether.setDifficulty(Difficulty.EASY);

seedWorldNether.setSpawnLocation(settings.getNetherSeedX(), 64, settings.getNetherSeedZ());
generatorMap.put(seedWorldNether, seedWorldNetherGenerator);
generatorMap.put(seedWorldNether, netherSeedGen);
getPlugin().getIWM().addWorld(seedWorldNether, this);
copyChunks(seedWorldNether, netherChunkGenerator);
copyChunks(seedWorldNether, netherGen);

if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating Boxed's Nether...");
Expand All @@ -219,38 +218,19 @@ private void createNether(String worldName) {
private void createOverWorld(String worldName) {
// Create vanilla seed world
log("Creating Boxed Seed world ...");
// This creates a vanilla base world with biomes
AbstractBoxedChunkGenerator seedBaseGen = new BoxedSeedChunkGenerator(this, Environment.NORMAL);
World baseWorld = WorldCreator
.name(worldName + "/" + SEED + BASE)
.generator(seedBaseGen)
.environment(Environment.NORMAL)
.seed(getSettings().getSeed())
.createWorld();
baseWorld.setDifficulty(Difficulty.PEACEFUL);
baseWorld.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());
generatorMap.put(baseWorld, seedBaseGen);
getPlugin().getIWM().addWorld(baseWorld, this);
copyChunks(baseWorld, seedBaseGen);
// Create seed world
// This copies a base world with custom biomes
log("Creating Boxed Biomed world ...");
BoxedSeedChunkGenerator seedWorldGenerator = new BoxedSeedChunkGenerator(this, Environment.NORMAL, new SeedBiomeGenerator(this, seedBaseGen));
seedWorld = WorldCreator
.name(worldName + "/" + SEED)
.generator(seedWorldGenerator)
.generator(seedGen)
.environment(Environment.NORMAL)
.seed(getSettings().getSeed())
.createWorld();
seedWorld.setDifficulty(Difficulty.EASY);

seedWorld.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());

generatorMap.put(seedWorld, seedWorldGenerator);
generatorMap.put(seedWorld, seedGen);
getPlugin().getIWM().addWorld(seedWorld, this);
copyChunks(seedWorld, chunkGenerator);


copyChunks(seedWorld, worldGen);

if (getServer().getWorld(worldName) == null) {
log("Creating Boxed world ...");
Expand Down Expand Up @@ -308,7 +288,8 @@ private void copyChunks(World world, AbstractBoxedChunkGenerator gen) {
int p = (int) (count / percent * 100);
if (p % 10 == 0 && p != last) {
last = p;
this.log("Pregenrating seed chunks for " + world.getName() + "'s " + world.getEnvironment() + " " + p + "% done");
this.log("Pregenerating seed chunks for " + world.getName() + "'s " + world.getEnvironment() + " "
+ p + "% done");
}

}
Expand All @@ -321,7 +302,7 @@ private void copyChunks(World world, AbstractBoxedChunkGenerator gen) {
* @return the chunkGenerator for the environment
*/
public AbstractBoxedChunkGenerator getChunkGenerator(Environment env) {
return env.equals(Environment.NORMAL) ? chunkGenerator : netherChunkGenerator;
return env.equals(Environment.NORMAL) ? worldGen : netherGen;
}

/**
Expand Down Expand Up @@ -386,8 +367,8 @@ public WorldSettings getWorldSettings() {

@Override
public @Nullable ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
for (Entry<World, ChunkGenerator> en : generatorMap.entrySet()) {
if (en.getKey().getName().equalsIgnoreCase(worldName)) {
for (Entry<String, ChunkGenerator> en : generatorMaps.entrySet()) {
if (en.getKey().equalsIgnoreCase(worldName)) {
return en.getValue();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/boxed/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.max-areas")
private int maxIslands = -1;

@ConfigComment("Area height - Lowest is 5.")
@ConfigComment("Area height")
@ConfigComment("It is the y coordinate of the bedrock block in the blueprint.")
@ConfigEntry(path = "world.area-height")
private int islandHeight = 8;
Expand Down
Loading

0 comments on commit ef08a3d

Please sign in to comment.