Search in sources :

Example 1 with BlockTypeHandler

use of org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler 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);
    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(TypeSerializationLibrary.class).add(Block.class, new BlockTypeHandler(blockManager));
    context.get(TypeSerializationLibrary.class).add(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    blockManager.initialise(gameManifest.getRegisteredBlockFamilies(), gameManifest.getBlockIdMap());
    return true;
}
Also used : WorldAtlasImpl(org.terasology.world.block.tiles.WorldAtlasImpl) Config(org.terasology.config.Config) NetworkSystem(org.terasology.network.NetworkSystem) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 2 with BlockTypeHandler

use of org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler in project Terasology by MovingBlocks.

the class HeadlessEnvironment method setupBlockManager.

@Override
protected void setupBlockManager(AssetManager assetManager) {
    WorldAtlas worldAtlas = new NullWorldAtlas();
    BlockManagerImpl blockManager = new BlockManagerImpl(worldAtlas, assetManager);
    context.put(BlockManager.class, blockManager);
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    typeSerializationLibrary.add(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    typeSerializationLibrary.add(Block.class, new BlockTypeHandler(blockManager));
}
Also used : NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Aggregations

TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)2 BlockFamilyTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)2 BlockTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler)2 BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)2 WorldAtlas (org.terasology.world.block.tiles.WorldAtlas)2 Config (org.terasology.config.Config)1 NetworkSystem (org.terasology.network.NetworkSystem)1 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)1 WorldAtlasImpl (org.terasology.world.block.tiles.WorldAtlasImpl)1