use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class EntityConverterService method convertHorse.
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);
}
}
}
}
use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class EntityConverterService method convertVillager.
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);
}
use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class MyPufferfish method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("PuffState", new TagInt(puffState.ordinal()));
return info;
}
use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class MySlime method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Size", new TagInt(getSize()));
return info;
}
use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class MyStray method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
List<TagCompound> itemList = new ArrayList<>();
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (getEquipment(slot) != null) {
TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(getEquipment(slot));
item.getCompoundData().put("Slot", new TagInt(slot.getSlotId()));
itemList.add(item);
}
}
info.getCompoundData().put("Equipment", new TagList(itemList));
return info;
}
Aggregations