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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations