Posted February 23, 201411 yr 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); } } } }
February 24, 201411 yr 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. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
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.