Search in sources :

Example 1 with Populate

use of net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate in project MinecraftForge by MinecraftForge.

the class TerrainGen method populate.

public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type) {
    PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.getResult() != Result.DENY;
}
Also used : Populate(net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate) Populate(net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate)

Example 2 with Populate

use of net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate 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)

Aggregations

Populate (net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate)2 World (net.minecraft.world.World)1 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)1 Decorate (net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate)1 GenerateMinable (net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable)1 BlockState (org.spongepowered.api.block.BlockState)1 BlockType (org.spongepowered.api.block.BlockType)1 StoneType (org.spongepowered.api.data.type.StoneType)1 Ore (org.spongepowered.api.world.gen.populator.Ore)1