use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class MyZombie method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Baby", new TagByte(isBaby()));
info.getCompoundData().put("Type", new TagInt(type.ordinal()));
info.getCompoundData().put("Profession", new TagInt(profession));
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 SkillTree method setIconItem.
public void setIconItem(short id, short damage, boolean enchantetGlow) {
getIconItem();
if (id > 0) {
iconItem.getCompoundData().put("id", new TagShort(id));
}
if (damage >= 0) {
iconItem.getCompoundData().put("Damage", new TagShort(damage));
}
if (!iconItem.getCompoundData().containsKey("tag")) {
iconItem.getCompoundData().put("tag", new TagCompound());
}
TagCompound tagCompound = iconItem.getAs("tag", TagCompound.class);
if (enchantetGlow) {
tagCompound.getCompoundData().put("ench", new TagList());
} else {
tagCompound.getCompoundData().remove("ench");
}
}
use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class SkullMeta method applyTo.
public void applyTo(TagCompound tag) {
if (hasOwner()) {
TagCompound ownerTag = new TagCompound();
ownerTag.put("Name", new TagString(getOwner()));
if (hasTexture()) {
TagCompound propertiesTag = new TagCompound();
TagList textureList = new TagList();
TagCompound textureTag = new TagCompound();
JSONObject jsonObject = new JSONObject();
JSONObject texturesObject = new JSONObject();
JSONObject skinObject = new JSONObject();
jsonObject.put("textures", texturesObject);
texturesObject.put("SKIN", skinObject);
skinObject.put("url", getTexture());
String base64 = BaseEncoding.base64Url().encode(jsonObject.toJSONString().getBytes());
textureTag.put("Value", new TagString(base64));
textureList.addTag(textureTag);
propertiesTag.put("textures", textureList);
ownerTag.put("Properties", propertiesTag);
}
tag.put("SkullOwner", ownerTag);
}
}
use of de.keyle.knbt.TagList in project MyPet by xXKeyleXx.
the class CustomInventory method load.
public void load(TagCompound nbtTagCompound) {
TagList items = nbtTagCompound.getAs("Items", TagList.class);
for (int i = 0; i < items.size(); i++) {
TagCompound itemCompound = items.getTagAs(i, TagCompound.class);
ItemStack itemStack = ItemStackNBTConverter.compundToItemStack(itemCompound);
setItem(itemCompound.getAs("Slot", TagByte.class).getByteData(), 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