Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am having trouble generating my ore in 1.8. I put in a line of code that tells me in the console where the ore is being generated but when i go to that location it's not there. I have gone over the code a few times and found an error here and there but they fixed other small issues and i still haven't been able to fix this issue. Could someone please take a look at the code below. Thanks!

 

package com.dylann6466.world;

import java.util.Random;

import com.dylann6466.Main.MainRegistry;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldOreGen implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
	switch(world.provider.getDimensionId())
	{
	case -1:
		GenerateNether(world, chunkX * 16, chunkZ * 16, random);
		break;
	case 0:
		GenerateOverworld(world, chunkX * 16, chunkZ * 16, random);
		break;
	case 1:
		GenerateEnd(world, chunkX * 16, chunkZ * 16, random);
		break;
	}
}

private void addOre(Block block, Block blockSpawn, Random random, World world, int posX, int posZ, int minY, int maxY, int minVein, int maxVein, int SpawnChance)
{
	for(int i = 0; i < SpawnChance; i++)
	{
		int defaultChunkSize = 16;

		int Xpos = posX + random.nextInt(defaultChunkSize);
		int Ypos = minY + random.nextInt(maxY - minY);
		int Zpos = posZ + random.nextInt(defaultChunkSize);

		IBlockState state = block.getDefaultState();
		BlockPos blockPos = new BlockPos(Xpos, Ypos, Zpos);

		new WorldGenMinable(state, maxVein).generate(world, random, blockPos); 
		System.out.println("Ore Generated: " + blockPos);
	}
}

private void GenerateEnd(World world, int i, int j, Random random) 
{

}

private void GenerateOverworld(World world, int i, int j, Random random) 
{
	addOre(MainRegistry.copperOre, Blocks.stone, random, world, i, j, 15, 100, 4, 8, 40);
}

private void GenerateNether(World world, int i, int j, Random random) 
{

}

}

  • Author

Hmmm, the block comes up in the creative tab so i think it's registering properly.

 

This is the world gen class file.

 

package com.dylann6466.world;

import java.util.Random;

import com.dylann6466.Main.MainRegistry;

import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class WorldGen 
{
public static void MainRegistry()
{
	registerWorldGen(new WorldOreGen(),1);
}

public static void registerWorldGen(IWorldGenerator iGenerator, int weightedProbability)
{
	GameRegistry.registerWorldGenerator(iGenerator, weightedProbability);
}
}

  • Author

I haven't used Git before. Are you able to please explain to me on what i need to do or link me to a video that shows me what to do?

  • 2 weeks later...
  • Author

I have tried uploading the files but there is none of those files you mentioned. I'm not sure if i have done it correctly, here is the link: https://github.com/Dylann6466/oreGen

 

Sorry for the late reply, i have been sick and been focusing on other stuff instead.

 

Do note that i am also getting help from someone else as well.

  • Author

It is all good now. The other person determined that i had my assets folder in the wrong spot and moving that to the right location has seemed to fix the problem.

 

Thanks for offering your help though :)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.