Java Code Examples for com.nukkitx.nbt.CompoundTagBuilder#stringTag()

The following examples show how to use com.nukkitx.nbt.CompoundTagBuilder#stringTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFrameEntity.java    From Geyser with MIT License 5 votes vote down vote up
private CompoundTag getDefaultTag() {
    CompoundTagBuilder builder = CompoundTag.builder();
    builder.intTag("x", bedrockPosition.getX());
    builder.intTag("y", bedrockPosition.getY());
    builder.intTag("z", bedrockPosition.getZ());
    builder.byteTag("isMovable", (byte) 1);
    builder.stringTag("id", "ItemFrame");
    return builder.buildRootTag();
}
 
Example 2
Source File: BlockTranslator.java    From Geyser with MIT License 5 votes vote down vote up
private static CompoundTag buildBedrockState(JsonNode node) {
    CompoundTagBuilder tagBuilder = CompoundTag.builder();
    tagBuilder.stringTag("name", node.get("bedrock_identifier").textValue())
            .intTag("version", BlockTranslator.BLOCK_STATE_VERSION);

    CompoundTagBuilder statesBuilder = CompoundTag.builder();

    // check for states
    if (node.has("bedrock_states")) {
        Iterator<Map.Entry<String, JsonNode>> statesIterator = node.get("bedrock_states").fields();

        while (statesIterator.hasNext()) {
            Map.Entry<String, JsonNode> stateEntry = statesIterator.next();
            JsonNode stateValue = stateEntry.getValue();
            switch (stateValue.getNodeType()) {
                case BOOLEAN:
                    statesBuilder.booleanTag(stateEntry.getKey(), stateValue.booleanValue());
                    continue;
                case STRING:
                    statesBuilder.stringTag(stateEntry.getKey(), stateValue.textValue());
                    continue;
                case NUMBER:
                    statesBuilder.intTag(stateEntry.getKey(), stateValue.intValue());
            }
        }
    }
    return tagBuilder.tag(statesBuilder.build("states")).build("block");
}
 
Example 3
Source File: InventoryUtils.java    From Geyser with MIT License 5 votes vote down vote up
/**
 * Returns a barrier block with custom name and lore to explain why
 * part of the inventory is unusable.
 */
public static ItemData createUnusableSpaceBlock(String description) {
    CompoundTagBuilder root = CompoundTagBuilder.builder();
    CompoundTagBuilder display = CompoundTagBuilder.builder();

    display.stringTag("Name", ChatColor.RESET + "Unusable inventory space");
    display.listTag("Lore", StringTag.class, Collections.singletonList(new StringTag("", ChatColor.RESET + ChatColor.DARK_PURPLE + description)));

    root.tag(display.build("display"));
    return ItemData.of(ItemRegistry.ITEM_ENTRIES.get(ItemRegistry.BARRIER_INDEX).getBedrockId(), (short) 0, 1, root.buildRootTag());
}
 
Example 4
Source File: SignBlockEntityTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@Override
public com.nukkitx.nbt.tag.CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z) {
    CompoundTagBuilder tagBuilder = getConstantBedrockTag(bedrockId, x, y, z).toBuilder();
    tagBuilder.stringTag("Text", "");
    return tagBuilder.buildRootTag();
}