mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-08 19:50:23 -04:00
Add every registered Ore automatically to the chunk generation
This commit is contained in:
parent
f7c07b4285
commit
cfb0d63955
@ -34,15 +34,8 @@ public class Chunk {
|
||||
private static Ore [] ores;
|
||||
private static float [] oreChances;
|
||||
private static int [] oreHeights;
|
||||
static {
|
||||
ArrayList<Ore> 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:
|
||||
|
@ -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<Ore> ores = new ArrayList<Ore>();
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user