use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.
the class UniverseSetupScreen method initAssets.
private void initAssets() {
ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
BlockFamilyLibrary library = new BlockFamilyLibrary(environment, context);
// 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> blockFamilyDefinitionDataAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionDataAssetType).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");
}
use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData 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);
}
use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData 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);
}
use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData 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);
}
use of org.terasology.engine.world.block.loader.BlockFamilyDefinitionData in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupAssetManager.
@Override
protected AssetManager setupAssetManager() {
ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
// 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> blockFamilyDefinitionDataAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionDataAssetType).addAssetFormat(new BlockFamilyDefinitionFormat(assetTypeManager.getAssetManager()));
assetTypeManager.createAssetType(StaticSound.class, NullSound::new, "sounds");
assetTypeManager.createAssetType(StreamingSound.class, NullStreamingSound::new, "music");
assetTypeManager.createAssetType(UISkinAsset.class, UISkinAsset::new, "skins");
assetTypeManager.createAssetType(BehaviorTree.class, BehaviorTree::new, "behaviors");
assetTypeManager.createAssetType(UIElement.class, UIElement::new, "ui");
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> textureDataAssetType = assetTypeManager.createAssetType(Texture.class, HeadlessTexture::create, "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(textureDataAssetType).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getPath().get(1).equals("textures")));
assetTypeManager.getAssetFileDataProducer(textureDataAssetType).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getPath().get(1).equals("fonts")));
assetTypeManager.createAssetType(Shader.class, HeadlessShader::new, "shaders");
assetTypeManager.createAssetType(Material.class, HeadlessMaterial::new, "materials");
assetTypeManager.createAssetType(Mesh.class, HeadlessMesh::new, "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, HeadlessSkeletalMesh::new, "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
assetTypeManager.switchEnvironment(context.get(ModuleManager.class).getEnvironment());
context.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
context.put(AssetManager.class, assetTypeManager.getAssetManager());
return assetTypeManager.getAssetManager();
}
Aggregations