Search in sources :

Example 46 with ResourceUrn

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

the class BulkLightPropagationTest method setup.

@BeforeEach
public void setup() throws Exception {
    super.setup();
    lightRules = new LightPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    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.getBaseSection().setTranslucent(true);
    fullLightData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
    BlockFamilyDefinitionData weakLightData = new BlockFamilyDefinitionData();
    weakLightData.getBaseSection().setDisplayName("PartLight");
    weakLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    weakLightData.getBaseSection().setLuminance((byte) 2);
    weakLightData.getBaseSection().setTranslucent(true);
    weakLightData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:weakLight"), weakLightData, BlockFamilyDefinition.class);
    weakLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:weakLight")));
    BlockFamilyDefinitionData mediumLightData = new BlockFamilyDefinitionData();
    mediumLightData.getBaseSection().setDisplayName("MediumLight");
    mediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    mediumLightData.getBaseSection().setLuminance((byte) 5);
    mediumLightData.getBaseSection().setTranslucent(true);
    mediumLightData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:mediumLight"), mediumLightData, BlockFamilyDefinition.class);
    mediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:mediumLight")));
    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")));
    BlockFamilyDefinitionData solidMediumLightData = new BlockFamilyDefinitionData();
    solidMediumLightData.getBaseSection().setDisplayName("SolidMediumLight");
    solidMediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidMediumLightData.getBaseSection().setTranslucent(false);
    solidMediumLightData.getBaseSection().setLuminance((byte) 5);
    solidMediumLightData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:solidMediumLight"), solidMediumLightData, BlockFamilyDefinition.class);
    solidMediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:solidMediumLight")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
}
Also used : LightPropagationRules(org.terasology.engine.world.propagation.light.LightPropagationRules) 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) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 47 with ResourceUrn

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

the class BulkSunlightPropagationTest method setup.

@BeforeEach
public void setup() throws Exception {
    super.setup();
    regenRules = new SunlightRegenPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    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")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
    Map<Vector3ic, Block> blockData = Maps.newHashMap();
    regenWorldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air, blockData);
    lightWorldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air, blockData);
    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) SunlightPropagationRules(org.terasology.engine.world.propagation.light.SunlightPropagationRules) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) Vector3ic(org.joml.Vector3ic) Block(org.terasology.engine.world.block.Block) 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)

Example 48 with ResourceUrn

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

the class TranslationFormatTests method testDataGenGerman.

@Test
public void testDataGenGerman() throws IOException, InvalidAssetFilenameException {
    byte[] resource = createSimpleTranslationFile().getBytes(StandardCharsets.UTF_8);
    AssetDataFile assetDataFile = mockAssetDataFile("menu_de-DE.lang", resource);
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    assertEquals("Einzelspieler", data.getTranslations().get("engine:mainMenuScreen#singleplayer#text"));
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 49 with ResourceUrn

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

the class TranslationFormatTests method testEmptyDataGenRoot.

@Test
public void testEmptyDataGenRoot() throws IOException, InvalidAssetFilenameException {
    AssetDataFile assetDataFile = mockAssetDataFile("menu.lang", "{}".getBytes(StandardCharsets.UTF_8));
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    assertEquals(new ResourceUrn("engine:menu"), data.getProjectUrn());
    assertEquals(Locale.ROOT, data.getLocale());
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 50 with ResourceUrn

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

the class TranslationSystemImpl method onAssetChanged.

private void onAssetChanged(Translation trans) {
    ResourceUrn uri = trans.getProjectUrn();
    TranslationProject project = projects.get(uri);
    if (trans.isDisposed()) {
        project.remove(trans);
    }
    for (Consumer<TranslationProject> listener : changeListeners) {
        listener.accept(project);
    }
}
Also used : ResourceUrn(org.terasology.gestalt.assets.ResourceUrn)

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