Search in sources :

Example 1 with BlockFamilyDefinitionData

use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.

the class StorageManagerTest method setup.

@BeforeEach
public void setup(@TempDir Path tempHome) throws Exception {
    super.setup();
    PathManager.getInstance().useOverrideHomePath(tempHome);
    savePath = PathManager.getInstance().getSavePath("testSave");
    assert !Files.isRegularFile(tempHome.resolve("global.dat"));
    entityManager = context.get(EngineEntityManager.class);
    moduleEnvironment = mock(ModuleEnvironment.class);
    blockManager = context.get(BlockManager.class);
    extraDataManager = context.get(ExtraBlockDataManager.class);
    ModuleManager moduleManager = mock(ModuleManager.class);
    when(moduleManager.getEnvironment()).thenReturn(moduleEnvironment);
    RecordedEventStore recordedEventStore = new RecordedEventStore();
    recordAndReplayUtils = new RecordAndReplayUtils();
    CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
    recordAndReplaySerializer = new RecordAndReplaySerializer(entityManager, recordedEventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, mock(TypeRegistry.class));
    recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    esm = new ReadWriteStorageManager(savePath, moduleEnvironment, entityManager, blockManager, extraDataManager, false, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
    context.put(StorageManager.class, esm);
    this.character = entityManager.create();
    Client client = createClientMock(PLAYER_ID, character);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    when(networkSystem.getPlayers()).thenReturn(Arrays.asList(client));
    context.put(NetworkSystem.class, networkSystem);
    AssetManager assetManager = context.get(AssetManager.class);
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock"), data, BlockFamilyDefinition.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock2"), data, BlockFamilyDefinition.class);
    testBlock = context.get(BlockManager.class).getBlock("test:testblock");
    testBlock2 = context.get(BlockManager.class).getBlock("test:testblock2");
    context.put(ChunkProvider.class, mock(ChunkProvider.class));
    WorldProvider worldProvider = mock(WorldProvider.class);
    when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo());
    context.put(WorldProvider.class, worldProvider);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) AssetManager(org.terasology.gestalt.assets.management.AssetManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) RecordedEventStore(org.terasology.engine.recording.RecordedEventStore) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) ModuleManager(org.terasology.engine.core.module.ModuleManager) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) BlockManager(org.terasology.engine.world.block.BlockManager) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) WorldProvider(org.terasology.engine.world.WorldProvider) WorldInfo(org.terasology.engine.world.internal.WorldInfo) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) Client(org.terasology.engine.network.Client) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ChunkProvider(org.terasology.engine.world.chunks.ChunkProvider) CharacterStateEventPositionMap(org.terasology.engine.recording.CharacterStateEventPositionMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with BlockFamilyDefinitionData

use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method createBlockWithPrefab.

private Block createBlockWithPrefab(String urn, Prefab prefab, boolean keepActive, AssetManager assetManager, BlockManager blockManager) {
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setBlockFamily(SymmetricFamily.class);
    data.getBaseSection().getEntity().setPrefab(prefab);
    data.getBaseSection().getEntity().setKeepActive(keepActive);
    assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class);
    return blockManager.getBlock(urn);
}
Also used : BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn)

Example 3 with BlockFamilyDefinitionData

use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method createBlockFamily.

private BlockFamily createBlockFamily(String urn, Prefab prefab, AssetManager assetManager, BlockManager blockManager) {
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setBlockFamily(HorizontalFamily.class);
    data.getBaseSection().getEntity().setKeepActive(true);
    data.getBaseSection().getEntity().setPrefab(prefab);
    assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class);
    return blockManager.getBlockFamily(urn);
}
Also used : BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn)

Example 4 with BlockFamilyDefinitionData

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

use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.

the class TerasologyEngine method initAssets.

private void initAssets() {
    // 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> blockFamilyDefinitionAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
    assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionAssetType).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");
    assetTypeManager.createAssetType(ByteBufferAsset.class, ByteBufferAsset::new, "mesh");
    for (EngineSubsystem subsystem : allSubsystems) {
        subsystem.registerCoreAssetTypes(assetTypeManager);
    }
}
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) BlockTile(org.terasology.engine.world.block.tiles.BlockTile) BehaviorTree(org.terasology.engine.logic.behavior.asset.BehaviorTree) ByteBufferAsset(org.terasology.engine.rendering.gltf.ByteBufferAsset) BlockSounds(org.terasology.engine.world.block.sounds.BlockSounds) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) EngineSubsystem(org.terasology.engine.core.subsystem.EngineSubsystem) BlockFamilyDefinition(org.terasology.engine.world.block.loader.BlockFamilyDefinition)

Aggregations

BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)13 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)10 AssetManager (org.terasology.gestalt.assets.management.AssetManager)8 BeforeEach (org.junit.jupiter.api.BeforeEach)7 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)7 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)7 BlockUri (org.terasology.engine.world.block.BlockUri)6 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)6 ModuleManager (org.terasology.engine.core.module.ModuleManager)3 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)2 BehaviorTree (org.terasology.engine.logic.behavior.asset.BehaviorTree)2 Block (org.terasology.engine.world.block.Block)2 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)2 BlockFamilyDefinitionFormat (org.terasology.engine.world.block.loader.BlockFamilyDefinitionFormat)2 BlockShapeImpl (org.terasology.engine.world.block.shapes.BlockShapeImpl)2 BlockSounds (org.terasology.engine.world.block.sounds.BlockSounds)2 BlockTile (org.terasology.engine.world.block.tiles.BlockTile)2 SunlightPropagationRules (org.terasology.engine.world.propagation.light.SunlightPropagationRules)2 SunlightRegenPropagationRules (org.terasology.engine.world.propagation.light.SunlightRegenPropagationRules)2 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)2