protected NBTList<NBTCompound> filterEnchantList(ProtocolVersion version, NBTList<NBTCompound> oldList) { if (oldList == null) { return null; } GenericSkippingTable<String> enchSkip = GenericIdSkipper.ENCHANT.getTable(version); NBTList<NBTCompound> newList = new NBTList<>(NBTType.COMPOUND); for (NBTCompound enchData : oldList.getTags()) { if (!enchSkip.shouldSkip(NBTString.getValueOrDefault(enchData.getTagOfType("id", NBTType.STRING), ""))) { newList.addTag(enchData); } } return newList; }
writeTagType(stream, tag.getTagsType()); stream.writeInt(tag.size()); for (NBT value : ((List<NBT>) tag.getTags())) { writeTag(stream, value);
@Override public NBTCompound remapTag(ProtocolVersion version, String locale, NetworkItemStack itemstack, NBTCompound tag) { NBTList<NBTString> pages = tag.getTagListOfType("pages", NBTType.STRING); if (pages != null) { NBTList<NBTString> newPages = new NBTList<>(NBTType.STRING); for (NBTString page : pages.getTags()) { newPages.addTag(new NBTString(ChatAPI.fromJSON(page.getValue()).toLegacyText(locale))); } tag.setTag("pages", newPages); } return tag; }
protected NBTList<NBTCompound> remapEnchantList(NBTList<NBTCompound> oldList) { NBTList<NBTCompound> newList = new NBTList<>(NBTType.COMPOUND); for (NBTCompound enchData : oldList.getTags()) { Enchantment ench = Enchantment.getByKey(NamespacedKeyUtils.fromString(NBTString.getValueOrNull(enchData.getTagOfType("id", NBTType.STRING)))); if (ench != null) { enchData.setTag("id", new NBTShort(LegacyEnchantmentId.getId(ench))); newList.addTag(enchData); } } return newList; }
protected NBTList<NBTCompound> remapEnchantList(NBTList<NBTCompound> oldList) { NBTList<NBTCompound> newList = new NBTList<>(NBTType.COMPOUND); for (NBTCompound enchData : oldList.getTags()) { NBTNumber enchId = enchData.getNumberTag("id"); if (enchId != null) { Enchantment ench = LegacyEnchantmentId.getById(enchId.getAsInt()); if (ench != null) { enchData.setTag("id", new NBTString(ench.getKey().toString())); newList.addTag(enchData); } } } return newList; }
public static GameProfile deserialize(NBTCompound tag) { String name = NBTString.getValueOrNull(tag.getTagOfType(NAME_KEY, NBTType.STRING)); UUID uuid = null; try { uuid = UUID.fromString(NBTString.getValueOrNull(tag.getTagOfType(UUID_KEY, NBTType.STRING))); } catch (Throwable t) { } if (StringUtils.isEmpty(name) && (uuid == null)) { return null; } GameProfile gameProfile = new GameProfile(uuid, name); NBTCompound propertiesTag = tag.getTagOfType(PROPERTIES_KEY, NBTType.COMPOUND); if (propertiesTag != null) { for (String propertyName : propertiesTag.getTagNames()) { NBTList<NBTCompound> propertiesListTag = propertiesTag.getTagListOfType(propertyName, NBTType.COMPOUND); if (propertiesListTag != null) { for (NBTCompound propertyTag : propertiesListTag.getTags()) { gameProfile.addProperty(new ProfileProperty( propertyName, NBTString.getValueOrNull(propertyTag.getTagOfType(PROPERTY_VALUE_KEY, NBTType.STRING)), NBTString.getValueOrNull(propertyTag.getTagOfType(PROPERTY_SIGNATURE_KEY, NBTType.STRING)) )); } } } } return gameProfile; }
protected RecyclableCollection<ServerBoundPacketData> transformBookSign() { ProtocolVersion version = connection.getVersion(); String locale = connection.getCache().getAttributesCache().getLocale(); NetworkItemStack book = ItemStackSerializer.readItemStack(data, version, locale); if (!book.isNull()) { book.setTypeId(ItemMaterialLookup.getRuntimeId(Material.WRITABLE_BOOK)); if (connection.getVersion() == ProtocolVersion.MINECRAFT_1_8) { NBTCompound rootTag = book.getNBT(); if (rootTag != null) { NBTList<NBTString> pages = rootTag.getTagListOfType("pages", NBTType.STRING); if (pages != null) { NBTList<NBTString> newPages = new NBTList<>(NBTType.STRING); for (NBTString page : pages.getTags()) { newPages.addTag(new NBTString(ChatAPI.fromJSON(page.getValue()).toLegacyText(locale))); } rootTag.setTag("pages", newPages); book.setNBT(rootTag); } } } return RecyclableSingletonList.create(MiddleEditBook.create(book, true, UsedHand.MAIN)); } else { return RecyclableEmptyList.get(); } }