Search in sources :

Example 1 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class ReadWriteStorageManager method addGameManifestToSaveTransaction.

private void addGameManifestToSaveTransaction(SaveTransactionBuilder saveTransactionBuilder) {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    BiomeManager biomeManager = CoreRegistry.get(BiomeManager.class);
    WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
    Time time = CoreRegistry.get(Time.class);
    Game game = CoreRegistry.get(Game.class);
    GameManifest gameManifest = new GameManifest(game.getName(), game.getSeed(), time.getGameTimeInMs());
    for (Module module : CoreRegistry.get(ModuleManager.class).getEnvironment()) {
        gameManifest.addModule(module.getId(), module.getVersion());
    }
    List<String> registeredBlockFamilies = Lists.newArrayList();
    for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) {
        registeredBlockFamilies.add(family.getURI().toString());
    }
    gameManifest.setRegisteredBlockFamilies(registeredBlockFamilies);
    gameManifest.setBlockIdMap(blockManager.getBlockIdMap());
    List<Biome> biomes = biomeManager.getBiomes();
    Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
    for (Biome biome : biomes) {
        short shortId = biomeManager.getBiomeShortId(biome);
        String id = biomeManager.getBiomeId(biome);
        biomeIdMap.put(id, shortId);
    }
    gameManifest.setBiomeIdMap(biomeIdMap);
    gameManifest.addWorld(worldProvider.getWorldInfo());
    saveTransactionBuilder.setGameManifest(gameManifest);
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) HashMap(java.util.HashMap) Time(org.terasology.engine.Time) ModuleManager(org.terasology.engine.module.ModuleManager) Game(org.terasology.game.Game) Biome(org.terasology.world.biomes.Biome) GameManifest(org.terasology.game.GameManifest) BlockManager(org.terasology.world.block.BlockManager) WorldProvider(org.terasology.world.WorldProvider) BlockFamily(org.terasology.world.block.family.BlockFamily) Module(org.terasology.module.Module)

Example 2 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class FloraRasterizer method initialize.

@Override
public void initialize() {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    air = blockManager.getBlock(BlockManager.AIR_ID);
    flora.put(FloraType.GRASS, ImmutableList.<Block>of(blockManager.getBlock("core:TallGrass1"), blockManager.getBlock("core:TallGrass2"), blockManager.getBlock("core:TallGrass3")));
    flora.put(FloraType.FLOWER, ImmutableList.<Block>of(blockManager.getBlock("core:Dandelion"), blockManager.getBlock("core:Glowbell"), blockManager.getBlock("core:Iris"), blockManager.getBlock("core:Lavender"), blockManager.getBlock("core:RedClover"), blockManager.getBlock("core:RedFlower"), blockManager.getBlock("core:Tulip"), blockManager.getBlock("core:YellowFlower")));
    flora.put(FloraType.MUSHROOM, ImmutableList.<Block>of(blockManager.getBlock("core:BigBrownShroom"), blockManager.getBlock("core:BrownShroom"), blockManager.getBlock("core:RedShroom")));
}
Also used : BlockManager(org.terasology.world.block.BlockManager)

Example 3 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class GroundRasterizer method initialize.

@Override
public void initialize() {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    stone = blockManager.getBlock("core:stone");
    water = blockManager.getBlock("core:water");
}
Also used : BlockManager(org.terasology.world.block.BlockManager)

Example 4 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class SolidRasterizer method initialize.

@Override
public void initialize() {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    stone = blockManager.getBlock("core:stone");
    water = blockManager.getBlock("core:water");
    ice = blockManager.getBlock("core:Ice");
    sand = blockManager.getBlock("core:Sand");
    grass = blockManager.getBlock("core:Grass");
    snow = blockManager.getBlock("core:Snow");
    dirt = blockManager.getBlock("core:Dirt");
}
Also used : BlockManager(org.terasology.world.block.BlockManager)

Example 5 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class TreeTests method setup.

@Before
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    // Needed only as long as #1536 is unresolved
    context.put(Config.class, new Config(new MockContext()));
    blockManager = Mockito.mock(BlockManager.class);
    Block air = blockManager.getBlock(BlockManager.AIR_ID);
    biomeManager = Mockito.mock(BiomeManager.class);
    Mockito.when(blockManager.getBlock(Matchers.<BlockUri>any())).thenReturn(air);
    Mockito.when(blockManager.getBlock(Matchers.<String>any())).thenReturn(air);
    context.put(BlockManager.class, blockManager);
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) MockContext(org.terasology.context.internal.MockContext) Config(org.terasology.config.Config) BlockManager(org.terasology.world.block.BlockManager) Block(org.terasology.world.block.Block) ContextImpl(org.terasology.context.internal.ContextImpl) Before(org.junit.Before)

Aggregations

BlockManager (org.terasology.world.block.BlockManager)16 BiomeManager (org.terasology.world.biomes.BiomeManager)6 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)5 Before (org.junit.Before)4 ModuleManager (org.terasology.engine.module.ModuleManager)4 WorldProvider (org.terasology.world.WorldProvider)4 Block (org.terasology.world.block.Block)4 Path (java.nio.file.Path)3 AssetManager (org.terasology.assets.management.AssetManager)3 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 EntityAwareWorldProvider (org.terasology.world.internal.EntityAwareWorldProvider)3 FileSystem (java.nio.file.FileSystem)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 ResourceUrn (org.terasology.assets.ResourceUrn)2 Config (org.terasology.config.Config)2 RenderingSubsystemFactory (org.terasology.engine.subsystem.RenderingSubsystemFactory)2 Game (org.terasology.game.Game)2 LocalPlayer (org.terasology.logic.players.LocalPlayer)2 ModuleEnvironment (org.terasology.module.ModuleEnvironment)2 NetworkSystem (org.terasology.network.NetworkSystem)2