Search in sources :

Example 1 with BlockFamilyLibrary

use of org.terasology.engine.world.block.family.BlockFamilyLibrary 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);
    RecordAndReplaySerializer recordAndReplaySerializer = context.get(RecordAndReplaySerializer.class);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    RecordAndReplayUtils recordAndReplayUtils = new RecordAndReplayUtils();
    RecordAndReplayCurrentStatus recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
    context.put(BlockFamilyLibrary.class, new BlockFamilyLibrary(environment, context));
    ExtraBlockDataManager extraDataManager = context.get(ExtraBlockDataManager.class);
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, blockManager, extraDataManager, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus));
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) Path(java.nio.file.Path) BlockManager(org.terasology.engine.world.block.BlockManager) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) BlockFamilyLibrary(org.terasology.engine.world.block.family.BlockFamilyLibrary) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ReadWriteStorageManager(org.terasology.engine.persistence.internal.ReadWriteStorageManager) ModuleManager(org.terasology.engine.core.module.ModuleManager) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer)

Example 2 with BlockFamilyLibrary

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

the class RegisterBlocks method step.

@Override
public boolean step() {
    NetworkSystem networkSystem = context.get(NetworkSystem.class);
    WorldAtlas atlas = new WorldAtlasImpl(context.get(Config.class).getRendering().getMaxTextureAtlasResolution());
    context.put(WorldAtlas.class, atlas);
    ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
    context.put(BlockFamilyLibrary.class, new BlockFamilyLibrary(environment, context));
    BlockManagerImpl blockManager;
    if (networkSystem.getMode().isAuthority()) {
        blockManager = new BlockManagerImpl(atlas, context.get(AssetManager.class), true);
        blockManager.subscribe(context.get(NetworkSystem.class));
    } else {
        blockManager = new BlockManagerImpl(atlas, context.get(AssetManager.class), false);
    }
    context.put(BlockManager.class, blockManager);
    context.get(TypeHandlerLibrary.class).addTypeHandler(Block.class, new BlockTypeHandler(blockManager));
    context.get(TypeHandlerLibrary.class).addTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    blockManager.initialise(gameManifest.getRegisteredBlockFamilies(), gameManifest.getBlockIdMap());
    return true;
}
Also used : WorldAtlasImpl(org.terasology.engine.world.block.tiles.WorldAtlasImpl) Config(org.terasology.engine.config.Config) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NetworkSystem(org.terasology.engine.network.NetworkSystem) BlockFamilyLibrary(org.terasology.engine.world.block.family.BlockFamilyLibrary) ModuleManager(org.terasology.engine.core.module.ModuleManager) BlockTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.engine.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 3 with BlockFamilyLibrary

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

the class UniverseSetupScreen method initAssets.

private void initAssets() {
    ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
    BlockFamilyLibrary library = new BlockFamilyLibrary(environment, context);
    // cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
    assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
    assetTypeManager.createAssetType(BlockShape.class, BlockShapeImpl::new, "shapes");
    assetTypeManager.createAssetType(BlockSounds.class, BlockSounds::new, "blockSounds");
    assetTypeManager.createAssetType(BlockTile.class, BlockTile::new, "blockTiles");
    AssetType<BlockFamilyDefinition, BlockFamilyDefinitionData> blockFamilyDefinitionDataAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
    assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionDataAssetType).addAssetFormat(new BlockFamilyDefinitionFormat(assetTypeManager.getAssetManager()));
    assetTypeManager.createAssetType(UISkinAsset.class, UISkinAsset::new, "skins");
    assetTypeManager.createAssetType(BehaviorTree.class, BehaviorTree::new, "behaviors");
    assetTypeManager.createAssetType(UIElement.class, UIElement::new, "ui");
}
Also used : PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) BlockShapeImpl(org.terasology.engine.world.block.shapes.BlockShapeImpl) UIElement(org.terasology.nui.asset.UIElement) UISkinAsset(org.terasology.nui.skin.UISkinAsset) BlockFamilyDefinitionFormat(org.terasology.engine.world.block.loader.BlockFamilyDefinitionFormat) BlockFamilyLibrary(org.terasology.engine.world.block.family.BlockFamilyLibrary) BlockTile(org.terasology.engine.world.block.tiles.BlockTile) ModuleManager(org.terasology.engine.core.module.ModuleManager) BehaviorTree(org.terasology.engine.logic.behavior.asset.BehaviorTree) BlockSounds(org.terasology.engine.world.block.sounds.BlockSounds) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) BlockFamilyDefinition(org.terasology.engine.world.block.loader.BlockFamilyDefinition)

Aggregations

ModuleManager (org.terasology.engine.core.module.ModuleManager)3 BlockFamilyLibrary (org.terasology.engine.world.block.family.BlockFamilyLibrary)3 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)3 Path (java.nio.file.Path)1 Config (org.terasology.engine.config.Config)1 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)1 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)1 BehaviorTree (org.terasology.engine.logic.behavior.asset.BehaviorTree)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1 ReadWriteStorageManager (org.terasology.engine.persistence.internal.ReadWriteStorageManager)1 BlockFamilyTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)1 BlockTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler)1 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)1 RecordAndReplaySerializer (org.terasology.engine.recording.RecordAndReplaySerializer)1 RecordAndReplayUtils (org.terasology.engine.recording.RecordAndReplayUtils)1 BlockManager (org.terasology.engine.world.block.BlockManager)1 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)1 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)1 BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)1 BlockFamilyDefinitionFormat (org.terasology.engine.world.block.loader.BlockFamilyDefinitionFormat)1