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

Hi,

 

I am creating a world generator for my mod so that i can spawn custom blocks into my world. I have got an issue with the BlockPos section as i've always remembered it to be the X,Y,Z coords of the block that you are wanting to spawn.

 

So far I have got this

package minecraft.criminoxmc.parallelworlds;

import java.util.Random;

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 ParallelWorldsGenerator 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, random, chunkX * 16, chunkZ * 16);
		break;
	case 0:
		generateSurface(world, random, chunkX * 16, chunkZ * 16);
		break;
	case 1:
		generateEnd(world, random, chunkX * 16, chunkZ * 16);
		break;
	}

}

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

}

private void generateSurface(World world, Random random, int i, int j) {
	for (int k = 0; k < 4; k++) {
		int NightOreXCoord = i + random.nextInt(16);
		int NightOreYCoord = i + random.nextInt(10);
		int NightOreZCoord = j + random.nextInt(16);

		(new WorldGenMinable(ParallelWorldsMain.NightOre.getDefaultState(), 4)).generate(world, random, BlockPos);
	}
}



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

}

}

 

So it's really i don't know what to do with the BlockPos, do i have to wrap the X,Y,Z coords for that block into BlockPos and if so can someone shed some light on this as i'm a bit rusty after being gone for a bit.

 

Also Here is my main code

package minecraft.criminoxmc.parallelworlds;

import minecraft.criminoxmc.parallelworlds.items.NightGem;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = ParallelWorldsMain.MODID, version = ParallelWorldsMain.Version)
public class ParallelWorldsMain {

public static final String MODID = "Parallel Worlds";
public static final String Version = "1.0.0";


//Block Static
public static minecraft.criminoxmc.parallelworlds.blocks.NightOre NightOre;

//Item Static
public static Item NightGem;
@EventHandler
public void PreInit(FMLPreInitializationEvent event){
	// Block New
	NightOre = new minecraft.criminoxmc.parallelworlds.blocks.NightOre();

	// Item New
	NightGem = new NightGem();
	//Block Registry
	GameRegistry.registerBlock(NightOre, "Night Ore");

	//Item Registry
	GameRegistry.registerItem(NightGem, "Night Gem");
}


public void Init(FMLInitializationEvent event){
	//Generation
	GameRegistry.registerWorldGenerator(new ParallelWorldsGenerator(), 14);
}

public void PostInit(FMLPostInitializationEvent event){

}

}

 

I am assuming that the number on the registerworldgenerator is a dimension ID, feel free to correct me if i am wrong.

 

Thanks people

:)

STOP CRUCIFYING NEW MODDERS!!!!

  • Author

BlockPos is just a wrapper object for x, y, z, so yes, pack you x, y, z into a BlockPos.

 

For registerWorldGenerator: The number is the priority.

 

Ahh right, Thank you very much dude :)

STOP CRUCIFYING NEW MODDERS!!!!

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.