@Override public String toString() { return uri.toString(); }
@Override public String convertToString(BlockFamily value) { Preconditions.checkNotNull(value, "'value' must not be null!"); return value.getURI().toString(); } }
@Override public String getAsString(Block item) { if (item == null) { return ""; } return item.getURI().toString(); }
@Override public String toString() { String familyType = ""; RegisterBlockFamily registerInfo = this.getClass().getAnnotation(RegisterBlockFamily.class); if (registerInfo != null) { familyType = registerInfo.value(); } return "BlockFamily[" + familyType + "," + uri.toString() + "]"; } }
@Override public String getAsString(BlockFamily item) { if (item == null) { return ""; } return item.getURI().toString(); }
/** * List blocks that match searched string * * @param searchLowercase searched string * @return List of blocks that match searched string */ private List<String> findBlockMatches(String searchLowercase) { return assetManager.getAvailableAssets(BlockFamilyDefinition.class) .stream().<Optional<BlockFamilyDefinition>>map(urn -> assetManager.getAsset(urn, BlockFamilyDefinition.class)) .filter(def -> def.isPresent() && def.get().isLoadable() && matchesSearch(searchLowercase, def.get())) .map(r -> new BlockUri(r.get().getUrn()).toString()).collect(Collectors.toList()); }
private List<String> findBlockMatches(String searchLowercase) { return assetManager.getAvailableAssets(BlockFamilyDefinition.class) .stream().<Optional<BlockFamilyDefinition>>map(urn -> assetManager.getAsset(urn, BlockFamilyDefinition.class)) .filter(def -> def.isPresent() && def.get().isLoadable() && matchesSearch(searchLowercase, def.get())) .map(r -> new BlockUri(r.get().getUrn()).toString()).collect(Collectors.toList()); }
@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(); }
List<BlockUri> registeredBlocks = sortItems(blockManager.listRegisteredBlockUris()); for (BlockUri blockUri : registeredBlocks) { if (!uriStartsWithAnyString(blockUri.toString(), startsWith)) { continue; stringBuilder.append(blockUri.toString()); stringBuilder.append(Console.NEW_LINE); List<BlockUri> availableBlocks = sortItems(blockExplorer.getAvailableBlockFamilies()); for (BlockUri blockUri : availableBlocks) { if (!uriStartsWithAnyString(blockUri.toString(), startsWith)) { continue; stringBuilder.append(blockUri.toString()); stringBuilder.append(Console.NEW_LINE);
@Override public Map<String, Short> getBlockIdMap() { Map<String, Short> result = Maps.newHashMapWithExpectedSize(registeredBlockInfo.get().idByUri.size()); TObjectShortIterator<BlockUri> iterator = registeredBlockInfo.get().idByUri.iterator(); while (iterator.hasNext()) { iterator.advance(); result.put(iterator.key().toString(), iterator.value()); } return result; }
public void receiveFamilyRegistration(BlockUri familyUri, Map<String, Integer> registration) { Optional<BlockFamily> family = loadFamily(familyUri); if (family.isPresent()) { lock.lock(); try { for (Block block : family.get().getBlocks()) { Integer id = registration.get(block.getURI().toString()); if (id != null) { block.setId((short) id.intValue()); } else { logger.error("Missing id for block {} in registered family {}", block.getURI(), familyUri); block.setId(UNKNOWN_ID); } } registerFamily(family.get()); } finally { lock.unlock(); } } }
/** * @return Standalone mesh * @deprecated Use getMeshGenerator() instead. */ @Deprecated public Mesh getMesh() { if (meshGenerator != null) { return meshGenerator.getStandaloneMesh(); } return new Tessellator().generateMesh(new ResourceUrn("engine", "blockmesh", uri.toString())); }
if (family.isPresent()) { for (Block block : family.get().getBlocks()) { Short id = knownBlockMappings.get(block.getURI().toString()); if (id != null) { block.setId(id);
private void sendRegisteredBlocks(NetData.NetMessage.Builder message) { synchronized (newlyRegisteredFamilies) { for (BlockFamily family : newlyRegisteredFamilies) { NetData.BlockFamilyRegisteredMessage.Builder blockRegMessage = NetData.BlockFamilyRegisteredMessage.newBuilder(); for (Block block : family.getBlocks()) { blockRegMessage.addBlockUri(block.getURI().toString()); blockRegMessage.addBlockId(block.getId()); } message.addBlockFamilyRegistered(blockRegMessage); } newlyRegisteredFamilies.clear(); } }
item.stackId = "block:" + blockFamily.getURI().toString(); item.stackCount = (byte) quantity;
private void generateMesh() { Tessellator tessellator = new Tessellator(); for (BlockPart dir : BlockPart.values()) { BlockMeshPart part = block.getPrimaryAppearance().getPart(dir); if (part != null) { if (block.isDoubleSided()) { tessellator.addMeshPartDoubleSided(part); } else { tessellator.addMeshPart(part); } } } mesh = tessellator.generateMesh(new ResourceUrn("engine", "blockmesh", block.getURI().toString())); } }
registeredBlockFamilies.add(family.getURI().toString());
item.stackId = "block:" + blockFamily.getURI().toString(); item.stackCount = (byte) 1;
serverInfoMessageBuilder.addRegisterBlockFamily(registeredBlockFamily.getURI().toString());