public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Active", new TagByte(pickup)); return nbtTagCompound; }
public static ItemStack compundToItemStack(TagCompound compound) { int id = compound.getAs("id", TagShort.class).getShortData(); int count = compound.getAs("Count", TagByte.class).getByteData(); int damage = compound.getAs("Damage", TagShort.class).getShortData(); ItemStack itemstack = new ItemStack(Item.getById(id), count, damage); if (compound.containsKeyAs("tag", TagCompound.class)) { TagCompound compoundToConvert = compound.get("tag"); itemstack.setTag((NBTTagCompound) compoundToVanillaCompound(compoundToConvert)); } return itemstack; }
public IconMenuItem addTag(String key, TagBase tag) { if (this.tag == null) { this.tag = new TagCompound(); } this.tag.put(key, tag); return this; }
public void convert(StoredMyPet pet) { Version fromVersion = Version.v1_7_R4; TagCompound info = pet.getInfo(); if (info.containsKey("Version")) { if (info.containsKeyAs("Version", TagString.class)) { fromVersion = Version.valueOf(info.getAs("Version", TagString.class).getStringData()); } else if (info.containsKeyAs("Version", TagInt.class)) { fromVersion = Version.values()[info.getAs("Version", TagInt.class).getIntData() + 1]; } else { fromVersion = Version.values()[info.getAs("Version", TagShort.class).getShortData()]; } } for (Version v : Version.values()) { if (v.ordinal() <= fromVersion.ordinal()) { continue; } if (v.ordinal() > toVersion.ordinal()) { break; } try { Method m = this.getClass().getDeclaredMethod(v.name(), StoredMyPet.class); m.invoke(this, pet); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { } } } }
public TagCompound save(TagCompound compound) { List<TagCompound> itemList = new ArrayList<>(); for (int i = 0; i < this.items.size(); i++) { ItemStack itemStack = this.items.get(i); if (itemStack != null) { TagCompound item = ItemStackNBTConverter.itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagByte((byte) i)); itemList.add(item); } } compound.getCompoundData().put("Items", new TagList(itemList)); return compound; }
@Override public void load(TagCompound compound) { if (compound.getCompoundData().containsKey("Buff")) { Buff selectedBuff = Buff.getBuffByID(compound.getAs("Buff", TagInt.class).getIntData()); if (selectedBuff != null) { this.selectedBuffs.add(selectedBuff); } } if (compound.getCompoundData().containsKey("Buffs")) { int[] selectedBuffs = compound.getAs("Buffs", TagIntArray.class).getIntArrayData(); if (selectedBuffs.length != 0) { for (int selectedBuffId : selectedBuffs) { Buff selectedBuff = Buff.getBuffByID(selectedBuffId); if (selectedBuff != null) { this.selectedBuffs.add(selectedBuff); } } } } if (compound.getCompoundData().containsKey("Active")) { this.active = compound.getAs("Active", TagByte.class).getBooleanData(); } if (compound.getCompoundData().containsKey("Reciever")) { this.receiver = BuffReceiver.valueOf(compound.getAs("Reciever", TagString.class).getStringData()); } }
public void clearConfig() { nbtTagCompound = new TagCompound(); } }
if (villagerPet.hasOriginalData()) { TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(normalEntity); for (String key : villagerPet.getOriginalData().getCompoundData().keySet()) { villagerTag.put(key, villagerPet.getOriginalData().get(key));
public static ItemTooltip myPetToItemTooltip(StoredMyPet mypet, String lang) { List<String> lore = new ArrayList<>(); lore.add(RESET + Translation.getString("Name.Hunger", lang) + ": " + GOLD + Math.round(mypet.getSaturation())); if (!Configuration.Respawn.DISABLE_AUTO_RESPAWN) { if (mypet.getRespawnTime() > 0) { lore.add(RESET + Translation.getString("Name.Respawntime", lang) + ": " + GOLD + mypet.getRespawnTime() + "sec"); } else { lore.add(RESET + Translation.getString("Name.HP", lang) + ": " + GOLD + String.format("%1.2f", mypet.getHealth())); } } else if (mypet.getRespawnTime() <= 0) { lore.add(RESET + Translation.getString("Name.HP", lang) + ": " + GOLD + String.format("%1.2f", mypet.getHealth())); } lore.add(RESET + Translation.getString("Name.Exp", lang) + ": " + GOLD + String.format("%1.2f", mypet.getExp())); if (mypet.getInfo().containsKey("storage")) { TagCompound storage = mypet.getInfo().getAs("storage", TagCompound.class); if (storage.containsKey("level")) { lore.add(RESET + Translation.getString("Name.Level", lang) + ": " + GOLD + storage.getAs("level", TagInt.class).getIntData()); } } lore.add(RESET + Translation.getString("Name.Type", lang) + ": " + GOLD + mypet.getPetType().name()); lore.add(RESET + Translation.getString("Name.Skilltree", lang) + ": " + GOLD + (mypet.getSkilltree() != null ? mypet.getSkilltree().getDisplayName() : "-")); if (Configuration.Respawn.DISABLE_AUTO_RESPAWN) { if (mypet.getRespawnTime() > 0) { lore.add(ChatColor.RED + Translation.getString("Name.Dead", lang)); } } return new ItemTooltip().addLore(lore).setTitle(mypet.getPetName()); }
public void load(TagCompound compound) { pickup = compound.getAs("Active", TagByte.class).getBooleanData(); }
public void convertVillager(Villager villager, TagCompound properties) { int profession = villager.getProfession().ordinal(); if (MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.10") >= 0) { profession--; } properties.getCompoundData().put("Profession", new TagInt(profession)); TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(villager); Set<String> allowedTags = Sets.newHashSet("Riches", "Career", "CareerLevel", "Willing", "Inventory", "Offers"); Set<String> keys = new HashSet<>(villagerTag.getCompoundData().keySet()); for (String key : keys) { if (allowedTags.contains(key)) { continue; } villagerTag.remove(key); } properties.getCompoundData().put("OriginalData", villagerTag); }
public IconMenuItem clone() { IconMenuItem newItem = new IconMenuItem(); newItem.material = this.material; newItem.data = this.data; newItem.amount = this.amount; newItem.title = this.title; newItem.lore.addAll(this.lore); newItem.glowing = this.glowing; if (this.bukkitMeta != null) { newItem.bukkitMeta = this.bukkitMeta.clone(); } if (this.meta != null) { newItem.meta = this.meta.clone(); } if (this.tag != null) { newItem.tag = this.tag.clone(); } newItem.hasChanged = true; return newItem; } }
public void convertCreeper(Creeper creeper, TagCompound properties) { properties.getCompoundData().put("Powered", new TagByte(creeper.isPowered())); }
public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); inv.save(nbtTagCompound); return nbtTagCompound; }
public void load(TagCompound nbtTagCompound) { TagList items = nbtTagCompound.getAs("Items", TagList.class); for (int i = 0; i < items.size(); i++) { TagCompound itemCompound = items.getTagAs(i, TagCompound.class); ItemStack itemStack = ItemStackNBTConverter.compundToItemStack(itemCompound); setItem(itemCompound.getAs("Slot", TagByte.class).getByteData(), itemStack); } }
@Override public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Buffs", new TagIntArray(selectedBuffs.stream().mapToInt(Buff::getId).toArray())); nbtTagCompound.getCompoundData().put("Active", new TagByte(this.active)); nbtTagCompound.getCompoundData().put("Reciever", new TagString(this.receiver.name())); return nbtTagCompound; }
public void convertZombie(Zombie zombie, TagCompound properties) { properties.getCompoundData().put("Baby", new TagByte(zombie.isBaby())); if (zombie.isVillager()) { properties.getCompoundData().put("Type", new TagInt(1)); } }
@SuppressWarnings("unchecked") public void applyTo(TagCompound tag) { if (hasOwner()) { TagCompound ownerTag = new TagCompound(); ownerTag.put("Name", new TagString(getOwner())); if (hasTexture()) { TagCompound propertiesTag = new TagCompound(); TagList textureList = new TagList(); TagCompound textureTag = new TagCompound(); JSONObject jsonObject = new JSONObject(); JSONObject texturesObject = new JSONObject(); JSONObject skinObject = new JSONObject(); jsonObject.put("textures", texturesObject); texturesObject.put("SKIN", skinObject); skinObject.put("url", getTexture()); String base64 = BaseEncoding.base64Url().encode(jsonObject.toJSONString().getBytes()); textureTag.put("Value", new TagString(base64)); textureList.addTag(textureTag); propertiesTag.put("textures", textureList); ownerTag.put("Properties", propertiesTag); } tag.put("SkullOwner", ownerTag); } }
TagCompound tag = new TagCompound(); icon.getMeta().applyTo(tag); NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag);
public static TagCompound itemStackToCompund(ItemStack itemStack) { TagCompound compound = new TagCompound(); compound.getCompoundData().put("id", new TagShort((short) Item.getId(itemStack.getItem()))); compound.getCompoundData().put("Count", new TagByte((byte) itemStack.count)); compound.getCompoundData().put("Damage", new TagShort((short) itemStack.getData())); if (itemStack.getTag() != null) { compound.getCompoundData().put("tag", vanillaCompoundToCompound(itemStack.getTag())); } return compound; }