/** * @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; } }
/** * @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; } }
public Set<BlockUri> getFreeformBlockFamilies() { return assetManager.getAvailableAssets(BlockFamilyDefinition.class) .stream().<Optional<BlockFamilyDefinition>>map(urn -> assetManager.getAsset(urn, BlockFamilyDefinition.class)) .filter(def -> def.isPresent() && def.get().isLoadable() && def.get().isFreeform()) .map(r -> new BlockUri(r.get().getUrn())).collect(Collectors.toSet()); } }
public Set<BlockUri> getAvailableBlockFamilies() { return assetManager.getAvailableAssets(BlockFamilyDefinition.class) .stream().<Optional<BlockFamilyDefinition>>map(urn -> assetManager.getAsset(urn, BlockFamilyDefinition.class)) .filter(def -> def.isPresent() && def.get().isLoadable() && !def.get().isFreeform()) .map(r -> new BlockUri(r.get().getUrn())).collect(Collectors.toSet()); }
public static TreeGenerator redTree() { return new TreeGeneratorLSystem("FFFFFAFAFAF", ImmutableMap.<Character, LSystemRule>builder() .put('A', new LSystemRule("[&FFAFF]////[&FFAFF]////[&FFAFF]", 1.0f)).build(), 4, (float) Math.toRadians(40)) .setLeafType(new BlockUri("core:RedLeaf")) .setBarkType(new BlockUri("core:OakTrunk")); }
/** * 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()); }
@Override public Block getBlock(String uri) { try { return getBlock(new BlockUri(uri)); } catch (BlockUriParseException e) { logger.error("Attempt to fetch block with illegal uri '{}'", uri); return getAirBlock(); } }
public static TreeGenerator pineTree() { return new TreeGeneratorLSystem( "FFFFAFFFFFFFAFFFFA", ImmutableMap.<Character, LSystemRule>builder() .put('A', new LSystemRule("[&FFFFFA]////[&FFFFFA]////[&FFFFFA]", 1.0f)).build(), 4, (float) Math.toRadians(35)) .setLeafType(new BlockUri("core:DarkLeaf")) .setBarkType(new BlockUri("core:PineTrunk")); }
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()); }
public static TreeGenerator cactus() { return new TreeGeneratorCactus() .setTrunkType(new BlockUri("core:Cactus")); } }
public static TreeGenerator birchTree() { return new TreeGeneratorLSystem( "FFFFAFFFFBFFFFAFFFFBFFFFAFFFFBFF", ImmutableMap.<Character, LSystemRule>builder() .put('A', new LSystemRule("[&FFFAFFF]////[&FFAFFF]////[&FFFAFFF]", 1.0f)) .put('B', new LSystemRule("[&FAF]////[&FAF]////[&FAF]", 0.8f)).build(), 4, (float) Math.toRadians(35)) .setLeafType(new BlockUri("core:DarkLeaf")) .setBarkType(new BlockUri("core:BirchTrunk")); }
public static TreeGenerator oakTree() { return new TreeGeneratorLSystem( "FFFFFFA", ImmutableMap.<Character, LSystemRule>builder() .put('A', new LSystemRule("[&FFBFA]////[&BFFFA]////[&FBFFA]", 1.0f)) .put('B', new LSystemRule("[&FFFA]////[&FFFA]////[&FFFA]", 0.8f)).build(), 4, (float) Math.toRadians(30)) .setLeafType(new BlockUri("core:GreenLeaf")) .setBarkType(new BlockUri("core:OakTrunk")); }
public SymmetricFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) { super(definition, blockBuilder); block = blockBuilder.constructSimpleBlock(definition, new BlockUri(definition.getUrn()), this); }
public static TreeGenerator oakVariationTree() { return new TreeGeneratorLSystem( "FFFFFFA", ImmutableMap.<Character, LSystemRule>builder() .put('A', new LSystemRule("[&FFBFA]////[&BFFFA]////[&FBFFAFFA]", 1.0f)) .put('B', new LSystemRule("[&FFFAFFFF]////[&FFFAFFF]////[&FFFAFFAA]", 0.8f)).build(), 4, (float) Math.toRadians(35)) .setLeafType(new BlockUri("core:GreenLeaf")) .setBarkType(new BlockUri("core:OakTrunk")); }
public HorizontalFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) { super(definition, blockBuilder); BlockUri uri = new BlockUri(definition.getUrn()); for (Rotation rot : Rotation.horizontalRotations()) { Side side = rot.rotate(Side.FRONT); Block block = blockBuilder.constructTransformedBlock(definition, side.toString().toLowerCase(Locale.ENGLISH), rot, new BlockUri(uri, new Name(side.name())), this); if (block == null) { throw new IllegalArgumentException("Missing block for side: " + side.toString()); } blocks.put(side, block); } }
public SymmetricFamily(BlockFamilyDefinition definition, BlockShape shape, BlockBuilderHelper blockBuilder) { super(definition, shape, blockBuilder); BlockUri uri; if (CUBE_SHAPE_URN.equals(shape.getUrn())) { uri = new BlockUri(definition.getUrn()); } else { uri = new BlockUri(definition.getUrn(), shape.getUrn()); } block = blockBuilder.constructSimpleBlock(definition, shape, uri, this); setBlockUri(uri); }
protected AbstractBlockFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) { setBlockUri(new BlockUri(definition.getUrn())); setCategory(definition.getCategories()); }
protected AbstractBlockFamily(BlockFamilyDefinition definition, BlockShape shape, BlockBuilderHelper blockBuilder) { setBlockUri(new BlockUri(definition.getUrn())); setCategory(definition.getCategories()); }
@Before public void setup() throws IOException { AssetManager assetManager = CoreRegistry.get(AssetManager.class); blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager); CoreRegistry.put(BlockManager.class, blockManager); airBlock = blockManager.getBlock(BlockManager.AIR_ID); biomeManager = Mockito.mock(BiomeManager.class); 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); solidBlock = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone"))); }