use of de.keyle.knbt.TagList 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;
}
use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class MyWitherSkeleton method readExtendedInfo.
@Override
public void readExtendedInfo(TagCompound info) {
if (info.getCompoundData().containsKey("Equipment")) {
TagList equipment = info.getAs("Equipment", TagList.class);
for (int i = 0; i < equipment.size(); i++) {
TagCompound item = equipment.getTagAs(i, TagCompound.class);
ItemStack itemStack = MyPetApi.getPlatformHelper().compundToItemStack(item);
setEquipment(EquipmentSlot.getSlotById(item.getAs("Slot", TagInt.class).getIntData()), itemStack);
}
}
}
use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class MyZombieVillager method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Baby", new TagByte(isBaby()));
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;
}
use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class MyZombieVillager method readExtendedInfo.
@Override
public void readExtendedInfo(TagCompound info) {
if (info.getCompoundData().containsKey("Baby")) {
setBaby(info.getAs("Baby", TagByte.class).getBooleanData());
}
if (info.getCompoundData().containsKey("Profession")) {
setProfession(info.getAs("Profession", TagInt.class).getIntData());
}
if (info.getCompoundData().containsKey("Equipment")) {
TagList equipment = info.get("Equipment");
for (int i = 0; i < equipment.size(); i++) {
TagCompound item = equipment.getTag(i);
ItemStack itemStack = MyPetApi.getPlatformHelper().compundToItemStack(item);
setEquipment(EquipmentSlot.getSlotById(item.getAs("Slot", TagInt.class).getIntData()), itemStack);
}
}
}
use of de.keyle.knbt.TagList 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));
}
Aggregations