Jump to content

[1.7.2] How to make my ore work


roblox0033

Recommended Posts

I need help with my Ore code I changed it to make it spawn more. I put the ore vain size from 4 - 8 and it spawns a lot of them and sometimes it generates 1 please help Here is my code

MoreEverythingWorldGenerator.java

 

 

package com.MoreEverything.Main;

 

import cpw.mods.fml.common.IWorldGenerator;

 

import com.MoreEverything.World.RubyOre;

import com.MoreEverything.World.TinOre;

 

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 java.util.Random;

 

/**

* mcmodtutorial

* <p/>

* TutorialWorldGenerator

*

* @Author Martijn Woudstra

*/

 

public class MoreEverythingWorldGenerator implements IWorldGenerator

{

    /**

    * Method to get what world we are generating.

    * For each case, we can have a different generator (0 = overworld, 1 = end, -1 = nether)

    * We multiply chunkX by 16, to change the 'chunknumber' to an actual coordinate.

    */

    @Override

    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)

    {

        switch(world.provider.dimensionId)

        {

            case 0: generateSurface(random, chunkX*16, chunkZ*16, world); break;

            case 1: generateEnd(random, chunkX*16, chunkZ*16, world); break;

            case -1: generateNether(random, chunkX*16, chunkZ*16, world); break;

            default:;

        }

    }

 

    /**

    * This is where you add your blocks to spawn for the overworld.

    * call addOreSpawn, and give these parameters:

    * Block: Block to generate

    * World: world var (see params)

    * Random: a random (see params)

    * ChunkX: The x coordinate of a chunk (see params)

    * ChunkZ: The z coordinate of a chunk (see params)

    * minVainSize: Minimal vain size

    * maxVainSize: The max vain size

    * chanceToSpawn: The chance to spawn. Dont make this extreme like 1000, keep it around at most 50, or your world wont load.

    * minY: Lowest point to spawn

    * maxY: Highest point to spawn.

    *

    * Nether and End go the same way

    */

    public void generateSurface(Random random, int chunkX, int chunkZ, World world)

    {

    addOreSpawn(RubyOre.RubyOre, world, random, chunkX, chunkZ, 4, 8, 10, 40, 120);

    addOreSpawn(TinOre.TinOre, world, random, chunkX, chunkZ, 6, 10, 15, 40, 150);

    }

 

    public void generateEnd(Random random, int chunkX, int chunkZ, World world)

    {

        //Add End Generation

    }

 

    public void generateNether(Random random, int chunkX, int chunkZ, World world)

    {

        //Add Nether Generation

    }

 

    /**

    *

    * This method adds our block to the world.

    * It randomizes the coordinates, and does that as many times, as defined in spawnChance.

    * Then it gives all the params to WorldGenMinable, which handles the replacing of the ores for us.

    *

    *@param block The block you want to spawn

    *@param world The world

    *@param blockXPos the blockXpos of a chunk

    *@param blockZPos the blockZpos of a chunk

    *@param maxVainSize max vain

    *@param chancesToSpawn the chance to spawn. Usually around 2

    *@param minY lowest point to spawn

    *@param maxY highest point to spawn

    */

    public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int minVainSize, int maxVainSize, int chancesToSpawn, int minY, int maxY )

    {

        for(int i = 0; i < chancesToSpawn; i++)

        {

            int posX = blockXPos + random.nextInt(16);

            int posY = minY + random.nextInt(maxY - minY);

            int posZ = blockZPos + random.nextInt(16);

            new WorldGenMinable(block, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.stone).generate(world, random, posX, posY, posZ);

        }

    }

 

public static void mainRegistry() {

// TODO Auto-generated method stub

 

}

}

 

 

RubyOre.java

 

 

package com.MoreEverything.World;

 

import com.MoreEverything.Main.MoreEverythingWorldGenerator;

import com.MoreEverything.block.RubyOreBlock;

import com.MoreEverything.lib.Strings;

 

import cpw.mods.fml.common.IWorldGenerator;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

 

public class RubyOre {

 

public static void mainRegistry(){

registerBlock();

initialiseBlock();

initialiseWorldGen();

}

 

public static void initialiseWorldGen(){

registerWorldGen(new MoreEverythingWorldGenerator(), 1);

}

 

public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProberblity){

GameRegistry.registerWorldGenerator(worldGenClass, weightedProberblity);

}

 

public static Block RubyOre;

 

public static void initialiseBlock(){

RubyOre = new RubyOreBlock(Material.ground).setBlockName("RubyOre").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName(Strings.MODID + ":RubyOre");

}

 

public static void registerBlock(){

GameRegistry.registerBlock(RubyOre, RubyOre.getUnlocalizedName());

}

}

 

 

 

TinOre.java

 

 

package com.MoreEverything.World;

 

import com.MoreEverything.Main.MoreEverythingWorldGenerator;

import com.MoreEverything.block.TinOreBlock;

import com.MoreEverything.lib.Strings;

 

import cpw.mods.fml.common.IWorldGenerator;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

 

public class TinOre {

 

public static void mainRegistry(){

initialiseBlock();

initialiseWorldGen();

registerBlock();

}

 

public static void initialiseWorldGen(){

registerWorldGen(new MoreEverythingWorldGenerator(), 2);

}

 

public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProberblity){

GameRegistry.registerWorldGenerator(worldGenClass, weightedProberblity);

}

 

public static Block TinOre;

 

public static void initialiseBlock(){

TinOre = new TinOreBlock(Material.ground).setBlockName("TinOre").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName(Strings.MODID + ":TinOre");

}

 

public static void registerBlock(){

GameRegistry.registerBlock(TinOre, TinOre.getUnlocalizedName());

}

}

 

 

 

MainRegistry.java

 

 

package com.MoreEverything.Main;

 

import com.MoreEverything.World.RubyOre;

import com.MoreEverything.World.TinOre;

import com.MoreEverything.Main.MoreEverythingWorldGenerator;

import com.MoreEverything.item.Ruby;

import com.MoreEverything.lib.Strings;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

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;

 

@Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version)

 

public class MainRegistry {

 

@SidedProxy(clientSide = "com.MoreEverything.Main.ClientProxy", serverSide = "com.MoreEverything.Main.ServerProxy")

public static ServerProxy proxy;

 

/**

* Loads before

* @param PreEvent

*/

 

@EventHandler

public static void PreLoad(FMLPreInitializationEvent PreEvent){

//Items

Ruby.mainRegistry();

 

//Ore

RubyOre.mainRegistry();

TinOre.mainRegistry();

 

//Proxy's

proxy.registerRenderThings();

 

//WorldOre

MoreEverythingWorldGenerator.mainRegistry();

}

 

 

/**

* Loads during

* @param event

*/

 

@EventHandler

public static void Load(FMLInitializationEvent event){

 

}

 

/**

* Loads after

* @param PostEvent

*/

 

@EventHandler

public static void PostLoad(FMLPostInitializationEvent PostEvent){

 

}

 

}

 

 

 

--------------------------------------------------

Also can you help me with my ore dropping random items I really like the idea and think it would be cool :)

Link to comment
Share on other sites

I have this same problem whenever i try to do ores. I just set it up with tje settings i want and leave it at that. All my attempts to figure it out end up at a dead end. Maybe you can figure it out and if so then i will be taking notes myself.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.