Hello,
I have recently began creating an ore mod I call Minology. I have tried a few tutorials on making overworld ore generation, but for some reason, it doesn't end up working for me. I have not received any crashes, but my ore will not generate. Don't ask - I have created a new world. I'll post some code, if it's of any help.
package pikadex.oremod;
import java.util.Random;
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 WorldGeneratorCoreOres 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);
}
/** case -1: {
generateNether(world, random, chunkX * 16, chunkZ * 16);
}
case 1: {
generateEnd(world, random, chunkX * 16, chunkZ * 16);
}
*/
}
}
private void generateSurface(World world, Random random, int BlockX, int BlockZ) {
/**
* Copper Ore
*/
for(int i = 0; i < 20; i++) {
int xCoord = BlockX + random.nextInt(16);
int zCoord = BlockZ + random.nextInt(16);
int yCoord = random.nextInt(96);
(new WorldGenMinable(PikadexOres.coreOre.blockID, 0, 32)).generate(world, random, xCoord, yCoord, zCoord);
}
/**
* Vintium Ore
*/
for(int i = 0; i < 10; i++) {
int xCoord = BlockX + random.nextInt(16);
int zCoord = BlockZ + random.nextInt(16);
int yCoord = random.nextInt(48);
(new WorldGenMinable(PikadexOres.coreOre.blockID, 1, 15)).generate(world, random, xCoord, yCoord, zCoord);
}
/**
* Mechanite Ore
*/
for(int i = 0; i < 1; i++) {
int xCoord = BlockX + random.nextInt(16);
int zCoord = BlockZ + random.nextInt(16);
int yCoord = random.nextInt(8);
(new WorldGenMinable(PikadexOres.coreOre.blockID, 2, 6)).generate(world, random, xCoord, yCoord, zCoord);
}
/**
* Ambrite Ore
*/
for(int i = 0; i < 15; i++) {
int xCoord = BlockX + random.nextInt(16);
int zCoord = BlockZ + random.nextInt(16);
int yCoord = random.nextInt(64);
(new WorldGenMinable(PikadexOres.coreOre.blockID, 3, 20)).generate(world, random, xCoord, yCoord, zCoord);
}
}
}
package pikadex.oremod;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMultiTextureTile;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = PikadexOres.modid, name = "Minology", version = "Alpha 1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class PikadexOres {
public static final String modid = "pikadexOres";
// Creative Tab Registration
public static CreativeTabs tabOre = new CreativeTabs("tabOre") {
public ItemStack getIconItemStack() {
return new ItemStack(coreOre, 1, 0);
}
};
public static CreativeTabs tabOreBlock = new CreativeTabs("tabOreBlock") {
public ItemStack getIconItemStack() {
return new ItemStack(coreOreBlock, 1, 1);
}
};
public static CreativeTabs tabMaterials = new CreativeTabs("tabMaterials") {
public ItemStack getIconItemStack() {
return new ItemStack(mechaniteIngot, 1, 0);
}
};
// Block Registration
public static final Block coreOre = new BlockCoreOre(700, Material.rock).setUnlocalizedName("coreOre")
.setStepSound(Block.soundStoneFootstep)
.setHardness(3.0F)
.setResistance(5.0F);
public static final Block coreOreBlock = new BlockCoreOreBlock(701, Material.iron).setUnlocalizedName("coreOreBlock")
.setStepSound(Block.soundMetalFootstep)
.setHardness(3.0F)
.setResistance(5.0F);
public static final Block mechaniteBlock = new BlockMechanite(702, Material.iron).setUnlocalizedName("mechaniteBlock")
.setStepSound(Block.soundMetalFootstep)
.setHardness(3.0F)
.setResistance(5.0F);
// Item Registration
public static final Item copperIngot = new IngotCopper(6503, 64, tabMaterials, "copperIngot");
public static final Item vintiumIngot = new IngotVintium(6504, 64, tabMaterials, "vintiumIngot");
public static final Item mechaniteRaw = new MechaniteRaw(6505, 64, tabMaterials, "mechaniteRaw");
public static final Item mechaniteIngot = new IngotMechanite(6506, 64, tabMaterials, "mechaniteIngot");
public static final Item ambrite = new ItemAmbrite(6507, 64, tabMaterials, "ambrite");
// Config Integer Registration
int coreOreIDs;
int copperIngotID;
int vintiumIngotID;
int mechaniteRawID;
int mechaniteIngotID;
int ambriteID;
// Instance
@Instance("PikadexOres")
public static PikadexOres instance;
// SidedProxy
@SidedProxy(clientSide="pikadex.oremod.client.ClientProxy", serverSide="pikadex.oremod.CommonProxy")
public static CommonProxy proxy;
// Configuration
@PreInit
public void preload(FMLPreInitializationEvent event) {
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
coreOreIDs = config.get("Block IDs", "Core Mod Ore IDs", 700).getInt();
copperIngotID = config.get("Item IDs", "Copper Bar ID", 6503).getInt();
vintiumIngotID = config.get("Item IDs", "Vintium Bar ID", 6504).getInt();
mechaniteRawID = config.get("Item IDs", "Raw Mechanite ID", 6505).getInt();
mechaniteIngotID = config.get("Item IDs", "Powered Mechanite ID", 6506).getInt();
ambriteID = config.get("Item IDs", "Ambrite ID", 6507).getInt();
config.save();
}
// Call Functions
@Init
public void load(FMLInitializationEvent event) {
proxy.registerRenders();
itemBlockRegistry();
languageRegistry();
worldGeneration();
blockHarvest();
toolHarvest();
CoreRecipe.recipe();
}
@PostInit
public void postload(FMLPostInitializationEvent event) {
}
// Materials
// Game Registry
public void itemBlockRegistry(){
GameRegistry.registerBlock(coreOre, ItemBlockCoreOre.class, "coreOre");
GameRegistry.registerItem(copperIngot, "copperIngot");
GameRegistry.registerItem(vintiumIngot, "vintiumIngot");
GameRegistry.registerItem(mechaniteRaw, "mechaniteRaw");
GameRegistry.registerItem(mechaniteIngot, "mechaniteIngot");
GameRegistry.registerItem(ambrite, "ambrite");
GameRegistry.registerBlock(coreOreBlock, ItemBlockCoreOreBlock.class, "coreOreBlock");
GameRegistry.registerBlock(mechaniteBlock, "mechaniteBlock");
}
// Language Registry
public void languageRegistry() {
// Items/Blocks
LanguageRegistry.addName(new ItemStack(coreOre, 1, 0), "Copper Ore");
LanguageRegistry.addName(new ItemStack(coreOre, 1, 1), "Vintium Ore");
LanguageRegistry.addName(new ItemStack(coreOre, 1, 2), "Mechanite Ore");
LanguageRegistry.addName(new ItemStack(coreOre, 1, 3), "Ambrite Ore");
LanguageRegistry.addName(copperIngot, "Copper Bar");
LanguageRegistry.addName(vintiumIngot, "Vintium Bar");
LanguageRegistry.addName(mechaniteRaw, "Raw Mechanite");
LanguageRegistry.addName(mechaniteIngot, "Powered Mechanite");
LanguageRegistry.addName(ambrite, "Ambrite");
LanguageRegistry.addName(new ItemStack(coreOreBlock, 1, 0), "Block of Copper");
LanguageRegistry.addName(new ItemStack(coreOreBlock, 1, 1), "Block of Vintium");
LanguageRegistry.addName(new ItemStack(coreOreBlock, 1, 2), "Block of Raw Mechanite");
LanguageRegistry.addName(new ItemStack(coreOreBlock, 1, 3), "Block of Ambrite");
LanguageRegistry.addName(mechaniteBlock, "Block of Powered Mechanite");
// Creative Tabs
LanguageRegistry.instance().addStringLocalization("itemGroup.tabOre", "Minology: Ores");
LanguageRegistry.instance().addStringLocalization("itemGroup.tabOreBlock", "Minology: Ore Blocks");
LanguageRegistry.instance().addStringLocalization("itemGroup.tabMaterials", "Minology: Materials");
}
// World Generation
public void worldGeneration(){
GameRegistry.registerWorldGenerator(new WorldGeneratorCoreOres());
}
// Block Harvest Level
public void blockHarvest() {
MinecraftForge.setBlockHarvestLevel(coreOre, 0, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(coreOre, 1, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(coreOre, 2, "pickaxe", 3);
MinecraftForge.setBlockHarvestLevel(coreOre, 3, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(coreOreBlock, "pickaxe", 2);
}
// Tool Harvest Level
public void toolHarvest(){
}
}
Again, any sort of help or at least suggestion would be of much help.
GameRegistry.registerWorldGenerator(new WorldGeneratorCoreOres());
in your @Init method instead of a method by itself! Hope this helps!
don't forge to click the green arrow at the bottom of the posts that helped you!
-sorash67 || Skorpio
Thanks, but, as perambulating panda pointed out, the way I did it makes the registry essentially in the Init method. I appreciate that you tried to help, though!
Anyway, not sure if this will help but try changing BlockX and BlockZ to chunkX and chunkZ, as they're the parameters already used in the overall generate method.
Thanks, but that did no good. It was a good suggestion, yet it did nothing. I do appreciate you trying to help!
I have been doing the same thing this week and here is my code. I have had no issues with ore generation and the only thing I see different is the following.
(new WorldGenMinable(TopazMod.topazore.blockID, 12)
12 being the frequency of the ore.
Hope this helps!
package ArsenicLullaby.Test;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneratorSCMowns implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
It essentially is in the @Init method, as he's registered the method containing the registerWorldGenerator in the @Init method - it's just a way of making the code more clear, so all the registry isn't in one big method.
Thanks, but, as perambulating panda pointed out, the way I did it makes the registry essentially in the Init method. I appreciate that you tried to help, though!
haha, my bad, you guys are correct! i feel like such a noob for saying that! x)
I have been doing the same thing this week and here is my code. I have had no issues with ore generation and the only thing I see different is the following.
(new WorldGenMinable(TopazMod.topazore.blockID, 12)
12 being the frequency of the ore.
Hope this helps!
package ArsenicLullaby.Test;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneratorSCMowns implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
I found your bug. Took me a little time but I narrowed it down.
(new WorldGenMinable(PikadexOres.coreOre.blockID, 0, 32)).generate(world, random, xCoord, yCoord, zCoord);
In each line where you invoke WorldGenMinable's constructor, you need to fix the version of it that you're using. The 3-parameter version accepts a block ID, the number of blocks to generate, and the block ID to be replaced. Based on your code, I think you believed the parameters were block ID, metadata, and number of blocks to generate. In this case, you generate zero ores.
Change to the 4-parameter constructor by adding an extra parameter: Block.stone.blockID
(new WorldGenMinable(PikadexOres.coreOre.blockID, 0, 32, Block.stone.blockID)).generate(world, random, xCoord, yCoord, zCoord);
That will have the desired effect.
In the future, if it's not too much trouble, please include all the files required to compile your code. Even if it's just a link to a download or a code repository. I had to copy classes from another project to replace missing files and rewrote a few from scratch to match your code. It would make helping you much easier.
I found your bug. Took me a little time but I narrowed it down.
(new WorldGenMinable(PikadexOres.coreOre.blockID, 0, 32)).generate(world, random, xCoord, yCoord, zCoord);
In each line where you invoke WorldGenMinable's constructor, you need to fix the version of it that you're using. The 3 parameter version accepts a block ID, the number of blocks to generate, and the block ID to be replaced. Based on your code, I think you believed the parameters were block ID, metadata, and number of blocks to generate. In this case, you generate zero ores.
Change to the 4 parameter constructor by adding an extra parameter: Block.stone.blockID
(new WorldGenMinable(PikadexOres.coreOre.blockID, 0, 32, Block.stone.blockID)).generate(world, random, xCoord, yCoord, zCoord);
In the future, if it's not too much trouble, please include all the files required to compile your code. I had to copy classes from another project to replace missing files, or rewrote a few from scratch to match your code. It would make helping you much easier.
Well, I gave all the code that could have been a problem. I'm not sure why you would need more code.
Anyways, thanks for the help! I'll edit the post so that others who might be having this problem can get a solution.
Well, I gave all the code that could have been a problem. I'm not sure why you would need more code.
Sometimes it's easiest to debug your problem if we can compile and run your code to perform checks. I couldn't compile your code off the bat because of references to other classes, such as BlockCoreOre, CommonProxxy, etc.
(Thanks to SenseiKiwi for the Solution)
Hello,
I have recently began creating an ore mod I call Minology. I have tried a few tutorials on making overworld ore generation, but for some reason, it doesn't end up working for me. I have not received any crashes, but my ore will not generate. Don't ask - I have created a new world. I'll post some code, if it's of any help.
Again, any sort of help or at least suggestion would be of much help.
Thanks.
- Pikadex
GameRegistry.registerWorldGenerator(new WorldGeneratorCoreOres());
in your @Init method instead of a method by itself! Hope this helps!
don't forge to click the green arrow at the bottom of the posts that helped you!
-sorash67 || Skorpio
http://www.minecraftforum.net/topic/1839245-1615-forge-sspsmp-skorpios-notonlymoreores-mod-the-crossbow-update/
Thanks, but, as perambulating panda pointed out, the way I did it makes the registry essentially in the Init method. I appreciate that you tried to help, though!
Thanks, but that did no good. It was a good suggestion, yet it did nothing. I do appreciate you trying to help!
(new WorldGenMinable(TopazMod.topazore.blockID, 12)
12 being the frequency of the ore.
Hope this helps!
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneratorSCMowns implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
// TODO Auto-generated method stub
switch(world.provider.dimensionId){
//case -1: generateNether(world, random,chunkX*16,chunkZ*16);
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<10;i++){
int Xcoord = BlockX + random.nextInt(16);
int Zcoord = BlockZ + random.nextInt(16);
int Ycoord = random.nextInt(74);
(new WorldGenMinable(TopazMod.topazore.blockID, 12)).generate(world, random, Xcoord, Ycoord, Zcoord);
}
for(int i =0; i<10;i++){
int Xcoord = BlockX + random.nextInt(16);
int Zcoord = BlockZ + random.nextInt(16);
int Ycoord = random.nextInt(74);
(new WorldGenMinable(TopazMod.jadeore.blockID, 12)).generate(world, random, Xcoord, Ycoord, Zcoord);
}}}
haha, my bad, you guys are correct! i feel like such a noob for saying that! x)
-sorash67 || Skorpio
http://www.minecraftforum.net/topic/1839245-1615-forge-sspsmp-skorpios-notonlymoreores-mod-the-crossbow-update/
Thanks, but the second int, between what is "TopazMod.jadeore.blockID" and "12" for you is the metadata. I need that in order for it to work properly.
In each line where you invoke WorldGenMinable's constructor, you need to fix the version of it that you're using. The 3-parameter version accepts a block ID, the number of blocks to generate, and the block ID to be replaced. Based on your code, I think you believed the parameters were block ID, metadata, and number of blocks to generate. In this case, you generate zero ores.
Change to the 4-parameter constructor by adding an extra parameter: Block.stone.blockID
That will have the desired effect.
In the future, if it's not too much trouble, please include all the files required to compile your code. Even if it's just a link to a download or a code repository. I had to copy classes from another project to replace missing files and rewrote a few from scratch to match your code. It would make helping you much easier.
I was wondering what it meant by target. Thanks!
Well, I gave all the code that could have been a problem. I'm not sure why you would need more code.
Anyways, thanks for the help! I'll edit the post so that others who might be having this problem can get a solution.
Sometimes it's easiest to debug your problem if we can compile and run your code to perform checks. I couldn't compile your code off the bat because of references to other classes, such as BlockCoreOre, CommonProxxy, etc.
So yes, just a suggestion for the future.