I need help again…
I’m trying to implement generation of veins in asteroids like in GT instead of the standard generation of one ore in one asteroid.
I’m having difficulty building arrays and methods
This is the original ore generation code:
Original
ChunkProviderAsteroids
public class ChunkProviderAsteroids extends ChunkProviderGenerate
{
private final SpecialAsteroidBlockHandler coreHandler;
public ChunkProviderAsteroids(World par1World, long par2, boolean par4)
{
//
this.coreHandler = new SpecialAsteroidBlockHandler();
//Diamond ore - has no config to disable
this.coreHandler.addBlock(new SpecialAsteroidBlock(Blocks.diamond_ore, (byte) 0, 1, .1));
}
}
SpecialAsteroidBlockHandler
public class SpecialAsteroidBlockHandler
{
ArrayList<SpecialAsteroidBlock> asteroidBlocks;
public SpecialAsteroidBlockHandler(SpecialAsteroidBlock... asteroidBlocks)
{
this.asteroidBlocks = new ArrayList<SpecialAsteroidBlock>();
for (SpecialAsteroidBlock asteroidBlock : this.asteroidBlocks)
{
for (int i = 0; i < asteroidBlock.probability; i++)
{
this.asteroidBlocks.add(asteroidBlock);
}
}
}
public SpecialAsteroidBlockHandler()
{
this.asteroidBlocks = new ArrayList<SpecialAsteroidBlock>();
}
public void addBlock(SpecialAsteroidBlock asteroidBlock)
{
for (int i = 0; i < asteroidBlock.probability; i++)
{
this.asteroidBlocks.add(asteroidBlock);
}
}
public SpecialAsteroidBlock getBlock(Random rand, int size)
{
int s = this.asteroidBlocks.size();
if (s < 10)
return this.asteroidBlocks.get(rand.nextInt(s));
Double r = rand.nextDouble();
int index = (int) (s * Math.pow(r, (size + 5) * 0.05D));
return this.asteroidBlocks.get(index);
}
}
SpecialAsteroidBlock
public class SpecialAsteroidBlock
{
public Block block;
public byte meta;
public int probability;
public double thickness; //Arbitrary scale from 0 to 1;
public int index;
public static ArrayList<SpecialAsteroidBlock> register = new ArrayList();
public SpecialAsteroidBlock(Block block, byte meta, int probability, double thickness)
{
this.block = block;
this.meta = meta;
this.probability = probability;
this.thickness = thickness;
this.index = register.size();
register.add(this);
}
}
I’m thinking of doing something like this:
Embedding option
this.eOreLayerHandler = new GCAOE_OresLayerHandler();
this.eOreLayerHandler.addLayerName(new GCAOE_OresLayerName("lQuartz", 1, .2)); //"lQuartz" - Name of ore vein
More like this
public class GCAOE_OresLayerList {
public void list() {
new GCAOE_OresLayerName("lQuartz", EBlock.ore2[7], EBlock.ore2[1], EBlock.ore1[0], EBlock.ore1[0]);
new GCAOE_OresLayerName("lGold", EBlock.ore1[5], EBlock.ore2[2], EBlock.ore2[0], EBlock.ore2[6]);
new GCAOE_OresLayerName("lPlatinum", EBlock.ore1[1], EBlock.ore2[8], EBlock.ore1[7], EBlock.ore1[3]);
new GCAOE_OresLayerName("lTungstate", EBlock.ore1[6], EBlock.ore2[10], EBlock.ore2[11], EBlock.ore2[9]);
new GCAOE_OresLayerName("lNaquadah", EBlock.ore1[4], EBlock.ore1[4], EBlock.ore1[4], EBlock.ore1[4]);
new GCAOE_OresLayerName("lTrinium", EBlock.ore1[8], EBlock.ore1[8], EBlock.ore1[8], EBlock.ore1[8]);
new GCAOE_OresLayerName("lDolamide", EBlock.ore2[5], EBlock.ore2[4], EBlock.ore2[3], EBlock.ore1[2]);
}
}
This is still a draft version for visual perception.