66
77import org .apache .commons .io .FileUtils ;
88
9+ import com .google .common .collect .ImmutableList ;
910import com .google .gson .Gson ;
1011import com .google .gson .GsonBuilder ;
1112import com .google .gson .JsonArray ;
@@ -50,13 +51,7 @@ public void writeSpawnEntries() {
5051 dimension .addProperty (ConfigNames .DIMENSION , String .format ("%d" , dim .getKey ()));
5152 }
5253
53- JsonArray spawns = new JsonArray ();
54-
55- dim .getValue ().getAllSpawns ().stream ().filter ( spawn -> !spawn .getOres ().isEmpty () )
56- .filter (spawn -> spawn .getOres ().get (0 ).getOre () != null )
57- .filter (spawn -> "minecraft:air" .equals (spawn .getOres ().get (0 ).getOre ().getBlock ().getRegistryName ().toString ()))
58- .map ( this ::genSpawn )
59- .forEach ( spawns ::add );
54+ JsonArray spawns = this .genSpawns (dim .getValue ().getAllSpawns ());
6055
6156 if ( spawns .size () > 0 ) {
6257 dimension .add (ConfigNames .ORES , spawns );
@@ -74,6 +69,19 @@ public void writeSpawnEntries() {
7469 });
7570 }
7671
72+ private JsonArray genSpawns (ImmutableList <SpawnBuilder > allSpawns ) {
73+ JsonArray rv = new JsonArray ();
74+ for ( SpawnBuilder spawn : allSpawns ) {
75+ if ( spawn .getOres ().isEmpty () ||
76+ spawn .getOres ().get (0 ).getOre () == null ||
77+ "minecraft:air" .equals (spawn .getOres ().get (0 ).getOre ().getBlock ().getRegistryName ().toString ()) ) {
78+ continue ;
79+ }
80+ rv .add ( this .genSpawn (spawn ) );
81+ }
82+ return rv ;
83+ }
84+
7785 private void writeFile (File file , JsonObject wrapper ) {
7886 Gson gson = new GsonBuilder ().setPrettyPrinting ().create ();
7987 try {
@@ -90,6 +98,7 @@ private JsonObject genSpawn(SpawnBuilder spawn) {
9098 String blockName = spawn .getOres ().get (0 ).getOre ().getBlock ().getRegistryName ().toString ();
9199
92100 ore .addProperty (ConfigNames .BLOCK , blockName );
101+
93102 String state = StateUtil .serializeState (spawn .getOres ().get (0 ).getOre ());
94103 if ( !ConfigNames .STATE_NORMAL .equals (state ) ) {
95104 ore .addProperty (ConfigNames .STATE , state );
0 commit comments