Search in sources :

Example 16 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class TreeTests method computeAABB.

private Vector3i computeAABB(TreeGenerator treeGen, long seed) {
    Vector3i pos = new Vector3i(ChunkConstants.SIZE_X / 2, 0, ChunkConstants.SIZE_Z / 2);
    final Vector3i min = new Vector3i(pos);
    final Vector3i max = new Vector3i(pos);
    Rect2i chunks = Rect2i.createFromMinAndMax(-1, -1, 1, 1);
    for (BaseVector2i chunkPos : chunks.contents()) {
        Chunk chunk = new ChunkImpl(chunkPos.getX(), 0, chunkPos.getY(), blockManager, biomeManager) {

            @Override
            public Block setBlock(int x, int y, int z, Block block) {
                Vector3i world = chunkToWorldPosition(x, y, z);
                minimize(min, world);
                maximize(max, world);
                return null;
            }
        };
        Random random = new MersenneRandom(seed);
        BlockManager blockManagerLocal = CoreRegistry.get(BlockManager.class);
        Vector3i relPos = chunk.chunkToWorldPosition(0, 0, 0).sub(pos).invert();
        treeGen.generate(blockManagerLocal, chunk, random, relPos.x, relPos.y, relPos.z);
    }
    Vector3i ext = new Vector3i(max).sub(min);
    return ext;
}
Also used : Rect2i(org.terasology.math.geom.Rect2i) MersenneRandom(org.terasology.utilities.random.MersenneRandom) Random(org.terasology.utilities.random.Random) MersenneRandom(org.terasology.utilities.random.MersenneRandom) ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) BlockManager(org.terasology.world.block.BlockManager) Vector3i(org.terasology.math.geom.Vector3i) BaseVector2i(org.terasology.math.geom.BaseVector2i) Block(org.terasology.world.block.Block) Chunk(org.terasology.world.chunks.Chunk)

Aggregations

BlockManager (org.terasology.world.block.BlockManager)16 BiomeManager (org.terasology.world.biomes.BiomeManager)6 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)5 Before (org.junit.Before)4 ModuleManager (org.terasology.engine.module.ModuleManager)4 WorldProvider (org.terasology.world.WorldProvider)4 Block (org.terasology.world.block.Block)4 Path (java.nio.file.Path)3 AssetManager (org.terasology.assets.management.AssetManager)3 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 EntityAwareWorldProvider (org.terasology.world.internal.EntityAwareWorldProvider)3 FileSystem (java.nio.file.FileSystem)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 ResourceUrn (org.terasology.assets.ResourceUrn)2 Config (org.terasology.config.Config)2 RenderingSubsystemFactory (org.terasology.engine.subsystem.RenderingSubsystemFactory)2 Game (org.terasology.game.Game)2 LocalPlayer (org.terasology.logic.players.LocalPlayer)2 ModuleEnvironment (org.terasology.module.ModuleEnvironment)2 NetworkSystem (org.terasology.network.NetworkSystem)2