Search in sources :

Example 31 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project MorePlanets by SteveKunG.

the class BlockNibiruFlower method generateBigMushroom.

private boolean generateBigMushroom(World world, BlockPos pos, IBlockState state, Random rand) {
    world.setBlockToAir(pos);
    WorldGenerator worldgenerator = new WorldGenTerrashroom();
    if (worldgenerator.generate(world, rand, pos)) {
        return true;
    } else {
        world.setBlockState(pos, state, 3);
        return false;
    }
}
Also used : WorldGenTerrashroom(stevekung.mods.moreplanets.module.planets.nibiru.world.gen.feature.WorldGenTerrashroom) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator)

Example 32 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Solar by Martacus.

the class WorldGenSilverOre method generateOverworld.

public void generateOverworld(World world, Random rand, int chunkX, int chunkZ) {
    for (int k = 0; k < 8; k++) {
        int blockCount = rand.nextInt(6) + 1;
        WorldGenerator silverGen = new WorldGenMinable(ModBlocks.SILVER_ORE.getDefaultState(), blockCount);
        int firstBlockXCoord = chunkX + rand.nextInt(16);
        int firstBlockZCoord = chunkZ + rand.nextInt(16);
        int blockY = rand.nextInt(28) + 2;
        BlockPos blockPos = new BlockPos(firstBlockXCoord, blockY, firstBlockZCoord);
        silverGen.generate(world, rand, blockPos);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) BlockPos(net.minecraft.util.math.BlockPos) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable)

Example 33 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Tropicraft by Tropicraft.

the class BlockTropicsSapling method grow.

@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
    // Change flag (and back) to make it show up when generated
    TCGenBase.blockGenNotifyFlag = 3;
    WorldGenerator gen;
    TropicraftSaplings variant;
    switch(variant = state.getValue(VARIANT)) {
        case PALM:
            int b = rand.nextInt(3);
            if (b == 0) {
                gen = new WorldGenLargePalmTrees(worldIn, rand);
            } else if (b == 1) {
                gen = new WorldGenCurvedPalms(worldIn, rand);
            } else if (b == 2) {
                gen = new WorldGenNormalPalms(worldIn, rand);
            } else {
                gen = null;
            }
            break;
        case MAHOGANY:
            gen = randomRainforestTreeGen(worldIn);
            break;
        default:
            gen = new WorldGenFruitTrees(worldIn, rand, variant.getMeta() - 2);
            break;
    }
    if (gen != null) {
        worldIn.setBlockToAir(pos);
        if (!gen.generate(worldIn, rand, pos)) {
            worldIn.setBlockState(pos, state.withProperty(BlockTropicsSapling.VARIANT, variant), 3);
        }
    }
    TCGenBase.blockGenNotifyFlag = TCGenBase.BLOCK_GEN_NOTIFY_FLAG_DEFAULT;
}
Also used : WorldGenLargePalmTrees(net.tropicraft.core.common.worldgen.WorldGenLargePalmTrees) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenCurvedPalms(net.tropicraft.core.common.worldgen.WorldGenCurvedPalms) TropicraftSaplings(net.tropicraft.core.common.enums.TropicraftSaplings) WorldGenFruitTrees(net.tropicraft.core.common.worldgen.WorldGenFruitTrees) WorldGenNormalPalms(net.tropicraft.core.common.worldgen.WorldGenNormalPalms)

Example 34 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project SpongeForge by SpongePowered.

the class SpongeChunkGeneratorForge method checkForgeEvent.

private boolean checkForgeEvent(Populator populator, IChunkGenerator chunkProvider, int chunkX, int chunkZ, List<String> flags, Chunk chunk) {
    boolean village_flag = flags.contains(WorldGenConstants.VILLAGE_FLAG);
    if (populator instanceof Ore && populator instanceof WorldGenerator) {
        BlockType type = ((Ore) populator).getOreBlock().getType();
        GenerateMinable.EventType otype = null;
        if (type.equals(BlockTypes.DIRT)) {
            otype = GenerateMinable.EventType.DIRT;
        } else if (type.equals(BlockTypes.GRAVEL)) {
            otype = GenerateMinable.EventType.GRAVEL;
        } else if (type.equals(BlockTypes.STONE)) {
            BlockState state = ((Ore) populator).getOreBlock();
            Optional<StoneType> stype;
            if ((stype = state.get(Keys.STONE_TYPE)).isPresent()) {
                StoneType stoneType = stype.get();
                if (stoneType.equals(StoneTypes.DIORITE)) {
                    otype = GenerateMinable.EventType.DIORITE;
                } else if (stoneType.equals(StoneTypes.ANDESITE)) {
                    otype = GenerateMinable.EventType.ANDESITE;
                } else if (stoneType.equals(StoneTypes.GRANITE)) {
                    otype = GenerateMinable.EventType.GRANITE;
                } else {
                    return true;
                }
            }
        } else if (type.equals(BlockTypes.COAL_ORE)) {
            otype = GenerateMinable.EventType.COAL;
        } else if (type.equals(BlockTypes.IRON_ORE)) {
            otype = GenerateMinable.EventType.IRON;
        } else if (type.equals(BlockTypes.GOLD_ORE)) {
            otype = GenerateMinable.EventType.GOLD;
        } else if (type.equals(BlockTypes.REDSTONE_ORE)) {
            otype = GenerateMinable.EventType.REDSTONE;
        } else if (type.equals(BlockTypes.DIAMOND_ORE)) {
            otype = GenerateMinable.EventType.DIAMOND;
        } else if (type.equals(BlockTypes.LAPIS_ORE)) {
            otype = GenerateMinable.EventType.LAPIS;
        } else if (type.equals(BlockTypes.QUARTZ_ORE)) {
            otype = GenerateMinable.EventType.QUARTZ;
        } else if (type.equals(BlockTypes.EMERALD_ORE)) {
            otype = GenerateMinable.EventType.EMERALD;
        } else if (type.equals(BlockTypes.MONSTER_EGG)) {
            otype = GenerateMinable.EventType.SILVERFISH;
        }
        return otype == null || TerrainGen.generateOre((World) chunk.getWorld(), this.rand, (WorldGenerator) populator, VecHelper.toBlockPos(chunk.getBlockMin()), otype);
    }
    Populate.EventType etype = this.getForgeEventTypeForPopulator(populator, chunk);
    boolean populate = TerrainGen.populate(chunkProvider, (net.minecraft.world.World) chunk.getWorld(), this.rand, chunkX, chunkZ, village_flag, etype);
    Decorate.EventType detype = this.getForgeDecorateEventTypeForPopulator(populator, chunk);
    boolean decorate = TerrainGen.decorate((World) chunk.getWorld(), this.rand, VecHelper.toBlockPos(chunk.getBlockMin()), detype);
    // TODO May need to separate this..
    return populate && decorate;
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) Ore(org.spongepowered.api.world.gen.populator.Ore) StoneType(org.spongepowered.api.data.type.StoneType) Decorate(net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate) World(net.minecraft.world.World) BlockState(org.spongepowered.api.block.BlockState) BlockType(org.spongepowered.api.block.BlockType) Populate(net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate) GenerateMinable(net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable)

Example 35 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project ForestryMC by ForestryMC.

the class TileSapling method tryGrow.

public void tryGrow(Random random, boolean bonemealed) {
    ITree tree = getTree();
    if (tree == null) {
        return;
    }
    int maturity = getRequiredMaturity(world, tree);
    if (timesTicked < maturity) {
        if (bonemealed) {
            timesTicked = maturity;
        }
        return;
    }
    WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
    final boolean generated;
    if (generator instanceof WorldGenBase) {
        generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
    } else {
        generated = generator.generate(world, random, getPos());
    }
    if (generated) {
        IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
        breedingTracker.registerBirth(tree);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBreedingTracker(forestry.api.genetics.IBreedingTracker) ITree(forestry.api.arboriculture.ITree) WorldGenBase(forestry.core.worldgen.WorldGenBase)

Aggregations

WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)44 BlockPos (net.minecraft.util.math.BlockPos)25 IBlockState (net.minecraft.block.state.IBlockState)8 WorldUtil (rtg.api.util.WorldUtil)7 World (net.minecraft.world.World)3 WorldGenMinable (net.minecraft.world.gen.feature.WorldGenMinable)3 WorldGenGrass (rtg.api.world.gen.feature.WorldGenGrass)3 MapMaker (com.google.common.collect.MapMaker)2 ITree (forestry.api.arboriculture.ITree)2 WorldGenBase (forestry.core.worldgen.WorldGenBase)2 Predicate (java.util.function.Predicate)2 RailcraftConfig (mods.railcraft.common.core.RailcraftConfig)2 NoiseGenSimplex (mods.railcraft.common.worldgen.NoiseGen.NoiseGenSimplex)2 Vec3 (net.minecraft.util.Vec3)2 Biome (net.minecraft.world.biome.Biome)2 WorldGenTrees (net.minecraft.world.gen.feature.WorldGenTrees)2 EventType (net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType)2 TerrainGen (net.minecraftforge.event.terraingen.TerrainGen)2 DecorateBiomeEventRTG (rtg.api.event.DecorateBiomeEventRTG)2 WorldGenBigTrees (betterwithaddons.world.WorldGenBigTrees)1