public void convertSlime(Slime slime, TagCompound properties) { properties.getCompoundData().put("Size", new TagInt(slime.getSize())); }
@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 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 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 void convertSkeleton(Skeleton skeleton, TagCompound properties) { properties.getCompoundData().put("Type", new TagInt(skeleton.getSkeletonType().ordinal())); }
switch (TagType.getTypeById(tag.getTagTypeId())) { case Int: return new NBTTagInt(((TagInt) tag).getIntData()); case Short: return new NBTTagShort(((TagShort) tag).getShortData());
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)); } }
public void convertSheep(Sheep sheep, TagCompound properties) { properties.getCompoundData().put("Color", new TagInt(sheep.getColor().getDyeData())); properties.getCompoundData().put("Sheared", new TagByte(sheep.isSheared())); }
public void convertOcelot(Ocelot ocelot, TagCompound properties) { properties.getCompoundData().put("CatType", new TagInt(ocelot.getCatType().getId())); properties.getCompoundData().put("Sitting", new TagByte(ocelot.isSitting())); }
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); }
if (itemStack != null && itemStack.getType() != Material.AIR) { TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Chestplate.getSlotId())); equipmentList.add(item); if (itemStack != null && itemStack.getType() != Material.AIR) { TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Helmet.getSlotId())); equipmentList.add(item); if (itemStack != null && itemStack.getType() != Material.AIR) { TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Leggins.getSlotId())); equipmentList.add(item); if (itemStack != null && itemStack.getType() != Material.AIR) { TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Boots.getSlotId())); equipmentList.add(item);
public void convertHorse(Horse horse, TagCompound properties) { byte type = (byte) horse.getVariant().ordinal(); int style = horse.getStyle().ordinal(); int color = horse.getColor().ordinal(); int variant = color & 255 | style << 8; if (horse.getInventory().getArmor() != null) { TagCompound armor = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getArmor()); properties.getCompoundData().put("Armor", armor); } if (horse.getInventory().getSaddle() != null) { TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getSaddle()); properties.getCompoundData().put("Saddle", saddle); } properties.getCompoundData().put("Type", new TagByte(type)); properties.getCompoundData().put("Variant", new TagInt(variant)); properties.getCompoundData().put("Chest", new TagByte(horse.isCarryingChest())); properties.getCompoundData().put("Age", new TagInt(horse.getAge())); if (horse.isCarryingChest()) { ItemStack[] contents = horse.getInventory().getContents(); for (int i = 2; i < contents.length; i++) { ItemStack item = contents[i]; if (item != null) { horse.getWorld().dropItem(horse.getLocation(), item); } } } }
return new TagShort(((NBTTagShort) vanillaTag).e()); case 3: return new TagInt(((NBTTagInt) vanillaTag).d()); case 4: return new TagLong(((NBTTagLong) vanillaTag).c());