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 spawning a block on the surface, the console prints out "block placed" but I will search all over and not see one, could I get some help fixing this?

 

package myown.worldgen;

import java.util.Random;

import myown.basicinfo.Ids;
import myown.blocks.Blocks;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenTallGrass;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;


public class WorldGeneratorHSM implements IWorldGenerator {

public static void init(){

	GameRegistry.registerWorldGenerator(new WorldGeneratorHSM());
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	// TODO Auto-generated method stub
	switch(world.provider.dimensionId){
	//case -1: generateNether(world, random,chunkX*16,chunkZ*16);
	case 0 : generateSurface(world, random,chunkX*16,chunkZ*16);
	}
}

private void generateSurface(World world, Random random, int BlockX, int BlockZ) {

	for(int i =0; i<10;i++){
		int Xcoord = BlockX + random.nextInt(16);
		int Zcoord = BlockZ + random.nextInt(16);
		int Ycoord = random.nextInt(30);
		(new WorldGenMinable(Ids.AlloBlock, 4)).generate(world, random, Xcoord, Ycoord, Zcoord);
	}

	for(int i =0; i<100;i++){
		int Xcoord = BlockX + random.nextInt(16);
		int Zcoord = BlockZ + random.nextInt(16);
		int Ycoord = world.getHeightValue(Xcoord, Zcoord)+random.nextInt(4);
		if(world.isAirBlock(Xcoord, Ycoord, Zcoord) && world.getBlockId(Xcoord, Ycoord-1, Zcoord) == Block.grass.blockID && Blocks.block1.canPlaceBlockAt(world, Xcoord, Ycoord, Zcoord)){
			System.out.println("block placed");
			(new WorldGenMinable(Ids.SapphireOre, 1)).generate(world, random, Xcoord, Ycoord, Zcoord);
		}
	}
}
}

You're generating minables (stuff below the surface) with coordinates that are up in the air (up to 4 blocks above the terrain). Why would you expect to find some stone to replace with an ore up there?

 

The generate function of WorldGenMinable checks for stone to replace, otherwise it doesn't place anything.

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.