6
6
import org .bukkit .generator .BlockPopulator ;
7
7
import org .bukkit .generator .ChunkGenerator ;
8
8
import org .bukkit .generator .WorldInfo ;
9
+
9
10
import world .bentobox .caveblock .CaveBlock ;
10
11
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 .*;
15
13
16
14
import java .util .ArrayList ;
17
15
import java .util .List ;
@@ -31,6 +29,7 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
31
29
private final CaveBlock addon ;
32
30
private final Settings settings ;
33
31
private final List <BlockPopulator > blockPopulators ;
32
+ private final World .Environment environment ;
34
33
private BiomeProvider biomeProvider ;
35
34
private boolean isNewGenerator ;
36
35
@@ -40,27 +39,39 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
40
39
41
40
/**
42
41
* @param addon - CaveBlock object
42
+ * @param environment - World environment
43
43
*/
44
- public ChunkGeneratorWorld (CaveBlock addon ) {
44
+ public ChunkGeneratorWorld (CaveBlock addon , World . Environment environment ) {
45
45
this .addon = addon ;
46
46
this .settings = addon .getSettings ();
47
47
this .blockPopulators = new ArrayList <>(2 );
48
48
49
+ this .environment = environment ;
49
50
reload ();
50
51
}
51
52
52
53
// ---------------------------------------------------------------------
53
54
// Section: Methods
54
55
// ---------------------------------------------------------------------
55
56
56
- private Material getGroundCeilMaterial (World .Environment environment ) {
57
+ private Material getGroundRoofMaterial (World .Environment environment ) {
57
58
return switch (environment ) {
58
59
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 ();
59
69
case THE_END -> this .settings .isEndFloor () ? Material .BEDROCK : this .settings .getEndMainBlock ();
60
70
default -> this .settings .isNormalFloor () ? Material .BEDROCK : this .settings .getNormalMainBlock ();
61
71
};
62
72
}
63
73
74
+
64
75
private Material getBaseMaterial (World .Environment environment ) {
65
76
return switch (environment ) {
66
77
case NETHER -> this .settings .getNetherMainBlock ();
@@ -70,19 +81,35 @@ private Material getBaseMaterial(World.Environment environment) {
70
81
}
71
82
72
83
@ 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
+ }
77
98
}
78
99
100
+
79
101
@ 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
+ }
84
110
}
85
111
112
+
86
113
@ Override
87
114
public void generateNoise (WorldInfo worldInfo , Random random , int chunkX , int chunkZ , ChunkData chunkData ) {
88
115
final int minHeight = worldInfo .getMinHeight ();
@@ -127,18 +154,22 @@ public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) {
127
154
}
128
155
129
156
@ 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 ();
132
161
}
133
162
134
163
@ Override
135
164
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 ();
137
167
}
138
168
139
169
@ Override
140
170
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 ();
142
173
}
143
174
144
175
/**
0 commit comments