use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.
the class TerasologyTestingEnvironment method setupEnvironment.
@BeforeClass
public static void setupEnvironment() throws Exception {
final JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class);
final FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive);
PathManager.getInstance().useOverrideHomePath(vfs.getPath(""));
/*
* Create at least for each class a new headless environemnt as it is fast and prevents side effects
* (Reusing a headless environment after other tests have modified the core registry isn't really clean)
*/
env = new HeadlessEnvironment(new Name("engine"));
context = env.getContext();
assetManager = context.get(AssetManager.class);
blockManager = context.get(BlockManager.class);
config = context.get(Config.class);
audioManager = context.get(AudioManager.class);
collisionGroupManager = context.get(CollisionGroupManager.class);
moduleManager = context.get(ModuleManager.class);
}
use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.
the class InitialiseBlockTypeEntities method step.
@Override
public boolean step() {
BlockManagerImpl blockManager = (BlockManagerImpl) context.get(BlockManager.class);
blockManager.subscribe(new BlockTypeEntityGenerator(context.get(EntityManager.class), blockManager));
return true;
}
use of org.terasology.world.block.BlockManager 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.world.block.BlockManager in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupStorageManager.
@Override
protected void setupStorageManager() throws IOException {
ModuleManager moduleManager = context.get(ModuleManager.class);
EngineEntityManager engineEntityManager = context.get(EngineEntityManager.class);
BlockManager blockManager = context.get(BlockManager.class);
BiomeManager biomeManager = context.get(BiomeManager.class);
Path savePath = PathManager.getInstance().getSavePath("world1");
context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, blockManager, biomeManager));
}
use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.
the class TerasologyTestingEnvironment method setup.
@Before
public void setup() throws Exception {
context.put(ModuleManager.class, moduleManager);
mockTime = mock(EngineTime.class);
context.put(Time.class, mockTime);
NetworkSystemImpl networkSystem = new NetworkSystemImpl(mockTime, context);
context.put(Game.class, new Game());
context.put(NetworkSystem.class, networkSystem);
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
engineEntityManager = context.get(EngineEntityManager.class);
// 'mock' added to avoid hiding a field
BlockManager mockBlockManager = context.get(BlockManager.class);
BiomeManager biomeManager = context.get(BiomeManager.class);
Path savePath = PathManager.getInstance().getSavePath("world1");
context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, mockBlockManager, biomeManager));
componentSystemManager = new ComponentSystemManager(context);
context.put(ComponentSystemManager.class, componentSystemManager);
LoadPrefabs prefabLoadStep = new LoadPrefabs(context);
boolean complete = false;
prefabLoadStep.begin();
while (!complete) {
complete = prefabLoadStep.step();
}
context.get(ComponentSystemManager.class).initialise();
context.put(Console.class, new ConsoleImpl(context));
}
Aggregations