Skip to content

Commit 589aa7b

Browse files
committed
Split out world generation by environment.
Requires changes in BentoBox. #61
1 parent 3879378 commit 589aa7b

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

src/main/java/world/bentobox/acidisland/AISettings.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ public class AISettings implements WorldSettings {
146146
@ConfigEntry(path = "world.island-height")
147147
private int islandHeight = 50;
148148

149-
@ConfigComment("Use your own world generator for this world.")
150-
@ConfigComment("In this case, the plugin will not generate anything.")
151-
@ConfigEntry(path = "world.use-own-generator", experimental = true)
149+
@ConfigComment("Use your own world generator for a world.")
150+
@ConfigComment("In this case, the addon will not generate anything. Do not change unless you really know what you are doing.")
151+
@ConfigEntry(path = "world.use-own-generator.world", experimental = true)
152152
private boolean useOwnGenerator;
153+
@ConfigEntry(path = "world.use-own-generator.nether")
154+
private boolean useOwnGeneratorNether;
155+
@ConfigEntry(path = "world.use-own-generator.end")
156+
private boolean useOwnGeneratorEnd;
157+
153158

154159
@ConfigComment("Sea height (don't changes this mid-game unless you delete the world)")
155160
@ConfigComment("Minimum is 0, which means you are playing Skyblock!")
@@ -838,6 +843,18 @@ public boolean isTeamJoinDeathReset() {
838843
public boolean isUseOwnGenerator() {
839844
return useOwnGenerator;
840845
}
846+
public boolean isUseOwnGeneratorNether() {
847+
return useOwnGeneratorNether;
848+
}
849+
public void setUseOwnGeneratorNether(boolean useOwnGeneratorNether) {
850+
this.useOwnGeneratorNether = useOwnGeneratorNether;
851+
}
852+
public boolean isUseOwnGeneratorEnd() {
853+
return useOwnGeneratorEnd;
854+
}
855+
public void setUseOwnGeneratorEnd(boolean useOwnGeneratorEnd) {
856+
this.useOwnGeneratorEnd = useOwnGeneratorEnd;
857+
}
841858
@Override
842859
public boolean isWaterUnsafe() {
843860
// Water is unsafe in acid island

src/main/java/world/bentobox/acidisland/AcidIsland.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void onLoad() {
3939
// Load settings from config.yml. This will check if there are any issues with it too.
4040
loadSettings();
4141
// Chunk generator
42-
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
42+
chunkGenerator = new ChunkGeneratorWorld(this);
4343
// Register commands
4444
adminCommand = new AcidCommand(this, settings.getAdminCommand());
4545
playerCommand = new AiCommand(this, settings.getIslandCommand());
@@ -103,8 +103,9 @@ public void createWorlds() {
103103
getLogger().info("Creating AcidIsland...");
104104
}
105105
// Create the world if it does not exist
106-
chunkGenerator = new ChunkGeneratorWorld(this);
107-
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(chunkGenerator)
106+
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT)
107+
.environment(World.Environment.NORMAL)
108+
.generator(settings.isUseOwnGenerator()? null : chunkGenerator)
108109
.createWorld();
109110
// Make the nether if it does not exist
110111
if (settings.isNetherGenerate()) {
@@ -115,7 +116,7 @@ public void createWorlds() {
115116
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
116117

117118
} else {
118-
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(chunkGenerator)
119+
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(settings.isUseOwnGeneratorNether()? null : chunkGenerator)
119120
.environment(World.Environment.NETHER).createWorld();
120121
}
121122
}
@@ -127,7 +128,7 @@ public void createWorlds() {
127128
if (!settings.isEndIslands()) {
128129
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
129130
} else {
130-
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(chunkGenerator)
131+
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(settings.isUseOwnGeneratorEnd()? null : chunkGenerator)
131132
.environment(World.Environment.THE_END).createWorld();
132133
}
133134
}
@@ -147,7 +148,12 @@ public void onReload() {
147148

148149
@Override
149150
public @NonNull ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
150-
return chunkGenerator;
151+
if ((islandWorld.getName().equalsIgnoreCase(worldName) && !settings.isUseOwnGenerator())
152+
|| (netherWorld !=null && netherWorld.getName().equalsIgnoreCase(worldName) && !settings.isUseOwnGeneratorNether())
153+
|| (endWorld != null && endWorld.getName().equalsIgnoreCase(worldName) && !settings.isUseOwnGeneratorEnd())) {
154+
return chunkGenerator;
155+
}
156+
return null;
151157
}
152158

153159
@Override

src/main/resources/config.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ world:
6161
# Island height - Lowest is 5.
6262
# It is the y coordinate of the bedrock block in the schem.
6363
island-height: 50
64-
# Use your own world generator for this world.
65-
# In this case, the plugin will not generate anything.
64+
# Use your own world generator for a world.
65+
# In this case, the addon will not generate anything. Do not change unless you really know what you are doing.
6666
# /!\ This feature is experimental and might not work as expected or might not work at all.
67-
use-own-generator: false
67+
use-own-generator:
68+
world: true
69+
nether: true
70+
end: true
6871
# Sea height (don't changes this mid-game unless you delete the world)
6972
# Minimum is 0, which means you are playing Skyblock!
7073
sea-height: 54

0 commit comments

Comments
 (0)