I'm making a simple mod that adds two ore types. I've successfully got the ores spawning in the world, but I'd like to be able to narrow down where they spawn -- and not just how deep or in which biomes. I've managed both of those. I'm looking to get one ore to spawn only in the vicinity of lava pools (underground or on the surface) and the other one to spawn only in caves.
I've poked around with reeds for a while, hoping I could figure it out by looking at the code that places them near water, but I'm not having any luck. Anyone have any advice?
public void generateSurface(World world, Random random, int chunkX, int chunkZ)
{
for(int i = 0; i < 30; i++)
{
int randPosX = chunkX + random.nextInt(16);
int randPosY = random.nextInt(128);
int randPosZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(brimstone.blockID, 15)).generate(world, random, randPosX, randPosY, randPosZ);
}
for(int p = 0; p < 30; p++)
{
int randPosX = chunkX + random.nextInt(16);
int randPosY = random.nextInt(128);
int randPosZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(saltpeter.blockID, 15)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
Do a check for lava. If lava is detected within x amount of your block, then spawn.
For the other, not sure how you'd go about that, other than doing a blockNear == null check...
Yeah, I know I need to check for lava within a radius of the randomly selected coordinates, but I'm not sure how to do that. I think I need to use an array and sort through the results, but I haven't had any luck with it yet.
Any other ideas? I've sort of made this work by forcing the WorldGenLakes class to spawn my ore at the edge of lava lakes instead of stone, but it only functions correctly about half the time. Apparently most of the underground lava is generated differently...
I've poked around with reeds for a while, hoping I could figure it out by looking at the code that places them near water, but I'm not having any luck. Anyone have any advice?
For the other, not sure how you'd go about that, other than doing a blockNear == null check...
Yeah, I know I need to check for lava within a radius of the randomly selected coordinates, but I'm not sure how to do that. I think I need to use an array and sort through the results, but I haven't had any luck with it yet.