Jump to content

[SOLVED][1.7.10] My first attempt with ore generation...


DeadEnd78

Recommended Posts

Hi fellow forgers (ha ha, see what I did there?) Anyway, I recently started coding with forge and made my first attempt at ore generation (I was following a tutorial for guidance.) It failed. The ore does not generate, even with the obscure numbers I have set. Any help is appreciated.

 

 

Below is my ore generation class.

 

 

package com.DeadEnd78.block;


import java.util.Random;


import com.DeadEnd78.Main.MainRegistry;


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 withiumOreGeneration implements IWorldGenerator {


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

	switch(world.provider.dimensionId) {
	case -1:
		generateInNether(world, random, chunkX*16, chunkZ*16);
		break;
	case 0:
		generateInOverworld(world, random, chunkX*16, chunkZ*16);
		break;
	case 1:
		generateInEnd(world, random, chunkX*16, chunkZ*16);
	}

}


private void generateInEnd(World world, Random random, int x, int z) {
	// TODO Auto-generated method stub

}


private void generateInOverworld(World world, Random random, int x, int z) {
	// TODO Auto-generated method stub
	for (int i = 0; i < 25; i++) { // means set i = 0, then if its less than 25 keep adding one to i
		int chunkX = x + random.nextInt(16);
		int chunkY = random.nextInt(256);
		int chunkZ = z + random.nextInt(16);


		new WorldGenMinable(MainRegistry.withiumOre, 50).generate(world, random, chunkX, chunkY, chunkZ);


	}
}


private void generateInNether(World world, Random random, int x, int z) {
	// TODO Auto-generated method stub

}


}

 

 

Next is my main registry (I know it is messy)


package com.DeadEnd78.Main;


import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;


import com.DeadEnd78.lib.RefStrings;


import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
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.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.DeadEnd78.block.*;
@Mod (modid = RefStrings.MODID , name = RefStrings.NAME , version = RefStrings.VERSION)
public class MainRegistry {
@SidedProxy(clientSide = RefStrings.CLIENTSIDE, serverSide = RefStrings.SERVERSIDE)
    public static ServerProxy proxy;
@Instance(value="growaspell")
public static MainRegistry instance;
public static CreativeTabs gasTab = new CreativeTabs("Grow a Spell"){
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem(){
	return Items.stick;
}

};
public static withiumOreGeneration withiumWorldGen;
public static Block withiumOre;
public static Item withiumOreItem;

@EventHandler 
public static void PreLoad(FMLPreInitializationEvent PreEvent) {
	proxy.registerRenderInfo();

	withiumOre = new withiumOreBlock(Material.rock).setBlockName("WithiumOre").setCreativeTab(MainRegistry.gasTab).setBlockTextureName("growaspell:withiumOre");
	withiumOreItem = new withiumOreItem().setUnlocalizedName("WithiumShard").setCreativeTab(MainRegistry.gasTab).setTextureName("");
	withiumWorldGen = new withiumOreGeneration();
	GameRegistry.registerItem(withiumOreItem, "Withium Shard");
	GameRegistry.registerBlock(withiumOre, "Withium Ore");
	GameRegistry.registerWorldGenerator(withiumWorldGen, 1);
}

Much love, Dead <3

"I am a modder.  I just need tutorials for most of my work." ~ Losers, 2014

Link to comment
Share on other sites

How do you know it doesn't generate? Where have you looked?

Everywhere.

I added a System.out.println("Spawned at: " + world + " " + chunkX + " " + chunkY + " " + chunkZ);

It prints out many times that the ore has spawned, but when I check any of the coordinates it does not show the ore.

 

Pleeeease help! I really don't know what i am doing wrong!!

"I am a modder.  I just need tutorials for most of my work." ~ Losers, 2014

Link to comment
Share on other sites

Here's your problem:

GameRegistry.registerWorldGenerator(withiumWorldGen, 1);

1 is the generation weight. The higher the number, the later it generates. Your ore is generating, then being overridden with other generation like stone. I haven't been able to find the vanilla generation weights, but I have found that setting it to 128 seems to work good.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Link to comment
Share on other sites

I have found that setting it to 128 seems to work good.

Yikes! That's some top-priority generation!!

 

Instead of using an absurd weight, try registering your generator in your mod's initialization stage instead of your pre-initialization stage. That way your WorldGen gets registered AFTER the vanilla generators and is weighted only against other mods' generators who have done the same.

Link to comment
Share on other sites

I have found that setting it to 128 seems to work good.

Yikes! That's some top-priority generation!!

 

Instead of using an absurd weight, try registering your generator in your mod's initialization stage instead of your pre-initialization stage. That way your WorldGen gets registered AFTER the vanilla generators and is weighted only against other mods' generators who have done the same.

Here's your problem:

GameRegistry.registerWorldGenerator(withiumWorldGen, 1);

1 is the generation weight. The higher the number, the later it generates. Your ore is generating, then being overridden with other generation like stone. I haven't been able to find the vanilla generation weights, but I have found that setting it to 128 seems to work good.

 

Thank you guys, It worked.

 

DA REAL MVP(S)!!

"I am a modder.  I just need tutorials for most of my work." ~ Losers, 2014

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.