Search in sources :

Example 1 with NullWorldAtlas

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

the class BlockShapeTest 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);
    this.assetManager = assetManager;
}
Also used : AssetManager(org.terasology.assets.management.AssetManager) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 2 with NullWorldAtlas

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

the class BulkLightPropagationTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    lightRules = new LightPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    BlockFamilyDefinitionData fullLightData = new BlockFamilyDefinitionData();
    fullLightData.getBaseSection().setDisplayName("Torch");
    fullLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    fullLightData.getBaseSection().setLuminance(ChunkConstants.MAX_LIGHT);
    fullLightData.getBaseSection().setTranslucent(true);
    fullLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
    BlockFamilyDefinitionData weakLightData = new BlockFamilyDefinitionData();
    weakLightData.getBaseSection().setDisplayName("PartLight");
    weakLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    weakLightData.getBaseSection().setLuminance((byte) 2);
    weakLightData.getBaseSection().setTranslucent(true);
    weakLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:weakLight"), weakLightData, BlockFamilyDefinition.class);
    weakLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:weakLight")));
    BlockFamilyDefinitionData mediumLightData = new BlockFamilyDefinitionData();
    mediumLightData.getBaseSection().setDisplayName("MediumLight");
    mediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    mediumLightData.getBaseSection().setLuminance((byte) 5);
    mediumLightData.getBaseSection().setTranslucent(true);
    mediumLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:mediumLight"), mediumLightData, BlockFamilyDefinition.class);
    mediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:mediumLight")));
    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")));
    BlockFamilyDefinitionData solidMediumLightData = new BlockFamilyDefinitionData();
    solidMediumLightData.getBaseSection().setDisplayName("SolidMediumLight");
    solidMediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidMediumLightData.getBaseSection().setTranslucent(false);
    solidMediumLightData.getBaseSection().setLuminance((byte) 5);
    solidMediumLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:solidMediumLight"), solidMediumLightData, BlockFamilyDefinition.class);
    solidMediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:solidMediumLight")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
}
Also used : LightPropagationRules(org.terasology.world.propagation.light.LightPropagationRules) BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) 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 3 with NullWorldAtlas

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

the class BulkSunlightPropagationTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    regenRules = new SunlightRegenPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    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")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
    Map<Vector3i, Block> blockData = Maps.newHashMap();
    regenWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
    lightWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
    lightRules = new SunlightPropagationRules(regenWorldView);
    sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
    propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Also used : BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) SunlightPropagationRules(org.terasology.world.propagation.light.SunlightPropagationRules) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) Vector3i(org.terasology.math.geom.Vector3i) Block(org.terasology.world.block.Block) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.assets.ResourceUrn) SunlightRegenPropagationRules(org.terasology.world.propagation.light.SunlightRegenPropagationRules) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 4 with NullWorldAtlas

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

the class HeadlessEnvironment method setupBlockManager.

@Override
protected void setupBlockManager(AssetManager assetManager) {
    WorldAtlas worldAtlas = new NullWorldAtlas();
    BlockManagerImpl blockManager = new BlockManagerImpl(worldAtlas, assetManager);
    context.put(BlockManager.class, blockManager);
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    typeSerializationLibrary.add(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    typeSerializationLibrary.add(Block.class, new BlockTypeHandler(blockManager));
}
Also used : NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 5 with NullWorldAtlas

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

the class InternalLightGeneratorTest 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);
    airBlock = blockManager.getBlock(BlockManager.AIR_ID);
    biomeManager = Mockito.mock(BiomeManager.class);
    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);
    solidBlock = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    BlockFamilyDefinitionData fullLightData = new BlockFamilyDefinitionData();
    fullLightData.getBaseSection().setDisplayName("Torch");
    fullLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    fullLightData.getBaseSection().setLuminance(ChunkConstants.MAX_LIGHT);
    fullLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
}
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) 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)

Aggregations

BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)8 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)8 Before (org.junit.Before)7 AssetManager (org.terasology.assets.management.AssetManager)7 ResourceUrn (org.terasology.assets.ResourceUrn)6 BlockUri (org.terasology.world.block.BlockUri)6 SymmetricBlockFamilyFactory (org.terasology.world.block.family.SymmetricBlockFamilyFactory)6 BlockFamilyDefinitionData (org.terasology.world.block.loader.BlockFamilyDefinitionData)6 BiomeManager (org.terasology.world.biomes.BiomeManager)4 Vector3i (org.terasology.math.geom.Vector3i)2 SunlightPropagationRules (org.terasology.world.propagation.light.SunlightPropagationRules)2 SunlightRegenPropagationRules (org.terasology.world.propagation.light.SunlightRegenPropagationRules)2 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)1 BlockFamilyTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)1 BlockTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler)1 Block (org.terasology.world.block.Block)1 WorldAtlas (org.terasology.world.block.tiles.WorldAtlas)1 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)1 LightPropagationRules (org.terasology.world.propagation.light.LightPropagationRules)1 SunlightRegenWorldView (org.terasology.world.propagation.light.SunlightRegenWorldView)1