I'm newish to Minecraft coding and how the game works but I have some knowledge on other Java programs and mods. I recently tried to spawn an ore (called money ore) but it doesn't spawn.
Could someone please check my code for any errors?
package com.landuros.world;
import java.util.Random;
import com.landuros.blocks.MBlocks;
import cpw.mods.fml.common.IWorldGenerator;
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;
public class MOre 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 posX, int posZ, int minY, int maxY, int minVein, int maxVein, int spawnChance)
{
for(int i = 0; i < spawnChance; i++)
{
int defaultChunkSize = 16;
int xPos = posX + random.nextInt(defaultChunkSize);
int yPos = minY + random.nextInt(maxY - minY);
int zPos = posZ + random.nextInt(defaultChunkSize);
new WorldGenMinable(block, (minVein + random.nextInt(maxVein - minVein)), blockspawn).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)
{
addOre(MBlocks.MoneyOre, Blocks.iron_ore, random, world, chunkX, chunkZ, 0, 150, 10, 50, 20);
}
private void generateNether(Random random, int chunkX, int chunkZ, World world)
{
}
}
I have another .java file that registers the World Gen and calls upon GameRegistry, and I don't think that's the problem. Also, could someone please confirm what the integers in this line of code represent?
addOre(MBlocks.MoneyOre, Blocks.iron_ore, random, world, chunkX, chunkZ, 0, 150, 10, 50, 20);
I'm pretty sure the first two are the minY and maxY values, and 50 is the spawn rate.
Thanks