Search in sources :

Example 1 with MapGenStructureHook

use of ivorius.reccomplex.world.gen.feature.structure.MapGenStructureHook in project RecurrentComplex by Ivorforce.

the class RCTerrainGenEventHandler method onInitMapGen.

@SubscribeEvent
public void onInitMapGen(InitMapGenEvent event) {
    if (RCConfig.decorationHacks) {
        InitMapGenEvent.EventType type = event.getType();
        // All need to inherit from the base type
        MapGenStructureHook hook;
        switch(type) {
            case OCEAN_MONUMENT:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.OCEAN_MONUMENT);
                event.setNewGen(new StructureOceanMonument() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
            case SCATTERED_FEATURE:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.SCATTERED_FEATURE);
                event.setNewGen(new MapGenScatteredFeature() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
            case VILLAGE:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.VILLAGE);
                event.setNewGen(new MapGenVillage() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
            case NETHER_BRIDGE:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.NETHER_BRIDGE);
                event.setNewGen(new MapGenNetherBridge() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
            case STRONGHOLD:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.STRONGHOLD);
                event.setNewGen(new MapGenStronghold() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
            case MINESHAFT:
                hook = new MapGenStructureHook((MapGenStructure) event.getNewGen(), RCBiomeDecorator.DecorationType.MINESHAFT);
                event.setNewGen(new MapGenMineshaft() {

                    @Override
                    public String getStructureName() {
                        return hook.getStructureName();
                    }

                    @Override
                    public boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
                        return hook.generateStructure(worldIn, randomIn, chunkCoord);
                    }

                    @Override
                    public boolean isInsideStructure(BlockPos pos) {
                        return hook.isInsideStructure(pos);
                    }

                    @Override
                    public boolean isPositionInStructure(World worldIn, BlockPos pos) {
                        return hook.isPositionInStructure(worldIn, pos);
                    }

                    @Override
                    @Nullable
                    public BlockPos getNearestStructurePos(World worldIn, BlockPos pos, boolean findUnexplored) {
                        return hook.getNearestStructurePos(worldIn, pos, findUnexplored);
                    }

                    @Override
                    public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
                        hook.generate(worldIn, x, z, primer);
                    }
                });
                break;
        }
    }
}
Also used : World(net.minecraft.world.World) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer) Random(java.util.Random) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) InitMapGenEvent(net.minecraftforge.event.terraingen.InitMapGenEvent) MapGenStructureHook(ivorius.reccomplex.world.gen.feature.structure.MapGenStructureHook) Nullable(javax.annotation.Nullable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

MapGenStructureHook (ivorius.reccomplex.world.gen.feature.structure.MapGenStructureHook)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 World (net.minecraft.world.World)1 ChunkPrimer (net.minecraft.world.chunk.ChunkPrimer)1 InitMapGenEvent (net.minecraftforge.event.terraingen.InitMapGenEvent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1