Search in sources :

Example 1 with SymmetricBlockFamilyFactory

use of org.terasology.world.block.family.SymmetricBlockFamilyFactory 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 2 with SymmetricBlockFamilyFactory

use of org.terasology.world.block.family.SymmetricBlockFamilyFactory 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 3 with SymmetricBlockFamilyFactory

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

the class StorageManagerTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class);
    FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive);
    PathManager.getInstance().useOverrideHomePath(temporaryFolder.getRoot().toPath());
    savePath = PathManager.getInstance().getSavePath("testSave");
    assert !Files.isRegularFile(vfs.getPath("global.dat"));
    entityManager = context.get(EngineEntityManager.class);
    moduleEnvironment = context.get(ModuleEnvironment.class);
    blockManager = context.get(BlockManager.class);
    biomeManager = context.get(BiomeManager.class);
    esm = new ReadWriteStorageManager(savePath, moduleEnvironment, entityManager, blockManager, biomeManager, false);
    context.put(StorageManager.class, esm);
    this.character = entityManager.create();
    Client client = createClientMock(PLAYER_ID, character);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    when(networkSystem.getPlayers()).thenReturn(Arrays.asList(client));
    context.put(NetworkSystem.class, networkSystem);
    AssetManager assetManager = context.get(AssetManager.class);
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("test:testblock"), data, BlockFamilyDefinition.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock2"), data, BlockFamilyDefinition.class);
    testBlock = context.get(BlockManager.class).getBlock("test:testblock");
    testBlock2 = context.get(BlockManager.class).getBlock("test:testblock2");
    context.put(ChunkProvider.class, mock(ChunkProvider.class));
    BiomeManager mockBiomeManager = mock(BiomeManager.class);
    when(mockBiomeManager.getBiomes()).thenReturn(Collections.<Biome>emptyList());
    context.put(BiomeManager.class, mockBiomeManager);
    WorldProvider worldProvider = mock(WorldProvider.class);
    when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo());
    context.put(WorldProvider.class, worldProvider);
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) AssetManager(org.terasology.assets.management.AssetManager) NetworkSystem(org.terasology.network.NetworkSystem) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ModuleEnvironment(org.terasology.module.ModuleEnvironment) BlockManager(org.terasology.world.block.BlockManager) FileSystem(java.nio.file.FileSystem) WorldProvider(org.terasology.world.WorldProvider) WorldInfo(org.terasology.world.internal.WorldInfo) Client(org.terasology.network.Client) ResourceUrn(org.terasology.assets.ResourceUrn) ChunkProvider(org.terasology.world.chunks.ChunkProvider) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) Before(org.junit.Before)

Example 4 with SymmetricBlockFamilyFactory

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

the class EntityAwareWorldProviderTest method createBlock.

private Block createBlock(String urn, AssetManager assetManager, BlockManager blockManager) {
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class);
    return blockManager.getBlock(urn);
}
Also used : BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ResourceUrn(org.terasology.assets.ResourceUrn) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory)

Example 5 with SymmetricBlockFamilyFactory

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

the class EntityAwareWorldProviderTest method createBlockWithPrefab.

private Block createBlockWithPrefab(String urn, Prefab prefab, boolean keepActive, AssetManager assetManager, BlockManager blockManager) {
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setFamilyFactory(new SymmetricBlockFamilyFactory());
    data.getBaseSection().getEntity().setPrefab(prefab);
    data.getBaseSection().getEntity().setKeepActive(keepActive);
    assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class);
    return blockManager.getBlock(urn);
}
Also used : BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ResourceUrn(org.terasology.assets.ResourceUrn) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory)

Aggregations

ResourceUrn (org.terasology.assets.ResourceUrn)9 SymmetricBlockFamilyFactory (org.terasology.world.block.family.SymmetricBlockFamilyFactory)9 BlockFamilyDefinitionData (org.terasology.world.block.loader.BlockFamilyDefinitionData)9 Before (org.junit.Before)7 AssetManager (org.terasology.assets.management.AssetManager)7 BlockUri (org.terasology.world.block.BlockUri)6 BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)6 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)6 BiomeManager (org.terasology.world.biomes.BiomeManager)5 Vector3i (org.terasology.math.geom.Vector3i)2 SunlightPropagationRules (org.terasology.world.propagation.light.SunlightPropagationRules)2 SunlightRegenPropagationRules (org.terasology.world.propagation.light.SunlightRegenPropagationRules)2 FileSystem (java.nio.file.FileSystem)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)1 ModuleEnvironment (org.terasology.module.ModuleEnvironment)1 Client (org.terasology.network.Client)1 NetworkSystem (org.terasology.network.NetworkSystem)1 WorldProvider (org.terasology.world.WorldProvider)1 Block (org.terasology.world.block.Block)1