public boolean isFreeform() { return BlockFamilyLibrary.isFreeformSupported(getData().getBlockFamily()); }
public BlockFamily createFamily(BlockBuilderHelper blockBuilderHelper) { Preconditions.checkState(!isFreeform()); return BlockFamilyLibrary.createFamily(getData().getBlockFamily(), this, blockBuilderHelper); }
public BlockFamily createFamily(BlockShape shape, BlockBuilderHelper blockBuilderHelper) { Preconditions.checkState(isFreeform()); return BlockFamilyLibrary.createFamily(getData().getBlockFamily(), this, shape, blockBuilderHelper); }
private BlockFamilyDefinitionData createBaseData(JsonObject jsonObject) { JsonPrimitive basedOn = jsonObject.getAsJsonPrimitive("basedOn"); if (basedOn != null && !basedOn.getAsString().isEmpty()) { Optional<BlockFamilyDefinition> baseDef = assetManager.getAsset(basedOn.getAsString(), BlockFamilyDefinition.class); if (baseDef.isPresent()) { BlockFamilyDefinitionData data = baseDef.get().getData(); if (data.getBlockFamily() == FreeformFamily.class) { data.setBlockFamily(null); } return data; } else { throw new JsonParseException("Unable to resolve based block definition '" + basedOn.getAsString() + "'"); } } BlockFamilyDefinitionData data = new BlockFamilyDefinitionData(); data.getBaseSection().setSounds(assetManager.getAsset("engine:default", BlockSounds.class).get()); return data; } }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getBaseSection().getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getBaseSection(), uri, blockFamily); }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, String section, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getSection(section).getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getSection(section), uri, blockFamily); }
@Override public Block constructSimpleBlock(BlockFamilyDefinition definition, String section, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getSection(section).getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, Rotation.none(), definition.getData().getSection(section), uri, blockFamily); }
@Override public Block constructSimpleBlock(BlockFamilyDefinition definition, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getBaseSection().getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, Rotation.none(), definition.getData().getBaseSection(), uri, blockFamily); }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, BlockShape shape, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getBaseSection(), uri, blockFamily); }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, BlockShape shape, String section, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getSection(section), uri, blockFamily); }
@Override public Block constructSimpleBlock(BlockFamilyDefinition definition, BlockShape shape, BlockUri uri, BlockFamily blockFamily) { return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, Rotation.none(), definition.getData().getBaseSection(), uri, blockFamily); }
@Override public Block constructSimpleBlock(BlockFamilyDefinition definition, BlockShape shape, String section, BlockUri uri, BlockFamily blockFamily) { return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, Rotation.none(), definition.getData().getSection(section), uri, blockFamily); }
if (definition.getData().hasSection("top")) { Block block = blockBuilder.constructSimpleBlock(definition, "top", new BlockUri(definition.getUrn(), new Name(Side.TOP.name())), this); block.setRotation(Rotation.rotate(Pitch.CLOCKWISE_270)); blockMap.put(Side.TOP, block); if (definition.getData().hasSection("front")) { for (Rotation rot : Rotation.horizontalRotations()) { Side side = rot.rotate(Side.FRONT); if (definition.getData().hasSection("bottom")) { Block block = blockBuilder.constructSimpleBlock(definition, "bottom", new BlockUri(definition.getUrn(), new Name(Side.BOTTOM.name())), this); block.setRotation(Rotation.rotate(Pitch.CLOCKWISE_90));