Package com.khorn.terraincontrol.generator.resource

Examples of com.khorn.terraincontrol.generator.resource.SaplingGen


            }
            location = lowestXZ;
        }

        // Get generator
        SaplingGen sapling = biomeConfig.getSaplingGen(saplingType);
        if (sapling == null)
        {
            return;
        }

        // Try 10 times to spawn tree
        boolean success = false;
        for (int i = 0; i < 10; i++)
        {
            if (sapling.growSapling(world, new Random(), location.getBlockX(), location.getBlockY(), location.getBlockZ()))
            {
                success = true;
                break;
            }
        }
View Full Code Here


            // Unsupported sapling
            return;
        }

        // Get the sapling generator
        SaplingGen saplingGen = this.getSaplingGen(localWorld, saplingGrower.saplingType, saplingGrower.x, saplingGrower.z);
        if (saplingGen == null)
        {
            // No sapling generator set for this sapling
            return;
        }

        // When we have reached this point, we know that we have to handle the
        // event ourselves
        // So cancel it
        event.setResult(Result.DENY);

        // Remove saplings
        if (saplingGrower.saplingType.requiresFourSaplings())
        {
            world.setBlock(saplingGrower.x, saplingGrower.y, saplingGrower.z, Blocks.air);
            world.setBlock(saplingGrower.x + 1, saplingGrower.y, saplingGrower.z, Blocks.air);
            world.setBlock(saplingGrower.x, saplingGrower.y, saplingGrower.z + 1, Blocks.air);
            world.setBlock(saplingGrower.x + 1, saplingGrower.y, saplingGrower.z + 1, Blocks.air);
        } else
        {
            world.setBlock(saplingGrower.x, saplingGrower.y, saplingGrower.z, Blocks.air);
        }

        // Try ten times to grow sapling
        boolean saplingGrown = false;
        for (int i = 0; i < 10; i++)
        {
            if (saplingGen.growSapling(localWorld, new Random(), saplingGrower.x, saplingGrower.y, saplingGrower.z))
            {
                saplingGrown = true;
                break;
            }
        }
View Full Code Here

            // World not managed by Terrain Control
            return;
        }

        // Get sapling gen
        SaplingGen gen = null;
        if (event.block == Blocks.red_mushroom_block)
        {
            gen = getSaplingGen(localWorld, SaplingType.RedMushroom, event.x, event.z);
        } else if (event.block == Blocks.brown_mushroom_block)
        {
            gen = getSaplingGen(localWorld, SaplingType.BrownMushroom, event.x, event.z);
        }
        if (gen == null)
        {
            // No sapling gen specified for this type
            return;
        }

        // Generate mushroom
        event.setResult(Result.ALLOW);
        event.world.setBlock(event.x, event.y, event.z, Blocks.air);

        boolean mushroomGrown = false;
        Random random = new Random();
        for (int i = 0; i < 10; i++)
        {
            if (gen.growSapling(localWorld, random, event.x, event.y, event.z))
            {
                mushroomGrown = true;
                break;
            }
        }
View Full Code Here

TOP

Related Classes of com.khorn.terraincontrol.generator.resource.SaplingGen

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.