Search in sources :

Example 1 with BlockManagerImpl

use of org.terasology.engine.world.block.internal.BlockManagerImpl in project Terasology by MovingBlocks.

the class BlockShapeTest method setup.

@BeforeEach
public void setup() throws Exception {
    super.setup();
    this.assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager);
    CoreRegistry.put(BlockManager.class, blockManager);
}
Also used : AssetManager(org.terasology.gestalt.assets.management.AssetManager) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with BlockManagerImpl

use of org.terasology.engine.world.block.internal.BlockManagerImpl in project Terasology by MovingBlocks.

the class InternalLightGeneratorTest method setup.

@BeforeEach
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager);
    CoreRegistry.put(BlockManager.class, blockManager);
    airBlock = blockManager.getBlock(BlockManager.AIR_ID);
    extraDataManager = new ExtraBlockDataManager();
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solidBlock = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    BlockFamilyDefinitionData fullLightData = new BlockFamilyDefinitionData();
    fullLightData.getBaseSection().setDisplayName("Torch");
    fullLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    fullLightData.getBaseSection().setLuminance(Chunks.MAX_LIGHT);
    fullLightData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
}
Also used : BlockUri(org.terasology.engine.world.block.BlockUri) AssetManager(org.terasology.gestalt.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BlockManagerImpl

use of org.terasology.engine.world.block.internal.BlockManagerImpl 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);
    TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
    typeHandlerLibrary.addTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    typeHandlerLibrary.addTypeHandler(Block.class, new BlockTypeHandler(blockManager));
}
Also used : TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) BlockTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) 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 4 with BlockManagerImpl

use of org.terasology.engine.world.block.internal.BlockManagerImpl 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 5 with BlockManagerImpl

use of org.terasology.engine.world.block.internal.BlockManagerImpl in project Terasology by MovingBlocks.

the class BetweenChunkPropagationTest method setup.

@BeforeEach
@Override
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    regenRules = new SunlightRegenPropagationRules();
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    extraDataManager = new ExtraBlockDataManager();
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    regenWorldView = new SunlightRegenWorldView(provider);
    lightWorldView = new SunlightWorldView(provider);
    lightRules = new SunlightPropagationRules(regenWorldView);
    sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
    propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Also used : BlockUri(org.terasology.engine.world.block.BlockUri) AssetManager(org.terasology.gestalt.assets.management.AssetManager) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) SunlightRegenWorldView(org.terasology.engine.world.propagation.light.SunlightRegenWorldView) SunlightPropagationRules(org.terasology.engine.world.propagation.light.SunlightPropagationRules) SunlightWorldView(org.terasology.engine.world.propagation.light.SunlightWorldView) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) SunlightRegenPropagationRules(org.terasology.engine.world.propagation.light.SunlightRegenPropagationRules) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)11 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)8 BeforeEach (org.junit.jupiter.api.BeforeEach)7 AssetManager (org.terasology.gestalt.assets.management.AssetManager)7 BlockUri (org.terasology.engine.world.block.BlockUri)6 BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)6 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)6 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)4 BlockFamilyTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)2 BlockTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler)2 BlockManager (org.terasology.engine.world.block.BlockManager)2 WorldAtlas (org.terasology.engine.world.block.tiles.WorldAtlas)2 SunlightPropagationRules (org.terasology.engine.world.propagation.light.SunlightPropagationRules)2 SunlightRegenPropagationRules (org.terasology.engine.world.propagation.light.SunlightRegenPropagationRules)2 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)2 Vector3i (org.joml.Vector3i)1 Vector3ic (org.joml.Vector3ic)1 Config (org.terasology.engine.config.Config)1 ModuleManager (org.terasology.engine.core.module.ModuleManager)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1