Java Code Examples for com.github.steveice10.opennbt.tag.builtin.CompoundTag#remove()
The following examples show how to use
com.github.steveice10.opennbt.tag.builtin.CompoundTag#remove() .
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: BookPagesTranslator.java From Geyser with MIT License | 6 votes |
@Override public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) { if (!itemTag.contains("pages")) { return; } List<Tag> pages = new ArrayList<>(); ListTag pagesTag = itemTag.get("pages"); for (Tag tag : pagesTag.getValue()) { if (!(tag instanceof StringTag)) continue; StringTag textTag = (StringTag) tag; CompoundTag pageTag = new CompoundTag(""); pageTag.put(new StringTag("photoname", "")); pageTag.put(new StringTag("text", MessageUtils.getBedrockMessageLenient(textTag.getValue()))); pages.add(pageTag); } itemTag.remove("pages"); itemTag.put(new ListTag("pages", pages)); }
Example 2
Source File: BookPagesTranslator.java From Geyser with MIT License | 6 votes |
@Override public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) { if (!itemTag.contains("pages")) { return; } List<Tag> pages = new ArrayList<>(); ListTag pagesTag = itemTag.get("pages"); for (Tag tag : pagesTag.getValue()) { if (!(tag instanceof CompoundTag)) continue; CompoundTag pageTag = (CompoundTag) tag; StringTag textTag = pageTag.get("text"); pages.add(new StringTag(MessageUtils.getJavaMessage(textTag.getValue()))); } itemTag.remove("pages"); itemTag.put(new ListTag("pages", pages)); }
Example 3
Source File: EnchantedBookTranslator.java From Geyser with MIT License | 5 votes |
@Override public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) { if (!itemTag.contains("StoredEnchantments")) { return; } Tag enchTag = itemTag.get("StoredEnchantments"); if (enchTag instanceof ListTag) { enchTag = new ListTag("Enchantments", ((ListTag) enchTag).getValue()); itemTag.remove("StoredEnchantments"); itemTag.put(enchTag); } }
Example 4
Source File: EnchantedBookTranslator.java From Geyser with MIT License | 5 votes |
@Override public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) { if (!itemTag.contains("Enchantments")) { return; } Tag enchTag = itemTag.get("Enchantments"); if (enchTag instanceof ListTag) { enchTag = new ListTag("StoredEnchantments", ((ListTag) enchTag).getValue()); itemTag.remove("Enchantments"); itemTag.put(enchTag); } }
Example 5
Source File: MapItemTranslator.java From Geyser with MIT License | 5 votes |
@Override public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) { IntTag mapId = itemTag.get("map"); if (mapId != null) { itemTag.put(new StringTag("map_uuid", mapId.getValue().toString())); itemTag.put(new IntTag("map_name_index", mapId.getValue())); itemTag.put(new ByteTag("map_display_players", (byte) 1)); itemTag.remove("map"); } }
Example 6
Source File: MapItemTranslator.java From Geyser with MIT License | 5 votes |
@Override public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) { IntTag tag = itemTag.get("map_name_index"); if (tag != null) { itemTag.put(new IntTag("map", tag.getValue())); itemTag.remove("map_name_index"); itemTag.remove("map_uuid"); } }
Example 7
Source File: LeatherArmorTranslator.java From Geyser with MIT License | 5 votes |
@Override public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) { if (!itemTag.contains("display")) { return; } CompoundTag displayTag = itemTag.get("display"); if (displayTag.contains("color")) { IntTag color = displayTag.get("color"); if (color != null) { itemTag.put(new IntTag("customColor", color.getValue())); displayTag.remove("color"); } } }
Example 8
Source File: InventoryPackets.java From ViaVersion with MIT License | 5 votes |
public static void toServer(Item item) { if (item == null) return; item.setIdentifier(getOldItemId(item.getIdentifier())); CompoundTag tag; if ((tag = item.getTag()) != null) { // Display Name now uses JSON Tag displayTag = tag.get("display"); if (displayTag instanceof CompoundTag) { CompoundTag display = (CompoundTag) displayTag; Tag loreTag = display.get("Lore"); if (loreTag instanceof ListTag) { ListTag lore = (ListTag) loreTag; ListTag via = display.get(NBT_TAG_NAME + "|Lore"); if (via != null) { display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via))); } else { for (Tag loreEntry : lore) { if (loreEntry instanceof StringTag) { ((StringTag) loreEntry).setValue( ChatRewriter.jsonTextToLegacy( ((StringTag) loreEntry).getValue() ) ); } } } display.remove(NBT_TAG_NAME + "|Lore"); } } } }
Example 9
Source File: WorldPackets.java From ViaVersion with MIT License | 5 votes |
private static void handleBlockEntity(CompoundTag compoundTag) { StringTag idTag = compoundTag.get("id"); if (idTag == null) return; String id = idTag.getValue(); if (id.equals("minecraft:conduit")) { Tag targetUuidTag = compoundTag.remove("target_uuid"); if (!(targetUuidTag instanceof StringTag)) return; // target_uuid -> Target UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue()); compoundTag.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid))); } else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) { CompoundTag ownerTag = compoundTag.remove("Owner"); StringTag ownerUuidTag = ownerTag.remove("Id"); if (ownerUuidTag != null) { UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue()); ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid))); } // Owner -> SkullOwner CompoundTag skullOwnerTag = new CompoundTag("SkullOwner"); for (Tag tag : ownerTag) { skullOwnerTag.put(tag); } compoundTag.put(skullOwnerTag); } }