1
1
package world .bentobox .caveblock .generators .populators ;
2
2
3
+ import java .util .ArrayList ;
4
+ import java .util .Collections ;
5
+ import java .util .EnumMap ;
6
+ import java .util .List ;
7
+ import java .util .Map ;
8
+ import java .util .Random ;
9
+
3
10
import org .bukkit .Location ;
4
11
import org .bukkit .Material ;
5
12
import org .bukkit .World ;
6
13
import org .bukkit .generator .BlockPopulator ;
7
14
import org .bukkit .generator .LimitedRegion ;
8
15
import org .bukkit .generator .WorldInfo ;
16
+
9
17
import world .bentobox .caveblock .Utils ;
10
18
import world .bentobox .caveblock .generators .Ore ;
11
19
12
- import java .util .*;
13
-
14
20
/**
15
21
* @author tastybento
16
22
*/
@@ -19,95 +25,102 @@ public class NewMaterialPopulator extends BlockPopulator {
19
25
private static final Map <World .Environment , List <Ore >> ORES ;
20
26
21
27
static {
22
- Map <World .Environment , List <Ore >> ores = new EnumMap <>(World .Environment .class );
23
- // Source https://minecraft.fandom.com/wiki/Blob
24
- List <Ore > worldOres = new ArrayList <>();
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 ));
31
- worldOres .add (new Ore (0 , 16 , Material .TUFF , 2 , 33 , false ));
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 ));
34
- worldOres .add (new Ore (0 , 16 , Material .GRAVEL , 8 , 33 , false ));
35
- worldOres .add (new Ore (0 , 79 , Material .GRANITE , 5 , 33 , false ));
36
- worldOres .add (new Ore (0 , 79 , Material .ANDESITE , 5 , 33 , false ));
37
- worldOres .add (new Ore (0 , 79 , Material .DIORITE , 5 , 33 , false ));
38
- worldOres .add (new Ore (32 , 320 , Material .EMERALD_ORE , 11 , 1 , true ));
39
- worldOres .add (new Ore (95 , 136 , Material .COAL_ORE , 20 , 17 , false ));
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 ));
44
- worldOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
45
- ores .put (World .Environment .NORMAL , worldOres );
46
- List <Ore > netherOres = new ArrayList <>();
47
- netherOres .add (new Ore (1 , 22 , Material .ANCIENT_DEBRIS , 1 , 5 , true ));
48
- netherOres .add (new Ore (-64 , 30 , Material .NETHER_GOLD_ORE , 2 , 9 , true ));
49
- netherOres .add (new Ore (0 , 16 , Material .GRAVEL , 8 , 33 , false ));
50
- netherOres .add (new Ore (0 , 320 , Material .BASALT , 8 , 33 , false ));
51
- netherOres .add (new Ore (0 , 320 , Material .BLACKSTONE , 8 , 33 , false ));
52
- netherOres .add (new Ore (0 , 320 , Material .FIRE , 8 , 33 , false ));
53
- netherOres .add (new Ore (200 , 320 , Material .GLOWSTONE , 8 , 33 , false ));
54
- netherOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
55
- netherOres .add (new Ore (-64 , 320 , Material .LAVA , 8 , 33 , false ));
56
- netherOres .add (new Ore (0 , 16 , Material .MAGMA_BLOCK , 8 , 33 , false ));
57
- netherOres .add (new Ore (0 , 320 , Material .CRIMSON_FUNGUS , 8 , 33 , false ));
58
- netherOres .add (new Ore (0 , 320 , Material .WARPED_FUNGUS , 8 , 33 , false ));
59
- netherOres .add (new Ore (0 , 320 , Material .CRIMSON_NYLIUM , 8 , 33 , false ));
60
- netherOres .add (new Ore (0 , 320 , Material .WARPED_NYLIUM , 8 , 33 , false ));
61
- netherOres .add (new Ore (0 , 320 , Material .SHROOMLIGHT , 8 , 33 , false ));
62
- netherOres .add (new Ore (0 , 320 , Material .CRIMSON_STEM , 8 , 33 , false ));
63
- netherOres .add (new Ore (0 , 320 , Material .WARPED_STEM , 8 , 33 , false ));
64
- netherOres .add (new Ore (-64 , 34 , Material .SOUL_SOIL , 20 , 17 , false ));
65
- netherOres .add (new Ore (0 , 96 , Material .NETHER_QUARTZ_ORE , 20 , 9 , true ));
66
- netherOres .add (new Ore (-64 , 320 , Material .BONE_BLOCK , 20 , 9 , true ));
67
- ores .put (World .Environment .NETHER , netherOres );
68
- List <Ore > endOres = new ArrayList <>();
69
- endOres .add (new Ore (32 , 320 , Material .PURPUR_BLOCK , 11 , 1 , true ));
70
- endOres .add (new Ore (95 , 136 , Material .OBSIDIAN , 20 , 17 , false ));
71
- endOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
72
- ores .put (World .Environment .THE_END , endOres );
73
- ORES = Collections .unmodifiableMap (ores );
28
+ Map <World .Environment , List <Ore >> ores = new EnumMap <>(World .Environment .class );
29
+ // Source https://minecraft.fandom.com/wiki/Blob
30
+ List <Ore > worldOres = new ArrayList <>();
31
+ worldOres .add (new Ore (-64 , 7 , Material .DEEPSLATE_DIAMOND_ORE , 1 , 10 , true ));
32
+ worldOres .add (new Ore (7 , 16 , Material .DIAMOND_ORE , 1 , 10 , true ));
33
+ worldOres .add (new Ore (-64 , 7 , Material .DEEPSLATE_LAPIS_ORE , 1 , 7 , true ));
34
+ worldOres .add (new Ore (7 , 64 , Material .LAPIS_ORE , 1 , 7 , true ));
35
+ worldOres .add (new Ore (-64 , 7 , Material .DEEPSLATE_GOLD_ORE , 2 , 9 , true ));
36
+ worldOres .add (new Ore (7 , 30 , Material .GOLD_ORE , 2 , 9 , true ));
37
+ worldOres .add (new Ore (0 , 16 , Material .TUFF , 2 , 33 , false ));
38
+ worldOres .add (new Ore (-64 , 7 , Material .DEEPSLATE_REDSTONE_ORE , 8 , 8 , true ));
39
+ worldOres .add (new Ore (7 , 16 , Material .REDSTONE_ORE , 8 , 8 , true ));
40
+ worldOres .add (new Ore (0 , 16 , Material .GRAVEL , 8 , 33 , false ));
41
+ worldOres .add (new Ore (0 , 79 , Material .GRANITE , 5 , 33 , false ));
42
+ worldOres .add (new Ore (0 , 79 , Material .ANDESITE , 5 , 33 , false ));
43
+ worldOres .add (new Ore (0 , 79 , Material .DIORITE , 5 , 33 , false ));
44
+ worldOres .add (new Ore (32 , 320 , Material .EMERALD_ORE , 11 , 1 , true ));
45
+ worldOres .add (new Ore (95 , 136 , Material .COAL_ORE , 20 , 17 , false ));
46
+ worldOres .add (new Ore (0 , 7 , Material .DEEPSLATE_COPPER_ORE , 20 , 9 , true ));
47
+ worldOres .add (new Ore (7 , 96 , Material .COPPER_ORE , 20 , 9 , true ));
48
+ worldOres .add (new Ore (-64 , 7 , Material .DEEPSLATE_IRON_ORE , 20 , 9 , true ));
49
+ worldOres .add (new Ore (7 , 320 , Material .IRON_ORE , 20 , 9 , true ));
50
+ worldOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
51
+ ores .put (World .Environment .NORMAL , worldOres );
52
+ List <Ore > netherOres = new ArrayList <>();
53
+ netherOres .add (new Ore (1 , 22 , Material .ANCIENT_DEBRIS , 1 , 5 , true ));
54
+ netherOres .add (new Ore (-64 , 30 , Material .NETHER_GOLD_ORE , 2 , 9 , true ));
55
+ netherOres .add (new Ore (0 , 16 , Material .GRAVEL , 8 , 33 , false ));
56
+ netherOres .add (new Ore (0 , 320 , Material .BASALT , 8 , 33 , false ));
57
+ netherOres .add (new Ore (0 , 320 , Material .BLACKSTONE , 8 , 33 , false ));
58
+ netherOres .add (new Ore (0 , 320 , Material .FIRE , 8 , 33 , false ));
59
+ netherOres .add (new Ore (200 , 320 , Material .GLOWSTONE , 8 , 33 , false ));
60
+ netherOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
61
+ netherOres .add (new Ore (-64 , 320 , Material .LAVA , 8 , 33 , false ));
62
+ netherOres .add (new Ore (0 , 16 , Material .MAGMA_BLOCK , 8 , 33 , false ));
63
+ netherOres .add (new Ore (0 , 320 , Material .CRIMSON_FUNGUS , 8 , 33 , false ));
64
+ netherOres .add (new Ore (0 , 320 , Material .WARPED_FUNGUS , 8 , 33 , false ));
65
+ netherOres .add (new Ore (0 , 320 , Material .CRIMSON_NYLIUM , 8 , 33 , false ));
66
+ netherOres .add (new Ore (0 , 320 , Material .WARPED_NYLIUM , 8 , 33 , false ));
67
+ netherOres .add (new Ore (0 , 320 , Material .SHROOMLIGHT , 8 , 33 , false ));
68
+ netherOres .add (new Ore (0 , 320 , Material .CRIMSON_STEM , 8 , 33 , false ));
69
+ netherOres .add (new Ore (0 , 320 , Material .WARPED_STEM , 8 , 33 , false ));
70
+ netherOres .add (new Ore (-64 , 34 , Material .SOUL_SOIL , 20 , 17 , false ));
71
+ netherOres .add (new Ore (0 , 96 , Material .NETHER_QUARTZ_ORE , 20 , 9 , true ));
72
+ netherOres .add (new Ore (-64 , 320 , Material .BONE_BLOCK , 20 , 9 , true ));
73
+ ores .put (World .Environment .NETHER , netherOres );
74
+ List <Ore > endOres = new ArrayList <>();
75
+ endOres .add (new Ore (32 , 320 , Material .PURPUR_BLOCK , 11 , 1 , true ));
76
+ endOres .add (new Ore (95 , 136 , Material .OBSIDIAN , 20 , 17 , false ));
77
+ endOres .add (new Ore (-64 , 320 , Material .CAVE_AIR , 8 , 33 , false ));
78
+ ores .put (World .Environment .THE_END , endOres );
79
+ ORES = Collections .unmodifiableMap (ores );
74
80
}
75
81
76
82
private final int worldDepth ;
77
83
84
+ /**
85
+ * @param worldDepth - Depth. If depth is set smaller than the world height,
86
+ * then the area above will be empty. Should not be less than
87
+ * cave height.
88
+ */
78
89
public NewMaterialPopulator (int worldDepth ) {
79
- this .worldDepth = worldDepth ;
90
+ this .worldDepth = worldDepth ;
80
91
}
81
92
82
93
@ Override
83
94
public void populate (WorldInfo worldInfo , Random random , int chunkX , int chunkZ , LimitedRegion limitedRegion ) {
84
- final int worldHeight = Math .min (worldInfo .getMaxHeight (), this .worldDepth );
85
- for (int y = worldInfo .getMinHeight (); y < worldHeight - 1 ; y ++) {
86
- for (Ore o : ORES .get (worldInfo .getEnvironment ())) {
87
- if (y > o .minY () && y < o .maxY () && random .nextInt (100 ) <= o .chance ()) {
88
- pasteBlob (worldInfo , random , chunkX , chunkZ , limitedRegion , y , o );
89
- if (o .cont ()) {
90
- break ;
91
- }
92
- }
93
- }
94
- }
95
+ final int worldHeight = Math .min (worldInfo .getMaxHeight (), this .worldDepth );
96
+ for (int y = worldInfo .getMinHeight () + 1 ; y < worldHeight - 1 ; y ++) {
97
+ for (Ore o : ORES .get (worldInfo .getEnvironment ())) {
98
+ if (y > o .minY () && y < o .maxY () && random .nextInt (100 ) <= o .chance ()) {
99
+ pasteBlob (worldInfo , random , chunkX , chunkZ , limitedRegion , y , o );
100
+ if (o .cont ()) {
101
+ break ;
102
+ }
103
+ }
104
+ }
105
+ }
95
106
}
96
107
97
- private void pasteBlob (WorldInfo worldInfo , Random random , int chunkX , int chunkZ , LimitedRegion limitedRegion , int y , Ore o ) {
98
- int offset = random .nextInt (16 );
99
- for (int x = Math .max (0 , offset - BLOB_SIZE ); x < Math .min (16 , offset + BLOB_SIZE ); x ++) {
100
- for (int z = Math .max (0 , offset - BLOB_SIZE ); z < Math .min (16 , offset + BLOB_SIZE ); z ++) {
101
- for (int yy = Math .max (worldInfo .getMinHeight (), y - BLOB_SIZE ); yy < Math .min (worldInfo .getMaxHeight (), y + BLOB_SIZE ); yy ++) {
102
- Location location = Utils .getLocationFromChunkLocation (x , yy , z , chunkX , chunkZ );
103
- if (!limitedRegion .isInRegion (location )) {
104
- continue ;
105
- }
106
- if (limitedRegion .getType (location ).isSolid () && random .nextBoolean ()) {
107
- limitedRegion .setType (location , o .material ());
108
- }
109
- }
110
- }
111
- }
108
+ private void pasteBlob (WorldInfo worldInfo , Random random , int chunkX , int chunkZ , LimitedRegion limitedRegion ,
109
+ int y , Ore o ) {
110
+ int offset = random .nextInt (16 );
111
+ for (int x = Math .max (0 , offset - BLOB_SIZE ); x < Math .min (16 , offset + BLOB_SIZE ); x ++) {
112
+ for (int z = Math .max (0 , offset - BLOB_SIZE ); z < Math .min (16 , offset + BLOB_SIZE ); z ++) {
113
+ for (int yy = Math .max (worldInfo .getMinHeight () + 1 , y - BLOB_SIZE ); yy < Math
114
+ .min (worldInfo .getMaxHeight () - 1 , y + BLOB_SIZE ); yy ++) {
115
+ Location location = Utils .getLocationFromChunkLocation (x , yy , z , chunkX , chunkZ );
116
+ if (!limitedRegion .isInRegion (location )) {
117
+ continue ;
118
+ }
119
+ if (limitedRegion .getType (location ).isSolid () && random .nextBoolean ()) {
120
+ limitedRegion .setType (location , o .material ());
121
+ }
122
+ }
123
+ }
124
+ }
112
125
}
113
126
}
0 commit comments