use of org.terasology.world.block.BlockUri in project Terasology by MovingBlocks.
the class BlockCommands method listFreeShapeBlocks.
@Command(shortDescription = "Lists available free shape blocks", helpText = "Lists all the available free shape blocks. These blocks can be created with any shape.\n" + "You can filter by adding the beginning of words after the commands, e.g.: \"listFreeShapeBlocks" + "engine: core:\" will list all free shape blocks from the engine and core module", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String listFreeShapeBlocks(@CommandParam(value = "startsWith", required = false) String[] startsWith) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Free Shape Blocks");
stringBuilder.append(Console.NEW_LINE);
stringBuilder.append("-----------------");
stringBuilder.append(Console.NEW_LINE);
List<BlockUri> sortedUris = sortItems(blockExplorer.getFreeformBlockFamilies());
for (BlockUri uri : sortedUris) {
if (!uriStartsWithAnyString(uri.toString(), startsWith)) {
continue;
}
stringBuilder.append(uri.toString());
stringBuilder.append(Console.NEW_LINE);
}
return stringBuilder.toString();
}
use of org.terasology.world.block.BlockUri in project Terasology by MovingBlocks.
the class AttachedToSurfaceFamilyFactory method createBlockFamily.
@Override
public BlockFamily createBlockFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) {
Map<Side, Block> blockMap = Maps.newEnumMap(Side.class);
if (definition.getData().hasSection("top")) {
Block block = blockBuilder.constructSimpleBlock(definition, "top");
block.setDirection(Side.TOP);
blockMap.put(Side.TOP, block);
}
if (definition.getData().hasSection("front")) {
for (Rotation rot : Rotation.horizontalRotations()) {
Side side = rot.rotate(Side.FRONT);
blockMap.put(side, blockBuilder.constructTransformedBlock(definition, side.toString().toLowerCase(Locale.ENGLISH), rot));
}
}
if (definition.getData().hasSection("bottom")) {
Block block = blockBuilder.constructSimpleBlock(definition, "bottom");
block.setDirection(Side.BOTTOM);
blockMap.put(Side.BOTTOM, block);
}
return new AttachedToSurfaceFamily(new BlockUri(definition.getUrn()), blockMap, definition.getCategories());
}
use of org.terasology.world.block.BlockUri in project Terasology by MovingBlocks.
the class HorizontalBlockFamilyFactory method createBlockFamily.
@Override
public BlockFamily createBlockFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) {
if (definition.isFreeform()) {
throw new IllegalStateException("A shape must be provided when creating a family for a freeform block family definition");
}
Map<Side, Block> blockMap = Maps.newHashMap();
for (Rotation rot : Rotation.horizontalRotations()) {
Side side = rot.rotate(Side.FRONT);
blockMap.put(side, blockBuilder.constructTransformedBlock(definition, side.toString().toLowerCase(Locale.ENGLISH), rot));
}
return new HorizontalBlockFamily(new BlockUri(definition.getUrn()), getArchetypeSide(), blockMap, definition.getCategories());
}
use of org.terasology.world.block.BlockUri in project Terasology by MovingBlocks.
the class BulkLightPropagationTest method setup.
@Before
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(ChunkConstants.MAX_LIGHT);
fullLightData.getBaseSection().setTranslucent(true);
fullLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
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.setFamilyFactory(new SymmetricBlockFamilyFactory());
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.setFamilyFactory(new SymmetricBlockFamilyFactory());
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.setFamilyFactory(new SymmetricBlockFamilyFactory());
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.setFamilyFactory(new SymmetricBlockFamilyFactory());
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.world.block.BlockUri in project Terasology by MovingBlocks.
the class BulkSunlightPropagationTest method setup.
@Before
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.setFamilyFactory(new SymmetricBlockFamilyFactory());
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<Vector3i, Block> blockData = Maps.newHashMap();
regenWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
lightWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
lightRules = new SunlightPropagationRules(regenWorldView);
sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Aggregations