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 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 TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Active", new TagByte(pickup)); 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)); } }
public void convertCreeper(Creeper creeper, TagCompound properties) { properties.getCompoundData().put("Powered", new TagByte(creeper.isPowered())); }
public void convertAgable(Ageable ageable, TagCompound properties) { properties.getCompoundData().put("Baby", new TagByte(!ageable.isAdult())); }
public void convertSlime(Slime slime, TagCompound properties) { properties.getCompoundData().put("Size", new TagInt(slime.getSize())); }
public void convertWolf(Wolf wolf, TagCompound properties) { properties.getCompoundData().put("Sitting", new TagByte(wolf.isSitting())); properties.getCompoundData().put("Tamed", new TagByte(wolf.isTamed())); properties.getCompoundData().put("CollarColor", new TagByte(wolf.getCollarColor().getWoolData())); } }
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; }
public void convertPig(Pig pig, TagCompound properties) { properties.getCompoundData().put("Saddle", new TagByte(pig.hasSaddle())); }
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); }
public void convertSkeleton(Skeleton skeleton, TagCompound properties) { properties.getCompoundData().put("Type", new TagInt(skeleton.getSkeletonType().ordinal())); }
@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 convertEnderman(Enderman enderman, TagCompound properties) { if (enderman.getCarriedMaterial().getItemType() != Material.AIR) { ItemStack block = enderman.getCarriedMaterial().toItemStack(1); properties.getCompoundData().put("Block", MyPetApi.getPlatformHelper().itemStackToCompund(block)); } }
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); } } } }
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); properties.getCompoundData().put("Equipment", new TagList(equipmentList));
Set<String> keys = tagCompound.c(); for (String tagName : keys) { compound.getCompoundData().put(tagName, vanillaCompoundToCompound(tagCompound.get(tagName)));
TagCompound TagCompound = (TagCompound) tag; NBTTagCompound tagCompound = new NBTTagCompound(); for (String name : TagCompound.getCompoundData().keySet()) { tagCompound.set(name, compoundToVanillaCompound(TagCompound.getCompoundData().get(name)));