The Meaning of Life, the Universe, and Everything.
Join Date:
5/22/2015
Posts:
99
Member Details
In this tutorial I will be showing you how to spawn an ore in a specific biome. I am assuming you already have a main generation class but if you don't let me know and I will see about showing you guys how to do that. So for startes, lets say your ore name is silver and you want to spawn in specifically in the Desert Biome, you will start off by typing
String s = world.getBiomeGenForCoords(x + 8, z + 8).biomeName;
what this does is it makes it so that whatever you set for s will be the biome the silver will spawn in. In our case Desert.
Next you will want an if state saying that if s = Desert then spawn ore here.
if (s.startsWith("Desert") {
}
So now you just cause your ore to spawn. lets say we want it to spawn 10 times per chunk with a vein size of 5 and spawning below layer 20 then we do something like this
for(int i = 0; i < 10; i++) {
int CHunkX = x + random.nextInt(16);
int CHunkY = random.nextInt(20) ;
int CHunkZ = z + random.nextInt(16);
(new WorldGenMinable(MainClass.SilverOre, 5)).generate(world, random, CHunkX, CHunkY, CHunkZ);
Then you just close off your statement. I'm also assuming where you have SilverOre registered is MainClass. So i is your rareness. The higher the number the more times your ore wills spawn. the three int's are the dimensions so ChunkX and CHunkZ are always wanting to be 16 because that is the size of a chunk and the ChunkY is where the max height in the world your ore will spawn (the max height overall is 250 or something like that) so if you hit f3 and are below layer 20 you will start seeing your ore (if you are in the desert) and then finally in the last statement the five is the max size of the vein of, in our case, silver. So in the end this would be the code
String s = world.getBiomeGenForCoords(x + 8, z + 8).biomeName;
if (s.startsWith("Desert"))
{
for(int i = 0; i < 10; i++) {
int CHunkX = x + random.nextInt(16);
int CHunkY = random.nextInt(20);
int CHunkZ = z + random.nextInt(16);
(new WorldGenMinable(MainClass.SilverOre, 1)).generate(world, random, CHunkX, CHunkY, CHunkZ);
}
}
In this tutorial I will be showing you how to spawn an ore in a specific biome. I am assuming you already have a main generation class but if you don't let me know and I will see about showing you guys how to do that. So for startes, lets say your ore name is silver and you want to spawn in specifically in the Desert Biome, you will start off by typing
String s = world.getBiomeGenForCoords(x + 8, z + 8).biomeName;
what this does is it makes it so that whatever you set for s will be the biome the silver will spawn in. In our case Desert.
Next you will want an if state saying that if s = Desert then spawn ore here.
if (s.startsWith("Desert") {
}
So now you just cause your ore to spawn. lets say we want it to spawn 10 times per chunk with a vein size of 5 and spawning below layer 20 then we do something like this
for(int i = 0; i < 10; i++) {
int CHunkX = x + random.nextInt(16);
int CHunkY = random.nextInt(20) ;
int CHunkZ = z + random.nextInt(16);
(new WorldGenMinable(MainClass.SilverOre, 5)).generate(world, random, CHunkX, CHunkY, CHunkZ);
Then you just close off your statement. I'm also assuming where you have SilverOre registered is MainClass. So i is your rareness. The higher the number the more times your ore wills spawn. the three int's are the dimensions so ChunkX and CHunkZ are always wanting to be 16 because that is the size of a chunk and the ChunkY is where the max height in the world your ore will spawn (the max height overall is 250 or something like that) so if you hit f3 and are below layer 20 you will start seeing your ore (if you are in the desert) and then finally in the last statement the five is the max size of the vein of, in our case, silver. So in the end this would be the code
String s = world.getBiomeGenForCoords(x + 8, z + 8).biomeName;
if (s.startsWith("Desert"))
{
for(int i = 0; i < 10; i++) {
int CHunkX = x + random.nextInt(16);
int CHunkY = random.nextInt(20);
int CHunkZ = z + random.nextInt(16);
(new WorldGenMinable(MainClass.SilverOre, 1)).generate(world, random, CHunkX, CHunkY, CHunkZ);
}
}