use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertSaddledHorse.
public void convertSaddledHorse(AbstractHorse horse, TagCompound properties) {
if (horse.getInventory() instanceof HorseInventory) {
if (((HorseInventory) horse.getInventory()).getSaddle() != null) {
TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(((HorseInventory) horse.getInventory()).getSaddle());
properties.getCompoundData().put("Saddle", saddle);
}
}
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertVillager.
public void convertVillager(Villager villager, TagCompound properties) {
int profession = villager.getProfession().ordinal() - 1;
properties.getCompoundData().put("Profession", new TagInt(profession));
TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(villager);
String[] allowedTags = { "Riches", "Career", "CareerLevel", "Willing", "Inventory", "Offers" };
Set<String> keys = new HashSet<>(villagerTag.getCompoundData().keySet());
for (String key : keys) {
if (Arrays.binarySearch(allowedTags, key) > -1) {
continue;
}
villagerTag.remove(key);
}
properties.getCompoundData().put("OriginalData", villagerTag);
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertHorse.
public void convertHorse(Horse horse, TagCompound properties) {
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);
}
properties.getCompoundData().put("Variant", new TagInt(variant));
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);
}
}
}
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class CustomInventory method load.
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);
}
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class CustomInventory method save.
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 != ItemStack.a) {
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;
}
Aggregations