Skip to content

Commit 0cbb775

Browse files
authored
Release 1.16.0 (#81)
* Fixes a 1.18 world generator bug where it generated dirt-grass layers. Expose 3 world generator options for overworld: - natural-surface - generates surface that is natural(-ish). Currently, it may be just grass and dirt layers. - natural-caves - generates caves inside world. - natural-bedrock - generates natural looking bedrock pattern. This also fixes a bug with floor and roof config option not working properly. Fixes BentoBoxWorld/Level#258 * Fixes issue when ores were not generated in correct form. #77
1 parent e6e3c97 commit 0cbb775

File tree

6 files changed

+327
-123
lines changed

6 files changed

+327
-123
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<!-- Revision variable removes warning about dynamic version -->
5151
<revision>${build.version}-SNAPSHOT</revision>
5252
<!-- This allows to change between versions and snapshots. -->
53-
<build.version>1.15.0</build.version>
53+
<build.version>1.16.0</build.version>
5454
<build.number>-LOCAL</build.number>
5555
<sonar.organization>bentobox-world</sonar.organization>
5656
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

src/main/java/world/bentobox/caveblock/CaveBlock.java

+30-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public void onLoad()
3434
this.saveDefaultConfig();
3535
this.loadSettings();
3636

37-
this.chunkGenerator = new ChunkGeneratorWorld(this);
37+
this.chunkNormalGenerator = new ChunkGeneratorWorld(this, World.Environment.NORMAL);
38+
this.chunkNetherGenerator = new ChunkGeneratorWorld(this, World.Environment.NETHER);
39+
this.chunkEndGenerator = new ChunkGeneratorWorld(this, World.Environment.THE_END);
3840

3941
// Player Command
4042
this.playerCommand = new DefaultPlayerCommand(this)
@@ -137,7 +139,7 @@ public void createWorlds()
137139
// Create the world if it does not exist
138140
this.islandWorld = WorldCreator.name(worldName).
139141
environment(World.Environment.NORMAL).
140-
generator(this.chunkGenerator).
142+
generator(this.chunkNormalGenerator).
141143
createWorld();
142144
// Set spawn rates
143145
setSpawnRates(islandWorld);
@@ -162,7 +164,7 @@ public void createWorlds()
162164
{
163165
this.netherWorld = WorldCreator.name(worldName + NETHER).
164166
type(WorldType.FLAT).
165-
generator(this.chunkGenerator).
167+
generator(this.chunkNetherGenerator).
166168
environment(World.Environment.NETHER).
167169
createWorld();
168170
}
@@ -187,7 +189,7 @@ public void createWorlds()
187189
{
188190
this.endWorld = WorldCreator.name(worldName + THE_END).
189191
type(WorldType.FLAT).
190-
generator(this.chunkGenerator).
192+
generator(this.chunkEndGenerator).
191193
environment(World.Environment.THE_END).
192194
createWorld();
193195
}
@@ -232,7 +234,18 @@ private void setSpawnRates(World w) {
232234
@Override
233235
public @NonNull ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
234236
{
235-
return this.chunkGenerator;
237+
if (worldName.endsWith("_nether"))
238+
{
239+
return this.chunkNetherGenerator;
240+
}
241+
else if (worldName.endsWith("_the_end"))
242+
{
243+
return this.chunkEndGenerator;
244+
}
245+
else
246+
{
247+
return this.chunkNormalGenerator;
248+
}
236249
}
237250

238251
// ---------------------------------------------------------------------
@@ -284,9 +297,19 @@ public void saveWorldSettings()
284297
private Settings settings;
285298

286299
/**
287-
* This stores CaveBlock addon WorldGenerator.
300+
* This stores CaveBlock addon WorldGenerator for overworld.
301+
*/
302+
private ChunkGeneratorWorld chunkNormalGenerator;
303+
304+
/**
305+
* This stores CaveBlock addon WorldGenerator for the nether.
306+
*/
307+
private ChunkGeneratorWorld chunkNetherGenerator;
308+
309+
/**
310+
* This stores CaveBlock addon WorldGenerator for the end.
288311
*/
289-
private ChunkGeneratorWorld chunkGenerator;
312+
private ChunkGeneratorWorld chunkEndGenerator;
290313

291314

292315
// ---------------------------------------------------------------------

src/main/java/world/bentobox/caveblock/Settings.java

+90-4
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,72 @@ public void setOnRespawnCommands(List<String> onRespawnCommands)
20772077
}
20782078

20792079

2080+
/**
2081+
* Is generate caves boolean.
2082+
*
2083+
* @return the boolean
2084+
*/
2085+
public boolean isGenerateCaves()
2086+
{
2087+
return generateCaves;
2088+
}
2089+
2090+
2091+
/**
2092+
* Sets generate caves.
2093+
*
2094+
* @param generateCaves the generate caves
2095+
*/
2096+
public void setGenerateCaves(boolean generateCaves)
2097+
{
2098+
this.generateCaves = generateCaves;
2099+
}
2100+
2101+
2102+
/**
2103+
* Is generate natural bedrock boolean.
2104+
*
2105+
* @return the boolean
2106+
*/
2107+
public boolean isGenerateNaturalBedrock()
2108+
{
2109+
return generateNaturalBedrock;
2110+
}
2111+
2112+
2113+
/**
2114+
* Sets generate natural bedrock.
2115+
*
2116+
* @param generateNaturalBedrock the generate natural bedrock
2117+
*/
2118+
public void setGenerateNaturalBedrock(boolean generateNaturalBedrock)
2119+
{
2120+
this.generateNaturalBedrock = generateNaturalBedrock;
2121+
}
2122+
2123+
2124+
/**
2125+
* Is generate natural surface boolean.
2126+
*
2127+
* @return the boolean
2128+
*/
2129+
public boolean isGenerateNaturalSurface()
2130+
{
2131+
return generateNaturalSurface;
2132+
}
2133+
2134+
2135+
/**
2136+
* Sets generate natural surface.
2137+
*
2138+
* @param generateNaturalSurface the generate natural surface
2139+
*/
2140+
public void setGenerateNaturalSurface(boolean generateNaturalSurface)
2141+
{
2142+
this.generateNaturalSurface = generateNaturalSurface;
2143+
}
2144+
2145+
20802146
// ---------------------------------------------------------------------
20812147
// Section: Variables
20822148
// ---------------------------------------------------------------------
@@ -2196,8 +2262,8 @@ public void setOnRespawnCommands(List<String> onRespawnCommands)
21962262
private int banLimit = -1;
21972263

21982264
@ConfigComment("")
2199-
@ConfigComment("This is cave.. no height... only depth. Max 256.")
2200-
@ConfigComment("Should not be less then cave height.")
2265+
@ConfigComment("This is cave.. no height... only depth. If depth is set smaller than maximal world height, then area above will be empty.")
2266+
@ConfigComment("Should not be less than cave height.")
22012267
@ConfigEntry(path = "world.world-depth", needsReset = true)
22022268
private int worldDepth = 256;
22032269

@@ -2212,14 +2278,34 @@ public void setOnRespawnCommands(List<String> onRespawnCommands)
22122278
private boolean newMaterialGenerator = false;
22132279

22142280
@ConfigComment("")
2215-
@ConfigComment("Make over world roof of bedrock, if false, it will be made from stone")
2281+
@ConfigComment("Make over world roof of bedrock, if false, it will be made from stone.")
22162282
@ConfigEntry(path = "world.normal.roof", needsReset = true)
22172283
private boolean normalRoof = true;
22182284

2219-
@ConfigComment("Make over world floor of bedrock, if false, it will be made from stone")
2285+
@ConfigComment("")
2286+
@ConfigComment("Option allows to toggle if world generator should generate natural(-ish) looking surface with dirt and grass blocks.")
2287+
@ConfigComment("Enabling this option will ignore roof setting.")
2288+
@ConfigComment("Default value is false.")
2289+
@ConfigEntry(path = "world.normal.natural-surface", needsReset = true, experimental = true)
2290+
private boolean generateNaturalSurface = false;
2291+
2292+
@ConfigComment("")
2293+
@ConfigComment("Option allows to toggle if world generator should generate natural looking caves.")
2294+
@ConfigComment("Default value is false.")
2295+
@ConfigEntry(path = "world.normal.natural-caves", needsReset = true)
2296+
private boolean generateCaves = false;
2297+
2298+
@ConfigComment("Make over world floor of bedrock, if false, it will be made from stone.")
22202299
@ConfigEntry(path = "world.normal.floor", needsReset = true)
22212300
private boolean normalFloor = true;
22222301

2302+
@ConfigComment("")
2303+
@ConfigComment("Option allows to toggle if world generator should generate natural looking bedrock block patterns.")
2304+
@ConfigComment("Enabling this option will ignore floor setting.")
2305+
@ConfigComment("Default value is false.")
2306+
@ConfigEntry(path = "world.normal.natural-bedrock", needsReset = true)
2307+
private boolean generateNaturalBedrock = false;
2308+
22232309
@ConfigComment("Main block of which world will be generated.")
22242310
@ConfigEntry(path = "world.normal.main-block", needsReset = true)
22252311
private Material normalMainBlock = Material.STONE;

src/main/java/world/bentobox/caveblock/generators/ChunkGeneratorWorld.java

+49-18
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
import org.bukkit.generator.BlockPopulator;
77
import org.bukkit.generator.ChunkGenerator;
88
import org.bukkit.generator.WorldInfo;
9+
910
import world.bentobox.caveblock.CaveBlock;
1011
import world.bentobox.caveblock.Settings;
11-
import world.bentobox.caveblock.generators.populators.EntitiesPopulator;
12-
import world.bentobox.caveblock.generators.populators.FlatBiomeProvider;
13-
import world.bentobox.caveblock.generators.populators.MaterialPopulator;
14-
import world.bentobox.caveblock.generators.populators.NewMaterialPopulator;
12+
import world.bentobox.caveblock.generators.populators.*;
1513

1614
import java.util.ArrayList;
1715
import java.util.List;
@@ -31,6 +29,7 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
3129
private final CaveBlock addon;
3230
private final Settings settings;
3331
private final List<BlockPopulator> blockPopulators;
32+
private final World.Environment environment;
3433
private BiomeProvider biomeProvider;
3534
private boolean isNewGenerator;
3635

@@ -40,27 +39,39 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
4039

4140
/**
4241
* @param addon - CaveBlock object
42+
* @param environment - World environment
4343
*/
44-
public ChunkGeneratorWorld(CaveBlock addon) {
44+
public ChunkGeneratorWorld(CaveBlock addon, World.Environment environment) {
4545
this.addon = addon;
4646
this.settings = addon.getSettings();
4747
this.blockPopulators = new ArrayList<>(2);
4848

49+
this.environment = environment;
4950
reload();
5051
}
5152

5253
// ---------------------------------------------------------------------
5354
// Section: Methods
5455
// ---------------------------------------------------------------------
5556

56-
private Material getGroundCeilMaterial(World.Environment environment) {
57+
private Material getGroundRoofMaterial(World.Environment environment) {
5758
return switch (environment) {
5859
case NETHER -> this.settings.isNetherRoof() ? Material.BEDROCK : this.settings.getNetherMainBlock();
60+
case THE_END -> this.settings.isEndRoof() ? Material.BEDROCK : this.settings.getEndMainBlock();
61+
default -> this.settings.isNormalRoof() ? Material.BEDROCK : this.settings.getNormalMainBlock();
62+
};
63+
}
64+
65+
66+
private Material getGroundFloorMaterial(World.Environment environment) {
67+
return switch (environment) {
68+
case NETHER -> this.settings.isNetherFloor() ? Material.BEDROCK : this.settings.getNetherMainBlock();
5969
case THE_END -> this.settings.isEndFloor() ? Material.BEDROCK : this.settings.getEndMainBlock();
6070
default -> this.settings.isNormalFloor() ? Material.BEDROCK : this.settings.getNormalMainBlock();
6171
};
6272
}
6373

74+
6475
private Material getBaseMaterial(World.Environment environment) {
6576
return switch (environment) {
6677
case NETHER -> this.settings.getNetherMainBlock();
@@ -70,19 +81,35 @@ private Material getBaseMaterial(World.Environment environment) {
7081
}
7182

7283
@Override
73-
public void generateBedrock(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
74-
final int minHeight = worldInfo.getMinHeight();
75-
Material material = getGroundCeilMaterial(worldInfo.getEnvironment());
76-
chunkData.setRegion(0, minHeight, 0, 16, minHeight + 1, 16, material);
84+
public void generateBedrock(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData)
85+
{
86+
if (!this.shouldGenerateBedrock())
87+
{
88+
final int minHeight = worldInfo.getMinHeight();
89+
Material material = this.getGroundFloorMaterial(worldInfo.getEnvironment());
90+
chunkData.setRegion(0, minHeight, 0, 16, minHeight + 1, 16, material);
91+
}
92+
else
93+
{
94+
// Apparently default surface generation does not include 0 bedrock layer.
95+
final int minHeight = worldInfo.getMinHeight();
96+
chunkData.setRegion(0, minHeight, 0, 16, minHeight + 1, 16, Material.BEDROCK);
97+
}
7798
}
7899

100+
79101
@Override
80-
public void generateSurface(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
81-
final int worldHeight = Math.min(worldInfo.getMaxHeight(), this.settings.getWorldDepth());
82-
Material material = getGroundCeilMaterial(worldInfo.getEnvironment());
83-
chunkData.setRegion(0, worldHeight - 1, 0, 16, worldHeight, 16, material);
102+
public void generateSurface(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData)
103+
{
104+
if (!this.shouldGenerateSurface())
105+
{
106+
final int worldHeight = Math.min(worldInfo.getMaxHeight(), this.settings.getWorldDepth());
107+
Material material = this.getGroundRoofMaterial(worldInfo.getEnvironment());
108+
chunkData.setRegion(0, worldHeight - 1, 0, 16, worldHeight, 16, material);
109+
}
84110
}
85111

112+
86113
@Override
87114
public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
88115
final int minHeight = worldInfo.getMinHeight();
@@ -127,18 +154,22 @@ public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) {
127154
}
128155

129156
@Override
130-
public boolean shouldGenerateSurface() {
131-
return true;
157+
public boolean shouldGenerateSurface()
158+
{
159+
// Surface generation should happen only in overworld. Nether and end worlds does not have surface.
160+
return this.environment.equals(World.Environment.NORMAL) && this.settings.isGenerateNaturalSurface();
132161
}
133162

134163
@Override
135164
public boolean shouldGenerateBedrock() {
136-
return true;
165+
// Bedrock generation should happen only in overworld. Nether and end worlds does not have nice bedrock layers.
166+
return this.environment.equals(World.Environment.NORMAL) && this.settings.isGenerateNaturalBedrock();
137167
}
138168

139169
@Override
140170
public boolean shouldGenerateCaves() {
141-
return this.isNewGenerator;
171+
// Cave generation should happen only in overworld. Nether and end worlds does not have nice cave layers.
172+
return this.environment.equals(World.Environment.NORMAL) && this.settings.isGenerateCaves();
142173
}
143174

144175
/**

src/main/java/world/bentobox/caveblock/generators/populators/NewMaterialPopulator.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ public class NewMaterialPopulator extends BlockPopulator {
2222
Map<World.Environment, List<Ore>> ores = new EnumMap<>(World.Environment.class);
2323
// Source https://minecraft.fandom.com/wiki/Blob
2424
List<Ore> worldOres = new ArrayList<>();
25-
worldOres.add(new Ore(-64, 16, Material.DIAMOND_ORE, 1, 10, true));
26-
worldOres.add(new Ore(-64, 64, Material.LAPIS_ORE, 1, 7, true));
27-
worldOres.add(new Ore(-64, 30, Material.GOLD_ORE, 2, 9, true));
25+
worldOres.add(new Ore(-64, 7, Material.DEEPSLATE_DIAMOND_ORE, 1, 10, true));
26+
worldOres.add(new Ore(7, 16, Material.DIAMOND_ORE, 1, 10, true));
27+
worldOres.add(new Ore(-64, 7, Material.DEEPSLATE_LAPIS_ORE, 1, 7, true));
28+
worldOres.add(new Ore(7, 64, Material.LAPIS_ORE, 1, 7, true));
29+
worldOres.add(new Ore(-64, 7, Material.DEEPSLATE_GOLD_ORE, 2, 9, true));
30+
worldOres.add(new Ore(7, 30, Material.GOLD_ORE, 2, 9, true));
2831
worldOres.add(new Ore(0, 16, Material.TUFF, 2, 33, false));
29-
worldOres.add(new Ore(-64, 16, Material.REDSTONE_ORE, 8, 8, true));
32+
worldOres.add(new Ore(-64, 7, Material.DEEPSLATE_REDSTONE_ORE, 8, 8, true));
33+
worldOres.add(new Ore(7, 16, Material.REDSTONE_ORE, 8, 8, true));
3034
worldOres.add(new Ore(0, 16, Material.GRAVEL, 8, 33, false));
3135
worldOres.add(new Ore(0, 79, Material.GRANITE, 5, 33, false));
3236
worldOres.add(new Ore(0, 79, Material.ANDESITE, 5, 33, false));
3337
worldOres.add(new Ore(0, 79, Material.DIORITE, 5, 33, false));
3438
worldOres.add(new Ore(32, 320, Material.EMERALD_ORE, 11, 1, true));
3539
worldOres.add(new Ore(95, 136, Material.COAL_ORE, 20, 17, false));
36-
worldOres.add(new Ore(0, 96, Material.COPPER_ORE, 20, 9, true));
37-
worldOres.add(new Ore(-64, 320, Material.IRON_ORE, 20, 9, true));
40+
worldOres.add(new Ore(0, 7, Material.DEEPSLATE_COPPER_ORE, 20, 9, true));
41+
worldOres.add(new Ore(7, 96, Material.COPPER_ORE, 20, 9, true));
42+
worldOres.add(new Ore(-64, 7, Material.DEEPSLATE_IRON_ORE, 20, 9, true));
43+
worldOres.add(new Ore(7, 320, Material.IRON_ORE, 20, 9, true));
3844
worldOres.add(new Ore(-64, 320, Material.CAVE_AIR, 8, 33, false));
3945
ores.put(World.Environment.NORMAL, worldOres);
4046
List<Ore> netherOres = new ArrayList<>();

0 commit comments

Comments
 (0)