Search in sources :

Example 56 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class ComponentMetadataTest method testStaticFieldsIgnored.

@Test
public void testStaticFieldsIgnored() {
    Reflections reflections = new Reflections(getClass().getClassLoader());
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeHandlerLibraryImpl(reflections));
    ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
    lib.register(new ResourceUrn("unittest:string"), StringComponent.class);
    ComponentMetadata<StringComponent> metadata = lib.getMetadata(StringComponent.class);
    assertNull(metadata.getField("STATIC_VALUE"));
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Reflections(org.reflections.Reflections) Test(org.junit.jupiter.api.Test)

Example 57 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class ChunkTest 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);
    ExtraBlockDataManager extraDataManager = new ExtraBlockDataManager();
    chunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, extraDataManager);
    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")));
}
Also used : BlockUri(org.terasology.engine.world.block.BlockUri) AssetManager(org.terasology.gestalt.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ChunkImpl(org.terasology.engine.world.chunks.internal.ChunkImpl) Vector3i(org.joml.Vector3i) 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 58 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method createBlock.

private Block createBlock(String urn, AssetManager assetManager, BlockManager blockManager) {
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setBlockFamily(SymmetricFamily.class);
    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 59 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method createPrefabWithString.

private Prefab createPrefabWithString(String urn, String text, AssetManager assetManager) {
    PrefabData prefabData = new PrefabData();
    prefabData.addComponent(new StringComponent(text));
    return assetManager.loadAsset(new ResourceUrn(urn), prefabData, Prefab.class);
}
Also used : PrefabData(org.terasology.engine.entitySystem.prefab.PrefabData) StringComponent(org.terasology.unittest.stubs.StringComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn)

Example 60 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class ChunkViewTest method setup.

@BeforeEach
public void setup() throws IOException {
    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")));
}
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)

Aggregations

ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)90 Test (org.junit.jupiter.api.Test)19 Name (org.terasology.gestalt.naming.Name)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)10 IOException (java.io.IOException)9 AssetManager (org.terasology.gestalt.assets.management.AssetManager)9 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)8 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)8 PrefabData (org.terasology.engine.entitySystem.prefab.PrefabData)7 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)7 BlockUri (org.terasology.engine.world.block.BlockUri)7 AssetDataFile (org.terasology.gestalt.assets.format.AssetDataFile)7 Texture (org.terasology.engine.rendering.assets.texture.Texture)5 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)5 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)5 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)5 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)5 StringComponent (org.terasology.unittest.stubs.StringComponent)5 ByteBuffer (java.nio.ByteBuffer)4