/** * @return The uri of the block's family, including shape */ public BlockUri getFamilyUri() { if (!blockName.isEmpty()) { return new BlockUri(blockFamilyDefinition, shape, Name.EMPTY); } else { return this; } }
/** * @return The uri of the block's family, excluding shape */ public BlockUri getRootFamilyUri() { if (!blockName.isEmpty() || shape.isPresent()) { return new BlockUri(blockFamilyDefinition); } else { return this; } }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(blockFamilyDefinition.toString()); if (shape.isPresent()) { builder.append(MODULE_SEPARATOR); builder.append(shape.get().toString()); } if (!blockName.isEmpty()) { builder.append(IDENTIFIER_SEPARATOR); builder.append(blockName.toString()); } return builder.toString(); }
@Override public Optional<MaterialData> getAssetData(ResourceUrn urn) throws IOException { if (RESOURCE_NAME.equals(urn.getResourceName()) && !urn.getFragmentName().isEmpty()) { Optional<? extends Shader> fontShader = assetManager.getAsset(FONT_SHADER_URN, Shader.class); if (!fontShader.isPresent()) { logger.error("Unable to resolve font shader"); return Optional.empty(); } Optional<Texture> texture = assetManager.getAsset(new ResourceUrn(urn.getModuleName(), urn.getFragmentName()), Texture.class); if (texture.isPresent()) { MaterialData materialData = new MaterialData(fontShader.get()); materialData.setParam("texture", texture.get()); return Optional.of(materialData); } } return Optional.empty(); } }
@Override public Optional<TextureData> getAssetData(ResourceUrn urn) throws IOException { if (TerasologyConstants.ENGINE_MODULE.equals(urn.getModuleName()) && TextureUtil.NOISE_RESOURCE_NAME.equals(urn.getResourceName())) { Name fragmentName = urn.getFragmentName(); if (!fragmentName.isEmpty()) { String[] parts = fragmentName.toLowerCase().split("\\."); if (parts.length == 5) { String type = parts[0]; int size = Integer.parseInt(parts[1]); long seed = Long.parseLong(parts[2]); int min = Integer.parseInt(parts[3]); int max = Integer.parseInt(parts[4]); TextureData textureData; switch (type) { case "white": return Optional.of(TextureDataFactory.createWhiteNoiseTexture(size, seed, min, max)); } } } } return Optional.empty(); } }
public BlockUri getShapelessUri() { if (!getIdentifier().isEmpty()) { return new BlockUri(blockFamilyDefinition, getIdentifier()); } else { return new BlockUri(blockFamilyDefinition); } } }
@Override public Block getBlockFor(BlockUri blockUri) { if (getURI().equals(blockUri.getFamilyUri()) && blockUri.getIdentifier().isEmpty()) { return block; } return null; }
@Override public Optional<TextureData> getAssetData(ResourceUrn urn) throws IOException { if (TerasologyConstants.ENGINE_MODULE.equals(urn.getModuleName()) && TextureUtil.COLOR_RESOURCE_NAME.equals(urn.getResourceName())) { Name fragmentName = urn.getFragmentName(); if (!fragmentName.isEmpty()) { Color color = TextureUtil.getColorForColorName(fragmentName.toLowerCase()); return Optional.of(TextureDataFactory.newInstance(color)); } } return Optional.empty(); } }
public static Mesh getIconMesh(TextureRegion region) { if (region instanceof Asset) { ResourceUrn urn = ((Asset<?>) region).getUrn(); if (urn.getFragmentName().isEmpty()) { return Assets.get(new ResourceUrn(urn.getModuleName(), IconMeshDataProducer.ICON_DISCRIMINATOR, urn.getResourceName()), Mesh.class).get(); } else { Name fragName = new Name(urn.getResourceName().toString() + ResourceUrn.FRAGMENT_SEPARATOR + urn.getFragmentName().toString()); return Assets.get(new ResourceUrn(urn.getModuleName(), IconMeshDataProducer.ICON_DISCRIMINATOR, fragName), Mesh.class).get(); } } else { return generateIconMesh(region); } }
@Override public boolean execute(Name commandName, List<String> params, EntityRef callingClient) { if (commandName.isEmpty()) { return false;