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
  On 8/20/2014 at 8:04 AM, sequituri said:

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
  On 8/21/2014 at 4:11 AM, F1repl4ce said:

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
  On 8/21/2014 at 7:52 AM, TehSeph said:

  Quote

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.

  Quote

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

    • Make a test with another Launcher like the Curseforge Launcher, MultiMC or AT Launcher
    • can anyone help me i am opening forge and add modpacks and then it says unable to update native luancher and i redownlaod java and the luancher it self?
    • The problem occurs also in 1.20.1 Forge, but with an "Error executing task on client" instead. I have "Sinytra Connector" installed. On 1.21.5 Fabric, there is no problem. When this happens, the chat message before the death screen appears gets sent, with an extra dash added.
    • Well, as usual, it was user error. Naming mismatch in sounds.json.  Please delete this post if you find it necessary. 
    • Hello Forge community.  I'm running into an issue with a mod I'm working on.  To preface, I can call /playsound modId:name music @a and I can hear the sound I registered being played in game. Great!  However, I cannot get it to trigger via my mod code.    Registration: public static final RegistryObject<SoundEvent> A_WORLD_OF_MADNESS = SOUND_EVENTS.register("a_world_of_madness", () -> new SoundEvent(new ResourceLocation("tetheredsouls", "a_world_of_madness")));   Playback: Minecraft mc = Minecraft.getInstance(); if (!(mc.player instanceof LocalPlayer) || mc.level == null) return; LocalPlayer player = (LocalPlayer) mc.player; BlockPos pos = player.blockPosition(); SoundEvent track = ModSounds.A_WORLD_OF_MADNESS.get(); System.out.println(track); System.out.println(pos); System.out.println(player); // play exactly like the tutorial: client-only, at the player's position try { mc.level.playLocalSound( player.getX(), player.getY(), player.getZ(), track, SoundSource.MUSIC, // Or MASTER if needed 1f, 1f, false ); System.out.println("[DEBUG] playSound success: " + track.getLocation()); } catch (Exception e) { System.err.println("[ERROR] Failed to play sound: " + track.getLocation()); e.printStackTrace(); } Sounds.json:   { "theme_of_laura": { "category": "music", "sounds": [ { "name": "tetheredsouls:a_world_of_madness", "stream": true } ] } } Things I have tried: - multiple .ogg files. Short .ogg files (5 seconds, <100KB).  - default minecraft sounds imported from import net.minecraft.sounds.SoundEvents; These work given my code. No idea why these are different.  - playSound() method, as well as several others in past iterations that did not work   I would be forever grateful if somebody could point me in the right direction. I've looked at several mod github repositories and found extremely similar code to what I'm doing. I've also found several threads in this forum that did not solve my issue. I just cannot figure out what I'm doing differently, and why I'm able to queue sounds manually with playsound but the code won't play it (despite confirming the code is being run with the debug statements.)
  • Topics

×
×
  • Create New...

Important Information

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