Jump to content

Trying to generate mushrooms


TheSmiler

Recommended Posts

Hello, am just beginning modding and I am trying to generate new mushrooms with the GeneratorBushFeature(BlockBush) class.

The game is starting but chash when I try to generate a world.

My mushroom block extends the BlockMushroom class and my generator class is registered with GameRegistry.registerWorldGenerator(new WorldGenMushrooms(),0);

 

here is the generator's cod:

 

package fr.thesmiler.mushroomsmod.world.gen.feature;

 

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

import net.minecraft.world.gen.feature.WorldGenerator;

import net.minecraftforge.fml.common.IWorldGenerator;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import fr.thesmiler.mushroomsmod.init.MushroomsBlocks;

 

public class WorldGenMushrooms implements IWorldGenerator{

 

public WorldGenerator mushroomYellowGen;

public Random randomGenerator;

public BlockPos bp;

 

public WorldGenMushrooms(){

        this.mushroomYellowGen = new GeneratorBushFeature(MushroomsBlocks.yellow_mushroom);

        System.out.println("TEST");

}

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){

 

generateSurfaceMush(world, random, chunkX*16, chunkZ*16);

 

if(world.provider.getDimensionId()==0){

 

generateSurfaceMush(world, random, chunkX*16, chunkZ*16);

}

 

 

 

 

}

 

 

public void generateSurfaceMush(World world, Random rand, int chunkX, int chunkZ){

 

 

 

    for (int i = 0; i < 50; i++){

   

    if (this.randomGenerator.nextInt(4) == 0){

 

    int randPosX = chunkX + rand.nextInt(16);

    int randPosY = rand.nextInt(48);

    int randPosZ = chunkZ + rand.nextInt(16);

           

    BlockPos blockpos2 = world.getHorizon(bp.add(randPosX, randPosY, randPosZ));

    mushroomYellowGen.generate(world, rand,blockpos2);

    System.out.println("test");

       

    }

   

   

    }

}

}

 

I did removed the comments because they were in Frensh, sorry.

 

Please help me!

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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