Jump to content

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


Recommended Posts

Posted

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

Posted

Yeah see the thing with random is, sometimes it just won't happen for a long time, or not in your observable frame.

 

Throw a SYSO on there with some coords, can watch it more easily then

Posted

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

Posted

Hey, I've been in much the same place!

I'm not sure if it matters but in the Withium ore class have a super of Material.Stone? I remembered that goofed up mine, but I'm no expert so..

If you need it I can provide my code.

Posted

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

Posted

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.

Posted

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Well, when I log in to the server, sometimes within an hour, sometimes within a minute, the server closes and informs me that there was a Ticking entity error. Below is the crash report
    • Try switching to Windowed or Borderless Window mode in Minecraft. These modes make it easier for the recorder to capture gameplay, as it still has access to the display without the game taking up all of the graphics resources.
    • This forum is for Forge, not NeoForge. Please go to them for support.
    • Forge version: 55.0.0 Minecraft version: 1.21.5 Downloads: As this is the start of a new version, it is recommended that you check the downloads page and use the latest version to receive any bug fixes. Downloads page Intro: Good evening! Today, we have released our initial build of Forge 55.0 for Minecraft 1.21.5. 1.21.5 is the newest member of the 1.21 family of versions, which was released yesterday on March 25, 2025. As a reminder, the first minor (X.0) of a Forge version is a beta. Forge betas are marked as such on the bottom left of the title screen and are candidates for any breaking changes. Additionally, there are a couple of important things to note about this update, which I've made sure to mention in this post as well. Feel free to chat with us about bugs or these implementation changes on GitHub and in our Discord server. As always, we will continue to keep all versions of 1.21 and 1.20 in active support as covered by our tiered support policy. Cheers, happy modding, and good luck porting! Rendering Refactor For those who tuned in to Minecraft Live on March 22, 2025, you may already know that Mojang have announced their intention to bring their new Vibrant Visuals overhaul to Java in the future. They've taken the first steps toward this by refactoring how rendering pipelines and render types are handled internally. This has, in turn, made many of Forge's rendering APIs that have existed for years obsolete, as they (for the most part) can be done directly in vanilla. If there was a rendering API that was provided by Forge which you believe should be re-implemented, we're happy to discuss on GitHub through an issue or a pull request. Deprecation of weapon-like ToolActions In 1.21.5, Minecraft added new data components for defining the characteristics of weapons in data. This includes attack speed, block tags which define efficient blocks, and more. As such, we will begin marking our ToolActions solution for this as deprecated. ToolActions were originally added to address the problem of creating modded tools that needed to perform the same actions as vanilla tools. There are still a few tool actions that will continue to be used, such as the shears tool action for example. There are some existing Forge tool actions that are currently obsolete and have no effect given the way the new data components are implemented. We will continue to work on these deprecations and invite you to chat with us on GitHub or Discord if you have any questions.
    • In summary, a full mod to adjust mining progress in such a specific way does not yet exist in its exact form, but it is possible to find mods that change certain aspects of progression (e.g. "Harder Ores").
  • Topics

×
×
  • Create New...

Important Information

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