Recently, someone asked me about how to do ore generation. Afterward, I noticed that lots of people were having trouble getting their ore generation code to work. So I've decided to make a post explaining how you do ore generation.
For clarity, I will be calling the ore gen class Oregen.
1) You create a class that implements the IWorldGenerator interface. If you are using Eclipse, make sure the "inherited abstract methods" checkbox is checked in Eclipse's New Class dialog. The class should be like this:
public class Oregen implements IWorldGenerator
{...stuff...}
2) Now inside that class, create a method called generate with the following header (the variable names for the arguments can be changed):
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
3) Now fill in the generate method with code to generate your ores in the correct dimensions (or call separate functions for each dimension). I did it using a switch-case block with cases for each dimension ID.
switch(dimID)
{
case -1:
nether...
break;
case 0:
overworld...
break;
case 1:
end...
break;
default:
break;
}
4) Now, make a function like this (the content of the function is based on the code for generating quartz ore found in the Nether Chunk Provider and is the one I use in my mod):
public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn)
{
int heightRange = maxY - minY;
WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
for (int k1 = 0; k1 < chancesToSpawn; ++k1)
{
int xrand = random.nextInt(16);
int yrand = random.nextInt(heightRange) + minY;
int zrand = random.nextInt(16);
worldgenminable.generate(world, random, chunk_x+xrand, y, chunk_z+zrand);
}
}
}
5) Now either call that in the proper case block or if you made functions for each dimension's ore gen, call this inside the proper function and then call that function in the proper case block and your ore will generate. Use the following syntax (yourOreBlock is a placeholder for your ore block object, it doesn't have to be named that):
generateOre(yourOreBlock, world, random, x, z)
The Oregen class is finished.
6) Now, in the main mod file's preInit function, assign an instance of this class to a variable and then pass that variable into a call to GameRegistry.registerWorldGenerator, like this:
Oregen ore_gen = new Oregen();
GameRegistry.registerWorldGenerator(ore_gen, 0);
And finally, in case you need it, here is the entire file:
import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.event.terraingen.TerrainGen;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
public class Oregen implements IWorldGenerator
{
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch(world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
break;
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
break;
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
break;
default:
}
}
private void generateEnd(World world, Random random, int x, int z)
{
...
}
private void generateSurface(World world, Random random, int x, int z)
{
...
}
private void generateNether(World world, Random random, int x, int z)
{
...
}
public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn)
{
int heightRange = maxY - minY;
WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
for (int k1 = 0; k1 < chancesToSpawn; ++k1)
{
int xrand = random.nextInt(16);
int yrand = random.nextInt(heightRange) + minY;
int zrand = random.nextInt(16);
worldgenminable.generate(world, random, chunk_x+xrand, y, chunk_z+zrand);
}
}
}
Possible Issues:
If you did this, and your ore is not generating, make sure that you have done the registerWorldGenerator call in the main modfile.
Also, I've seen multiple people having issues because they have multiple copies of a function to generate the ores for the same dimension. If there are multiple copies of the same function, only the last one defined is called. Therefore, any ores in the first copy but not in the last will not generate.
And finally, if you are having your ore veins generate in a regular grid, all at the same height, then you are somehow re-initializing the random number generator every time the function is called. Remove any code from these functions that initializes the random generator. Forge will initialize the generator for you.
If you're having issues with variable names, it was an error in my code. It has been fixed.
If you're having (or have had) another ore gen issue not listed here and you think it should be here, tell me and I'll add it!
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
The Meaning of Life, the Universe, and Everything.
Join Date:
4/2/2013
Posts:
130
Minecraft:
Flamealchamist
Xbox:
Flamealcamist
PSN:
Flamealchamist
Member Details
ok well I found an easier way
package com.flame.mod;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class Oregen implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
/* runs 'generateNether' or 'generateSurface' depending on which dimension you're loading */
switch(world.provider.dimensionId) {
case -1: generateNether(world, random, chunkX*16, chunkZ*16);
break;
case 0: generateSurface(world, random, chunkX*16, chunkZ*16);
break;
}
}
public void generateSurface(World world, Random random, int x, int z) {
this.addOreSpawn(Flamesmod.Bronzeore, world, random, x, z, 16, 16, 50, 20, 0, 256);
}
public void generateNether(World world, Random random, int x, int z) {
}
public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY ){
for(int i = 0; i < chancesToSpawn; i++){
int posX = blockXPos + random.nextInt(maxX);
int posY = minY + random.nextInt(maxY -minY);
int posZ = blockZPos + random.nextInt(maxZ);
new WorldGenMinable(block, maxVeinSize).generate(world, random, posX, posY, posZ);
}
}
}
Hope this helped you with coding your own ore generation!
Are you still having any issues? If so, ask me about them.
Also, this code can be used for more more than just ores. I used it (it was in my custom Nether chunk provider, however) to generate random patches of Nether Wart, and (in my ore gen class this time) to generate patches of soul sand.
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
One question. I have my ore generating properly when I make it really common, but I want to make it more rare than diamond, but still reasonable. Do you know what the code for diamond ore generation is?
One question. I have my ore generating properly when I make it really common, but I want to make it more rare than diamond, but still reasonable. Do you know what the code for diamond ore generation is?
The function arguments for diamond are:
blockXPos = x
blockZPos = z
maxX = 16
maxZ = 16
maxVeinSize = 7? (maybe 8)
chancesToSpawn = 1
minY = 0
maxY = 16
To make an ore that is rarer than diamond, I suggest you reduce maxVeinSize or maxY (or increase minY if you want it to start generating higher than the bottom of the world).
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
Thank you for this; all the other Forge ore generation tutorials always seemed to have some broken parts, but this helped me a lot. A question, though; would you know how I would have to go ahead if I wanted my "ore" to generate inside glowstone clusters in the Nether? Possibly hooking onto the vanilla generation and replacing a percentage of glowstone with my custom ore, would that be doable with Forge?
Thank you for this; all the other Forge ore generation tutorials always seemed to have some broken parts, but this helped me a lot. A question, though; would you know how I would have to go ahead if I wanted my "ore" to generate inside glowstone clusters in the Nether? Possibly hooking onto the vanilla generation and replacing a percentage of glowstone with my custom ore, would that be doable with Forge?
You could do that by literally having the ore generate in glowstone (make it gen high # of times/chunk) (somewhat unreliable).
You could also do it (more reliable) by overriding the ChunkProviderNether class (no base edits required if you do it right! I'll possibly make a full tutorial later) so that it uses your own modified WorldGenGlowStone1 and WorldGenGlowStone2 classes. Also, you could use reflection to override the WorldGenGlowStone1 and WorldGenGlowStone2 classes directly without replacing the ChunkProviderNether (I think), but it's harder (the other way just needs an extra dimension and Forge events).
Quick explanation:
Create a new dimension:
dimID = 6; //actual dimID can be anything I think (there are bounds but I forgot them but I'm sure they're no lower than 255), but don't use -1, 0, or 1 or it'll have an ID conflict and crash the game
/*Setting up worldgen*/
WorldServer world = DimensionManager.getWorld(-1); //gets the Nether world
DimensionManager.registerProviderType(dimID, WorldProviderEnder.class, true);
DimensionManager.registerDimension(dimID, dimID);
@SubscribeEvent
public void onNetherGen(ChunkProviderEvent.InitNoiseField event)
{
if (event.chunkProvider.getClass() == ChunkProviderNether.class)
{
ChunkProviderNetherModded gen = (ChunkProviderNetherModded)(new
ChunkProviderNetherModded(DimensionManager.getWorld(-1), DimensionManager.getWorld(-1).getSeed())); //ChunkProviderNetherModded is your modded ChunkProviderNether which can be identical except for the class names for the glowstone gen
event.setResult(Result.DENY);
event.noisefield = gen.initializeNoiseField(null, event.posX, event.posY, event.posZ, event.sizeX, event.sizeY, event.sizeZ);
}
}
For the glowstone, just look through the glowstone gen classes for where it actually sets a block to glowstone and put a random test using the world seed to make your ore generate with a 1 in [whatever you want] chance.
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
In case anyone was wondering, in the update to 1.8, the structure stays about the same, but in the WorldGenMineable, you have to change the Block to an IBlockState and the (x,y,z) in .generate to a BlockPos. to follow along with the example given by Flamealchamist, it would be:
BlockPos blockPos = new BlockPos(posX, posY, posZ);
new WorldGenMinable(block.getDefaultState(), maxVeinSize).generate(world, random, blockPos);
block.getDefaultState() is a simple way to receive the BlockState for a block, AS LONG AS IT DOESN'T CHANGE (i.e. Wheat, Carrots) as those have multiple block states. If you don't know much about block states, I HIGHLY suggest you look into them more, as they are quite important.
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
private void generateEnd(World world, Random random, int x, int z)
{
}
private void generateSurface(World world, Random random, int x, int z)
{
}
private void generateNether(World world, Random random, int x, int z)
{
}
public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn)
{
int heightRange = maxY - minY;
WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
private void generateEnd(World world, Random random, int x, int z)
{
}
private void generateSurface(World world, Random random, int x, int z)
{
}
private void generateNether(World world, Random random, int x, int z)
{
}
public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn)
{
int heightRange = maxY - minY;
WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
There seems to be nothing in your GenerateSurface, GenerateNether, and GenerateEnd methods, which control the ore gen for their respective dimensions. You'll need to add a generateOre call for your ore in the appropriate generate function for the dimension you want the ore to generate in.
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
There seems to be nothing in your GenerateSurface, GenerateNether, and GenerateEnd methods, which control the ore gen for their respective dimensions. You'll need to add a generateOre call for your ore in the appropriate generate function for the dimension you want the ore to generate in.
Can you post the crash report from using my tutorial? I'll try to figure out what's crashing it.
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
Wait, found it, just needed net.minecraft.init.Blocks.
But then it crashed...???!?!?!?!?!??!
It crashed when I was making a world.
---- Minecraft Crash Report ----
// I just don't know what went wrong
Time: 15/07/16 8:55 AM
Description: Exception in server tick loop
java.lang.NullPointerException: at index 0
at com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:240)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:231)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:226)
at com.google.common.collect.ImmutableList.construct(ImmutableList.java:303)
at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258)
at cpw.mods.fml.common.registry.GameRegistry.computeSortedGeneratorList(GameRegistry.java:126)
at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:101)
at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:280)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1055)
at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:190)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:131)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:101)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:265)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:78)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:92)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_77, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 833282536 bytes (794 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' =
Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available
'D' = Disabled 'E' = Errored
UCHIJAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAA FML{7.10.99.99} [Forge Mod Loader] (forgeBin-1.7.10-10.13.4.1614-1.7.10.jar)
UCHIJAA Forge{10.13.4.1614} [Minecraft Forge] (forgeBin-1.7.10-10.13.4.1614-1.7.10.jar)
UCHIJAA pokeore{0.1} [Pokemon Ore Mod] (bin)
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
Rollback Post to RevisionRollBack
My Mods:
Originally created by Tradeworld, I'm continuing it.
Mods that I think are cool (that also happen to all be dead):
public class FlawlessOreGen implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch(world.provider.dimensionId)
{
case 0:
generateSurface(world, random,chunkX*16,chunkZ*16);
}
}
private void generateSurface(World world, Random random, int BlockX, int BlockZ) {
for(int i =0; i<32; i++){
int Xcoord = BlockX + random.nextInt(16);
int Zcoord = BlockZ + random.nextInt(16);
int Ycoord = random.nextInt(26);
(new WorldGenMinable(CastleCrashers.FlawlessOre, 6)).generate(world, random, Xcoord, Ycoord, Zcoord);
}
}
}
Rollback Post to RevisionRollBack
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
Recently, someone asked me about how to do ore generation. Afterward, I noticed that lots of people were having trouble getting their ore generation code to work. So I've decided to make a post explaining how you do ore generation.
For clarity, I will be calling the ore gen class Oregen.
1) You create a class that implements the IWorldGenerator interface. If you are using Eclipse, make sure the "inherited abstract methods" checkbox is checked in Eclipse's New Class dialog. The class should be like this:
2) Now inside that class, create a method called generate with the following header (the variable names for the arguments can be changed):
3) Now fill in the generate method with code to generate your ores in the correct dimensions (or call separate functions for each dimension). I did it using a switch-case block with cases for each dimension ID.
4) Now, make a function like this (the content of the function is based on the code for generating quartz ore found in the Nether Chunk Provider and is the one I use in my mod):
5) Now either call that in the proper case block or if you made functions for each dimension's ore gen, call this inside the proper function and then call that function in the proper case block and your ore will generate. Use the following syntax (yourOreBlock is a placeholder for your ore block object, it doesn't have to be named that):
The Oregen class is finished.
6) Now, in the main mod file's preInit function, assign an instance of this class to a variable and then pass that variable into a call to GameRegistry.registerWorldGenerator, like this:
And finally, in case you need it, here is the entire file:
Possible Issues:
If you did this, and your ore is not generating, make sure that you have done the registerWorldGenerator call in the main modfile.
Also, I've seen multiple people having issues because they have multiple copies of a function to generate the ores for the same dimension. If there are multiple copies of the same function, only the last one defined is called. Therefore, any ores in the first copy but not in the last will not generate.
And finally, if you are having your ore veins generate in a regular grid, all at the same height, then you are somehow re-initializing the random number generator every time the function is called. Remove any code from these functions that initializes the random generator. Forge will initialize the generator for you.
If you're having issues with variable names, it was an error in my code. It has been fixed.
If you're having (or have had) another ore gen issue not listed here and you think it should be here, tell me and I'll add it!
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
"x = random.nextInt(16);
worldgenminable.generate(world, random, chunk_x+x, y, chunk_z+z)"
were the x = random.nextInt(16);
it eclipse wants me to change the x to x1
and also at chunck_z+z)
it wants me to change the second z
Please help me.
Thanks!
Hope this helped you with coding your own ore generation!
Are you still having any issues? If so, ask me about them.
Also, this code can be used for more more than just ores. I used it (it was in my custom Nether chunk provider, however) to generate random patches of Nether Wart, and (in my ore gen class this time) to generate patches of soul sand.
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
The function arguments for diamond are:
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
You could do that by literally having the ore generate in glowstone (make it gen high # of times/chunk) (somewhat unreliable).
You could also do it (more reliable) by overriding the ChunkProviderNether class (no base edits required if you do it right! I'll possibly make a full tutorial later) so that it uses your own modified WorldGenGlowStone1 and WorldGenGlowStone2 classes. Also, you could use reflection to override the WorldGenGlowStone1 and WorldGenGlowStone2 classes directly without replacing the ChunkProviderNether (I think), but it's harder (the other way just needs an extra dimension and Forge events).
Quick explanation:
Create a new dimension:
For the glowstone, just look through the glowstone gen classes for where it actually sets a block to glowstone and put a random test using the world seed to make your ore generate with a 1 in [whatever you want] chance.
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
In case anyone was wondering, in the update to 1.8, the structure stays about the same, but in the WorldGenMineable, you have to change the Block to an IBlockState and the (x,y,z) in .generate to a BlockPos. to follow along with the example given by Flamealchamist, it would be:
BlockPos blockPos = new BlockPos(posX, posY, posZ);
new WorldGenMinable(block.getDefaultState(), maxVeinSize).generate(world, random, blockPos);
block.getDefaultState() is a simple way to receive the BlockState for a block, AS LONG AS IT DOESN'T CHANGE (i.e. Wheat, Carrots) as those have multiple block states. If you don't know much about block states, I HIGHLY suggest you look into them more, as they are quite important.
IT DOESN'T WORK
What exactly is happening?
What Forge build are you using this in?
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
Hello, I've added in a new ore (silicon) and i want it to be as common as iron but i can't get it to work... can i have some help?
The Ore isn't generating.
Here is the class:
package com.metocolipson1.castlecrashers.Items;
import java.util.Random;
import com.metocolipson1.castlecrashers.Main.CastleCrashers;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
public class FlawlessOreGen implements IWorldGenerator
{
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch(world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
break;
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
break;
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
break;
default:
}
}
private void generateEnd(World world, Random random, int x, int z)
{
}
private void generateSurface(World world, Random random, int x, int z)
{
}
private void generateNether(World world, Random random, int x, int z)
{
}
public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn)
{
int heightRange = maxY - minY;
WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
for (int k1 = 0; k1 < 3200; ++k1)
{
int xrand = random.nextInt(16);
int yrand = random.nextInt(42) + minY;
int zrand = random.nextInt(16);
worldgenminable.generate(world, random, chunk_x+xrand, yrand, chunk_z+zrand);
}
}
}
Main:
public static void initWorldGen(){
registerWorldGen(new FlawlessOreGen(), 1);
}
publicstaticvoid registerWorldGen(IWorldGenerator worldGenClass, intweightedProbability){
GameRegistry.registerWorldGenerator(worldGenClass, weightedProbability);
}
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
There seems to be nothing in your GenerateSurface, GenerateNether, and GenerateEnd methods, which control the ore gen for their respective dimensions. You'll need to add a generateOre call for your ore in the appropriate generate function for the dimension you want the ore to generate in.
Can you post the crash report from using my tutorial? I'll try to figure out what's crashing it.
Links to Mods: EndPlus | Deeper Caves | FarLands
"Roughly 95% of Minecraft players hate Villagers and would be very happy if they were removed. If you are one of the 5% who actually like villagers, copy this into your signature." -RainbowGirl
Thanks M8!
EDIT: It still isn't generating.
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
Also, in your file what is under:
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown
I've done everything, I just need to know what goes in "generateIn".
generateOre(NewOre.newOreBlock, world, random, x, z, 16, 16, 8, 1, 0, 16, ???);
Originally created by Tradeworld, I'm continuing it.
Mods that I think are cool (that also happen to all be dead):
Wait, found it, just needed net.minecraft.init.Blocks.
But then it crashed...???!?!?!?!?!??!
It crashed when I was making a world.
---- Minecraft Crash Report ----
// I just don't know what went wrong
Time: 15/07/16 8:55 AM
Description: Exception in server tick loop
java.lang.NullPointerException: at index 0
at com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:240)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:231)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:226)
at com.google.common.collect.ImmutableList.construct(ImmutableList.java:303)
at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258)
at cpw.mods.fml.common.registry.GameRegistry.computeSortedGeneratorList(GameRegistry.java:126)
at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:101)
at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:280)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1055)
at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:190)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:131)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:101)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:265)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:78)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:92)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_77, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 833282536 bytes (794 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' =
Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available
'D' = Disabled 'E' = Errored
UCHIJAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAA FML{7.10.99.99} [Forge Mod Loader] (forgeBin-1.7.10-10.13.4.1614-1.7.10.jar)
UCHIJAA Forge{10.13.4.1614} [Minecraft Forge] (forgeBin-1.7.10-10.13.4.1614-1.7.10.jar)
UCHIJAA pokeore{0.1} [Pokemon Ore Mod] (bin)
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
Originally created by Tradeworld, I'm continuing it.
Mods that I think are cool (that also happen to all be dead):
Here powerthegreat, I used this:
package com.metocolipson1.castlecrashers.blocks;
import java.util.Random;
import com.metocolipson1.castlecrashers.Main.CastleCrashers;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class FlawlessOreGen implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch(world.provider.dimensionId)
{
case 0:
generateSurface(world, random,chunkX*16,chunkZ*16);
}
}
private void generateSurface(World world, Random random, int BlockX, int BlockZ) {
for(int i =0; i<32; i++){
int Xcoord = BlockX + random.nextInt(16);
int Zcoord = BlockZ + random.nextInt(16);
int Ycoord = random.nextInt(26);
(new WorldGenMinable(CastleCrashers.FlawlessOre, 6)).generate(world, random, Xcoord, Ycoord, Zcoord);
}
}
}
There is one God. The creator of the heavens and the earth, who sent his son down to earth to save us... he loves you and he's pursuing you. Return to him.
...yeah, I'm one of THOSE guys.
"Some may say that you are a Christian because you were raised in a christian family, but even if my mother was a calculus teacher, no mater what she told me, two plus two would still equal four." - Dr. S. Jenkins
"I'm not a hater, I just know you're wrong. You need to realize that." - Unknown