use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertEntity.
@Override
public void convertEntity(MyPet myPet, LivingEntity normalEntity) {
if (myPet instanceof MyCreeper) {
if (((MyCreeper) myPet).isPowered()) {
((Creeper) normalEntity).setPowered(true);
}
} else if (myPet instanceof MyEnderman) {
if (((MyEnderman) myPet).hasBlock()) {
MaterialData materialData = new MaterialData(((MyEnderman) myPet).getBlock().getType(), ((MyEnderman) myPet).getBlock().getData().getData());
((Enderman) normalEntity).setCarriedMaterial(materialData);
}
} else if (myPet instanceof MyIronGolem) {
((IronGolem) normalEntity).setPlayerCreated(true);
} else if (myPet instanceof MyMagmaCube) {
((MagmaCube) normalEntity).setSize(((MyMagmaCube) myPet).getSize());
} else if (myPet instanceof MyOcelot) {
((Ocelot) normalEntity).setCatType(Ocelot.Type.WILD_OCELOT);
((Ocelot) normalEntity).setTamed(false);
} else if (myPet instanceof MyPig) {
((Pig) normalEntity).setSaddle(((MyPig) myPet).hasSaddle());
} else if (myPet instanceof MySheep) {
((Sheep) normalEntity).setSheared(((MySheep) myPet).isSheared());
((Sheep) normalEntity).setColor(((MySheep) myPet).getColor());
} else if (myPet instanceof MyVillager) {
MyVillager villagerPet = (MyVillager) myPet;
Villager.Profession profession = Villager.Profession.values()[villagerPet.getProfession() + 1];
((Villager) normalEntity).setProfession(profession);
if (villagerPet.hasOriginalData()) {
TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(normalEntity);
for (String key : villagerPet.getOriginalData().getCompoundData().keySet()) {
villagerTag.put(key, villagerPet.getOriginalData().get(key));
}
MyPetApi.getPlatformHelper().applyTagToEntity(villagerTag, normalEntity);
}
} else if (myPet instanceof MyWolf) {
((Wolf) normalEntity).setTamed(false);
} else if (myPet instanceof MySlime) {
((Slime) normalEntity).setSize(((MySlime) myPet).getSize());
} else if (myPet instanceof MyZombie) {
switch(((MyZombie) myPet).getZombieType()) {
case HUSK:
((Zombie) normalEntity).setVillagerProfession(Villager.Profession.HUSK);
break;
case VILLAGER:
Villager.Profession profession = Villager.Profession.values()[((MyZombie) myPet).getProfession() + 1];
((Zombie) normalEntity).setVillagerProfession(profession);
break;
}
} else if (myPet instanceof MySkeleton) {
((Skeleton) normalEntity).setSkeletonType(Skeleton.SkeletonType.values()[((MySkeleton) myPet).getType()]);
if (((MySkeleton) myPet).isWither()) {
normalEntity.getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD));
} else {
normalEntity.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
} else if (myPet instanceof MyPigZombie) {
normalEntity.getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD));
} else if (myPet instanceof MyHorse) {
Horse.Style style = Horse.Style.values()[(((MyHorse) myPet).getVariant() >>> 8)];
Horse.Color color = Horse.Color.values()[(((MyHorse) myPet).getVariant() & 0xFF)];
((Horse) normalEntity).setColor(color);
((Horse) normalEntity).setStyle(style);
if (((MyHorse) myPet).hasSaddle()) {
((Horse) normalEntity).getInventory().setSaddle(((MyHorse) myPet).getSaddle().clone());
}
if (((MyHorse) myPet).hasArmor()) {
((Horse) normalEntity).getInventory().setArmor(((MyHorse) myPet).getArmor().clone());
}
((Horse) normalEntity).setOwner(myPet.getOwner().getPlayer());
} else if (myPet instanceof MyRabbit) {
((Rabbit) normalEntity).setRabbitType(((MyRabbit) myPet).getVariant().getBukkitType());
}
if (myPet instanceof MyPetBaby && normalEntity instanceof Ageable) {
if (((MyPetBaby) myPet).isBaby()) {
((Ageable) normalEntity).setBaby();
} else {
((Ageable) normalEntity).setAdult();
}
}
}
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 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 != 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;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyChicken method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Baby", new TagByte(isBaby()));
return info;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyCow method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Baby", new TagByte(isBaby()));
return info;
}
Aggregations