So, for a clarification to my post I present the following:
The mod I am creating is running under the name MagiCraft. The primary mod file is thus named MagiCraft.java:
package MagiCraft;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ForgeHooks;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenDesert;
import net.minecraft.world.gen.feature.WorldGenMinable;
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="Generic", name="Generic", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MagiCraft
{
//Items
public static final Item SaltItem = new ItemSalt(500);
//Blocks
//Ores
public static final Block rocksaltBlock = (new BlockRockSalt(161, 0));
//Crafting
//Smelting
//Graphics
public void updateIcons(IconRegister iconRegister)
{
iconIndex = iconRegister.registerIcon("MagiCraft:Salt");
iconIndex = iconRegister.registerIcon("MagiCraft:RockSalt");
}
// The instance of your mod that Forge uses.
@Instance("MagiCraft")
public static MagiCraft instance;
// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="MagiCraft.client.ClientProxy", serverSide="MagiCraft.CommonProxy")
public static CommonProxy proxy;
private static BiomeGenBase BiomeGenDesert;
@PreInit
public void preInit(FMLPreInitializationEvent event) {
// Stub Method
}
@Init
public void load(FMLInitializationEvent event)
{
LanguageRegistry.addName(SaltItem, "Salt");
LanguageRegistry.addName(rocksaltBlock, "Rock Salt");
MinecraftForge.setBlockHarvestLevel(rocksaltBlock, "pickaxe", 1);
GameRegistry.registerBlock(rocksaltBlock, "BlockRockSalt");
proxy.registerRenderers();
GameRegistry.registerWorldGenerator(new MagiCraftGenerator());
//Replacing Desert for Further Additions
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
// Stub Method
}
}
As you can see this uses the world gen file MagiCraftGenerator.java.
While generating the ore randomly within game it looked as such:
package MagiCraft;
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 MagiCraftGenerator 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;
}
}
private void generateEnd(World world, Random random, int i, int j)
{
}
private void generateSurface(World world, Random random, int i, int j)
{
Random randomGenerator = random;
for (i = 0; i < 15; i++)
{
int randPosX = i + randomGenerator.nextInt(16);
int randPosY = random.nextInt(65);
int randPosZ = j + randomGenerator.nextInt(16);
(new WorldGenMinable(MagiCraft.rocksaltBlock.blockID, 10)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
private void generateNether(World world, Random random, int i, int j)
{
}
}
Then ofcourse you have the block and item codes:
BLOCK
package MagiCraft;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.world.World;
import net.minecraft.block.material.Material;
public class BlockRockSalt extends BlockOre
{
public BlockRockSalt(int id, int texture)
{
super(id);
setHardness(0.8F); // Same as Sandstone
setResistance(5.0F);
setStepSound(Block.soundStoneFootstep);
setUnlocalizedName("Rock Salt");
setCreativeTab(CreativeTabs.tabBlock);
}
public String getTextureFile()
{
return CommonProxy.BLOCK_PNG;
}
public int idDropped(int par1, Random random, int par2)
{
return MagiCraft.SaltItem.itemID;
}
public int quantityDropped(Random par1Random)
{
return 4 + par1Random.nextInt(2);
}
public int quantityDroppedWithBonus(int par1, Random par2Random)
{
return this.quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
}
}
Item
package MagiCraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class ItemSalt extends Item
{
public ItemSalt(int id)
{
super(id);
// TODO Auto-generated constructor stub
// Constructor Configuration
setMaxStackSize(64);
setCreativeTab(CreativeTabs.tabMisc);
setUnlocalizedName("Salt");
}
public String getTextureFile()
{
return CommonProxy.ITEMS_PNG;
}
}
To the Attempted Desert Biome Generation
After much research I decided that it was probably easiest to override the BiomeGenDesert.java by creating my own and redirecting with the following code:
private static final BiomeGenBase BiomGenDesert = null;
public void load(FMLInitializationEvent event)
{
LanguageRegistry.addName(SaltItem, "Salt");
LanguageRegistry.addName(rocksaltBlock, "Rock Salt");
MinecraftForge.setBlockHarvestLevel(rocksaltBlock, "pickaxe", 1);
GameRegistry.registerBlock(rocksaltBlock, "BlockRockSalt");
proxy.registerRenderers();
GameRegistry.registerWorldGenerator(new MagiCraftGenerator());
//Replacing Desert for Further Additions
GameRegistry.removeBiome(BiomeGenBase.desert);
GameRegistry.addBiome(MagiCraft.BiomGenDesert);
}
BiomeGenDesert.java looks like:
package MagiCraft;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenDesertWells;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.biome.BiomeGenBase;
import MagiCraft.MagiCraftGenerator;
public class BiomeGenDesert extends BiomeGenBase
{
public BiomeGenDesert(int par1)
{
super(par1);
this.spawnableCreatureList.clear();
this.topBlock = (byte)Block.sand.blockID;
this.fillerBlock = (byte)Block.sand.blockID;
this.theBiomeDecorator.treesPerChunk = -999;
this.theBiomeDecorator.deadBushPerChunk = 2;
this.theBiomeDecorator.reedsPerChunk = 50;
this.theBiomeDecorator.cactiPerChunk = 10;
}
public void decorate(World par1World, Random par2Random, int par3, int par4)
{
super.decorate(par1World, par2Random, par3, par4);
int o = 0 + par2Random.nextInt(6);
int p;
int q1;
int r1;
if (par2Random.nextInt(1000) == 0)
{
int k = par3 + par2Random.nextInt(16) + 8;
int l = par4 + par2Random.nextInt(16) + 8;
WorldGenDesertWells worldgendesertwells = new WorldGenDesertWells();
worldgendesertwells.generate(par1World, par2Random, k, par1World.getHeightValue(k, l) + 1, l);
}
for (p = 0; p < o; ++p)
{
r1 = par3 + par2Random.nextInt(16);
q1 = par2Random.nextInt(28) + 4;
int o1 = par4 + par2Random.nextInt(16);
int p1 = par1World.getBlockId(q1, r1, o1);
if (p1 == Block.sandStone.blockID)
{
par1World.setBlock(o1, r1, 01, MagiCraft.rocksaltBlock.blockID, 0, 2);
}
}
}
}
I've attempted to combine the coding from BiomeGenBase with the Emerald Ore coding from BiomeGenHills.
I hope this helps you to see what I was trying to do,
Dan.