use of org.terasology.assets.ResourceUrn 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")));
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class ChunkViewTest method setup.
@Before
public void setup() throws IOException {
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")));
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method setup.
@Before
public void setup() throws Exception {
super.setup();
GameThread.setToCurrentThread();
this.entityManager = context.get(EngineEntityManager.class);
AssetManager assetManager = context.get(AssetManager.class);
BlockManager blockManager = context.get(BlockManager.class);
airBlock = blockManager.getBlock(BlockManager.AIR_ID);
worldStub = new WorldProviderCoreStub(airBlock, null);
worldProvider = new EntityAwareWorldProvider(worldStub, context);
plainBlock = createBlock("test:plainblock", assetManager, blockManager);
prefabWithString = createPrefabWithString("test:prefabWithString", "Test", assetManager);
blockWithString = createBlockWithPrefab("test:blockWithString", prefabWithString, false, assetManager, blockManager);
keepActiveBlock = createBlockWithPrefab("test:keepActiveBlock", prefabWithString, true, assetManager, blockManager);
Prefab prefabWithDifferentString = createPrefabWithString("test:prefabWithDifferentString", "Test2", assetManager);
blockWithDifferentString = createBlockWithPrefab("test:prefabWithDifferentString", prefabWithDifferentString, false, assetManager, blockManager);
BlockFamily blockFamily = createBlockFamily("test:blockFamily", prefabWithString, assetManager, blockManager);
Iterator<Block> iterator = blockFamily.getBlocks().iterator();
blockInFamilyOne = iterator.next();
blockInFamilyTwo = iterator.next();
PrefabData retainedPrefabData = new PrefabData();
retainedPrefabData.addComponent(new RetainedOnBlockChangeComponent(3));
Prefab retainedPrefab = assetManager.loadAsset(new ResourceUrn("test:retainedPrefab"), retainedPrefabData, Prefab.class);
blockWithRetainedComponent = createBlockWithPrefab("test:blockWithRetainedComponent", retainedPrefab, false, assetManager, blockManager);
worldProvider.initialise();
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method createBlockFamily.
private BlockFamily createBlockFamily(String urn, Prefab prefab, AssetManager assetManager, BlockManager blockManager) {
BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
data.setFamilyFactory(new HorizontalBlockFamilyFactory());
data.getBaseSection().getEntity().setKeepActive(true);
data.getBaseSection().getEntity().setPrefab(prefab);
assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class);
return blockManager.getBlockFamily(urn);
}
use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.
the class CoreCommands method reloadScreen.
/**
* Reloads ui screen
* @param ui String containing ui screen name
* @return String containing Success if UI was reloaded or No unique resource found if more screens were found
*/
@Command(shortDescription = "Reloads a ui screen")
public String reloadScreen(@CommandParam("ui") String ui) {
Set<ResourceUrn> urns = assetManager.resolve(ui, UIElement.class);
if (urns.size() == 1) {
ResourceUrn urn = urns.iterator().next();
boolean wasOpen = nuiManager.isOpen(urn);
if (wasOpen) {
nuiManager.closeScreen(urn);
}
if (wasOpen) {
nuiManager.pushScreen(urn);
}
return "Success";
} else {
return "No unique resource found";
}
}
Aggregations