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() - 1;
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 EntityConverterService method convertSheep.
public void convertSheep(Sheep sheep, TagCompound properties) {
properties.getCompoundData().put("Color", new TagInt(sheep.getColor().getDyeData()));
properties.getCompoundData().put("Sheared", new TagByte(sheep.isSheared()));
}
use of de.keyle.knbt.TagInt 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.TagInt in project MyPet by xXKeyleXx.
the class EntityConverterService method convertOcelot.
public void convertOcelot(Ocelot ocelot, TagCompound properties) {
properties.getCompoundData().put("CatType", new TagInt(ocelot.getCatType().getId()));
properties.getCompoundData().put("Sitting", new TagByte(ocelot.isSitting()));
}
use of de.keyle.knbt.TagInt in project MyPet by xXKeyleXx.
the class ItemStackNBTConverter method vanillaCompoundToCompound.
public static TagBase vanillaCompoundToCompound(Tag vanillaTag) {
switch(vanillaTag.getId()) {
case 1:
return new TagByte(((ByteTag) vanillaTag).getAsByte());
case 2:
return new TagShort(((ShortTag) vanillaTag).getAsShort());
case 3:
return new TagInt(((IntTag) vanillaTag).getAsInt());
case 4:
return new TagLong(((LongTag) vanillaTag).getAsLong());
case 5:
return new TagFloat(((FloatTag) vanillaTag).getAsFloat());
case 6:
return new TagDouble(((DoubleTag) vanillaTag).getAsDouble());
case 7:
return new TagByteArray(((ByteArrayTag) vanillaTag).getAsByteArray());
case 8:
return new TagString(vanillaTag.getAsString());
case 9:
ListTag tagList = (ListTag) vanillaTag;
List compoundList = new ArrayList();
try {
ArrayList list = (ArrayList) TAG_LIST_LIST.get(tagList);
for (Object aList : list) {
compoundList.add(vanillaCompoundToCompound((Tag) aList));
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return new TagList(compoundList);
case 10:
TagCompound compound = new TagCompound();
CompoundTag tagCompound = ((CompoundTag) vanillaTag);
Set<String> keys = tagCompound.getAllKeys();
for (String tagName : keys) {
compound.getCompoundData().put(tagName, vanillaCompoundToCompound(tagCompound.get(tagName)));
}
return compound;
case 11:
return new TagIntArray(((IntArrayTag) vanillaTag).getAsIntArray());
}
return null;
}
Aggregations