public class ExampleOre 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(random, chunkX * 16, chunkZ * 16, world);
break;
case 0:
generateOverworld(random, chunkX * 16, chunkZ * 16, world);
break;
case 1:
generateEnd(random, chunkX * 16, chunkZ * 16, world);
break;
}
}
private void addOre(Block block, Block blockspawn, Random random, World world, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int spawnChance, int minY, int maxY){
for(int i = 0; i < spawnChance; i++){
int defaultChunkSize = 16;
int xPos = blockXPos + random.nextInt(defaultChunkSize);
int yPos = minY + random.nextInt(maxY - minY);
int zPos = blockZPos + random.nextInt(defaultChunkSize);
new WorldGenMinable(block, maxVeinSize).generate(world, random, xPos, yPos, zPos);
}
}
private void generateEnd(Random random, int chunkX, int chunkZ, World world) {
}
private void generateOverworld(Random random, int chunkX, int chunkZ, World world) {
}
private void generateNether(Random random, int chunkX, int chunkZ, World world) {
addOre(ModBlocks.ExampleOre, Blocks.netherrack, random, world, chunkX, chunkZ, 16, 16, 5 + random.nextInt(6), 11, 0, 50);
If you set a breakpoint in the ExampleOre#generate method and launch Minecraft in debug mode, is the breakpoint ever reached? Keep in mind that worldgen only happens in new chunks, so you might need to travel a large distance to trigger it.
If the breakpoint is reached, you can log the position of each vein you generate just after calling WorldGenMinable#generate in addOre. You can either use FMLLog (or a wrapper around it) or plain old System.out.printf/println calls.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Simply call any of the level methods (i.e. all methods except log) with a String message and 0 or more format arguments. It will format the message with the arguments using the equivalent of String.format and print it to the log.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Logger's individual level methods like Logger.info(message, ...) are basically equivalent to calling System.out.printf(message, ...) except they print each message on a new line with some extra formatting (such as the timestamp and level).
The level isn't that important, it's just an indication of the message's purpose (e.g. general info, debugging, error notification) and determines whether it gets printed to the console or not (DEBUG and TRACE don't get printed to the console, but all levels get printed to the log file).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I'm having trouble spawning an ore in the nether. I do not see it anywhere and I'm not sure what the problem is. Here is what I put:
addOre(ModBlocks.ExampleOre, Blocks.netherrack, random, world, chunkX, chunkZ, 16, 16, 5 + random.nextInt(6), 11, 0, 50);
Could someone help pls?
Post your entire class, plus where you are registering the world generator too.
package com.example.world;
import java.util.Random;
import com.example.blocks.ModBlocks;
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 cpw.mods.fml.common.IWorldGenerator;
public class ExampleOre 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(random, chunkX * 16, chunkZ * 16, world);
break;
case 0:
generateOverworld(random, chunkX * 16, chunkZ * 16, world);
break;
case 1:
generateEnd(random, chunkX * 16, chunkZ * 16, world);
break;
}
}
private void addOre(Block block, Block blockspawn, Random random, World world, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int spawnChance, int minY, int maxY){
for(int i = 0; i < spawnChance; i++){
int defaultChunkSize = 16;
int xPos = blockXPos + random.nextInt(defaultChunkSize);
int yPos = minY + random.nextInt(maxY - minY);
int zPos = blockZPos + random.nextInt(defaultChunkSize);
new WorldGenMinable(block, maxVeinSize).generate(world, random, xPos, yPos, zPos);
}
}
private void generateEnd(Random random, int chunkX, int chunkZ, World world) {
}
private void generateOverworld(Random random, int chunkX, int chunkZ, World world) {
}
private void generateNether(Random random, int chunkX, int chunkZ, World world) {
addOre(ModBlocks.ExampleOre, Blocks.netherrack, random, world, chunkX, chunkZ, 16, 16, 5 + random.nextInt(6), 11, 0, 50);
}
}
Here is another class I have in the same package:
package com.example.world;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModWorld {
public static void mainRegistry(){
initializeWorldGen();
}
public static void initializeWorldGen(){
registerWorldGen(new ExampleOre(), 2);
}
public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProbability){
GameRegistry.registerWorldGenerator(worldGenClass, weightedProbability);
}
}
In the main registry, I registered the class above like this:
@Instance(Strings.MODID)
public static MainRegistry modInstance;
ExampleOre eventWorldGen = new ExampleOre();
@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent) {
ModBlocks.mainRegistry();
ModWorld.mainRegistry();
I think this is everything that I did for this particular situation.
If you set a breakpoint in the ExampleOre#generate method and launch Minecraft in debug mode, is the breakpoint ever reached? Keep in mind that worldgen only happens in new chunks, so you might need to travel a large distance to trigger it.
If the breakpoint is reached, you can log the position of each vein you generate just after calling WorldGenMinable#generate in addOre. You can either use FMLLog (or a wrapper around it) or plain old System.out.printf/println calls.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Can you show me an example of using ForgeModLoaderLog? I haven't used it before, so I don't know exactly what I need to do.
Here.
This is my wrapper around FMLLog.
Simply call any of the level methods (i.e. all methods except log) with a String message and 0 or more format arguments. It will format the message with the arguments using the equivalent of String.format and print it to the log.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
This is a bit confusing.
What is? Logger/FMLLog?
Logger's individual level methods like Logger.info(message, ...) are basically equivalent to calling System.out.printf(message, ...) except they print each message on a new line with some extra formatting (such as the timestamp and level).
The level isn't that important, it's just an indication of the message's purpose (e.g. general info, debugging, error notification) and determines whether it gets printed to the console or not (DEBUG and TRACE don't get printed to the console, but all levels get printed to the log file).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I understand what you are saying. I see now that it doesn't matter which level method that I use, which was what I was confused on earlier.