use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class RepositoryMyPetConverterService method v1_16_R1.
public void v1_16_R1(StoredMyPet pet) {
TagCompound info = pet.getInfo();
switch(pet.getPetType()) {
case PigZombie:
pet.setPetType(MyPetType.ZombifiedPiglin);
}
pet.setInfo(info);
}
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 (horse.getInventory().getSaddle() != null) {
TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(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();
properties.getCompoundData().put("Profession", new TagInt(profession));
int type = villager.getVillagerType().ordinal();
properties.getCompoundData().put("VillagerType", new TagInt(type));
int level = villager.getVillagerLevel();
properties.getCompoundData().put("VillagerLevel", new TagInt(level));
TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(villager);
Set<String> allowedTags = Sets.newHashSet("RestocksToday", "FoodLevel", "Gossips", "Offers", "LastRestock", "Inventory", "Xp");
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.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertEquipable.
public void convertEquipable(LivingEntity entity, TagCompound properties) {
List<TagCompound> equipmentList = new ArrayList<>();
if (random.nextFloat() <= entity.getEquipment().getChestplateDropChance()) {
ItemStack itemStack = entity.getEquipment().getChestplate();
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 (random.nextFloat() <= entity.getEquipment().getHelmetDropChance()) {
ItemStack itemStack = entity.getEquipment().getHelmet();
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 (random.nextFloat() <= entity.getEquipment().getLeggingsDropChance()) {
ItemStack itemStack = entity.getEquipment().getLeggings();
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 (random.nextFloat() <= entity.getEquipment().getBootsDropChance()) {
ItemStack itemStack = entity.getEquipment().getBoots();
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));
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertZombieVillager.
public void convertZombieVillager(ZombieVillager zombie, TagCompound properties) {
properties.getCompoundData().put("Profession", new TagInt(zombie.getVillagerProfession().ordinal()));
TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(zombie);
Set<String> allowedTags = Sets.newHashSet("VillagerData");
Set<String> keys = new HashSet<>(villagerTag.getCompoundData().keySet());
for (String key : keys) {
if (allowedTags.contains(key)) {
continue;
}
villagerTag.remove(key);
}
properties.getCompoundData().put("VillagerData", villagerTag);
}
Aggregations