diff --git a/cubyz-common/src/io/cubyz/world/Chunk.java b/cubyz-common/src/io/cubyz/world/Chunk.java index 4a2b8ab7..299e5080 100644 --- a/cubyz-common/src/io/cubyz/world/Chunk.java +++ b/cubyz-common/src/io/cubyz/world/Chunk.java @@ -34,15 +34,8 @@ public class Chunk { private static Ore [] ores; private static float [] oreChances; private static int [] oreHeights; - static { - ArrayList oress = new ArrayList<>(); - oress.add((Ore) br.getByID("cubyz:coal_ore")); - oress.add((Ore) br.getByID("cubyz:iron_ore")); - oress.add((Ore) br.getByID("cubyz:ruby_ore")); - oress.add((Ore) br.getByID("cubyz:gold_ore")); - oress.add((Ore) br.getByID("cubyz:diamond_ore")); - oress.add((Ore) br.getByID("cubyz:emerald_ore")); - ores = oress.toArray(new Ore[0]); + + public static void init(Ore [] ores) { oreChances = new float[ores.length+1]; oreHeights = new int[ores.length]; for(int i = 0; i < ores.length; i++) { @@ -65,6 +58,7 @@ public class Chunk { for(int i = 0; i < ores.length; i++) { oreChances[i+1] = oreChances[i] + ores[i].getChance(); } + Chunk.ores = ores; } // Liquids: diff --git a/cubyz-common/src/io/cubyz/world/LocalWorld.java b/cubyz-common/src/io/cubyz/world/LocalWorld.java index d738e9a3..fbd0df5a 100644 --- a/cubyz-common/src/io/cubyz/world/LocalWorld.java +++ b/cubyz-common/src/io/cubyz/world/LocalWorld.java @@ -12,6 +12,7 @@ import io.cubyz.api.CubzRegistries; import io.cubyz.api.IRegistryElement; import io.cubyz.blocks.Block; import io.cubyz.blocks.BlockInstance; +import io.cubyz.blocks.Ore; import io.cubyz.entity.Entity; import io.cubyz.entity.Player; import io.cubyz.save.WorldIO; @@ -203,6 +204,7 @@ public class LocalWorld extends World { Random r = new Random(); int ID = 0; seed = r.nextInt(); + ArrayList ores = new ArrayList(); blocks = new Block[CubzRegistries.BLOCK_REGISTRY.registered().length]; for (IRegistryElement ire : CubzRegistries.BLOCK_REGISTRY.registered()) { Block b = (Block) ire; @@ -219,7 +221,12 @@ public class LocalWorld extends World { b.ID = ID; ID++; } + try { + ores.add((Ore)b); + } + catch(Exception e) {} } + Chunk.init(ores.toArray(new Ore[ores.size()])); } @Override