Search in sources :

Example 21 with ChunkImpl

use of org.terasology.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.

the class ChunkTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager);
    CoreRegistry.put(BlockManager.class, blockManager);
    BiomeManager biomeManager = Mockito.mock(BiomeManager.class);
    chunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, biomeManager);
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.assets.ResourceUrn) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 22 with ChunkImpl

use of org.terasology.world.chunks.internal.ChunkImpl 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

ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)22 Vector3i (org.terasology.math.geom.Vector3i)18 Chunk (org.terasology.world.chunks.Chunk)18 Test (org.junit.Test)15 ChunkStore (org.terasology.persistence.ChunkStore)4 EntityRef (org.terasology.entitySystem.entity.EntityRef)3 ChunkProvider (org.terasology.world.chunks.ChunkProvider)3 Map (java.util.Map)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 StorageManager (org.terasology.persistence.StorageManager)2 Block (org.terasology.world.block.Block)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 TShortObjectMap (gnu.trove.map.TShortObjectMap)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Before (org.junit.Before)1 ResourceUrn (org.terasology.assets.ResourceUrn)1 AssetManager (org.terasology.assets.management.AssetManager)1 LocationComponent (org.terasology.logic.location.LocationComponent)1