Jump to content

Recommended Posts

Posted (edited)

I just started recently and have been learning a lot.

I have been trying to generate a block on grass for quite some time now. 

I managed to get it correctly generated however the block only generates if the vein is 4 or greater (the actually blocks in the world that are generated generate anything from 1 to 4). If i set it to 3 or lower nothing will be generated.

Any fix for this or any other methods i can use to generate a block in a chunk size of 1 or 2.

Here is code for the world gen

Spoiler

package world;

import java.util.Random;

import com.KOBKingobrine.FirstMod.init.ModBlocks;

import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldGeneratorBlocks implements IWorldGenerator {

    private WorldGenerator snakePit, j4block;

    public WorldGeneratorBlocks()
    {
        snakePit = new WorldGenMinable(ModBlocks.SNAKE_PIT.getDefaultState(),1,BlockMatcher.forBlock(Blocks.GRASS));  //This block will only generate if the number parameter in the middle is higher than 4
        
    }
    
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunk)
    {
        switch(world.provider.getDimension())
        {
        case 0:
            runGenerator(snakePit,world,random,chunkX,chunkZ,100,50,100);
            
        }
    }
    private void runGenerator(WorldGenerator gen, World world, Random rand, int chunkX, int chunkZ, int chance, int minHeight, int maxHeight)
    {
        
        int deltaY = maxHeight - minHeight + 1;
        for(int i = 0; i<chance;i++)
        {
            int x = chunkX * 16 + rand.nextInt(16);
            int y = minHeight + rand.nextInt(deltaY);
            int z = chunkZ * 16 + rand.nextInt(16);
            
            gen.generate(world,rand,new BlockPos(x,y,z));
        }
    }
    
    

}
 

I dont get any crashes even if the value is lower than 4

 

Thank you for any help

Edited by ijuststartedmoddingplshelp
Corrections

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.