use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyStrider method readExtendedInfo.
@Override
public void readExtendedInfo(TagCompound info) {
if (info.containsKeyAs("Saddle", TagByte.class)) {
boolean saddle = info.getAs("Saddle", TagByte.class).getBooleanData();
if (saddle) {
ItemStack item = new ItemStack(Material.SADDLE);
setSaddle(item);
}
} else if (info.containsKeyAs("Saddle", TagCompound.class)) {
TagCompound itemTag = info.get("Saddle");
try {
ItemStack item = MyPetApi.getPlatformHelper().compundToItemStack(itemTag);
setSaddle(item);
} catch (Exception e) {
MyPetApi.getLogger().warning("Could not load Saddle item from pet data!");
}
}
if (info.containsKey("Baby")) {
setBaby(info.getAs("Baby", TagByte.class).getBooleanData());
}
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyTropicalFish method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Variant", new TagInt(getVariant()));
return info;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyHorse method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
info.getCompoundData().put("Type", new TagByte(getHorseType()));
info.getCompoundData().put("Variant", new TagInt(getVariant()));
if (hasArmor()) {
info.getCompoundData().put("Armor", MyPetApi.getPlatformHelper().itemStackToCompund(getArmor()));
}
info.getCompoundData().put("Age", new TagInt(getAge()));
if (hasChest()) {
info.getCompoundData().put("Chest", MyPetApi.getPlatformHelper().itemStackToCompund(getChest()));
}
if (hasSaddle()) {
info.getCompoundData().put("Saddle", MyPetApi.getPlatformHelper().itemStackToCompund(getSaddle()));
}
return info;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class MyIllusioner method writeExtendedInfo.
@Override
public TagCompound writeExtendedInfo() {
TagCompound info = super.writeExtendedInfo();
if (getEquipment(EquipmentSlot.MainHand) != null && getEquipment(EquipmentSlot.MainHand).getType() != Material.AIR) {
TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(getEquipment(EquipmentSlot.MainHand));
info.getCompoundData().put("Weapon", item);
}
if (getEquipment(EquipmentSlot.Helmet) != null && getEquipment(EquipmentSlot.Helmet).getType() != Material.AIR) {
TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(getEquipment(EquipmentSlot.Helmet));
info.getCompoundData().put("Banner", item);
}
return info;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class NbtRepository method createMyPetPlayer.
public static MyPetPlayer createMyPetPlayer(TagCompound playerTag) {
MyPetPlayerImpl petPlayer = null;
UUID mojangUUID = null;
UUID internalUUID = null;
String playerName = null;
if (playerTag.containsKeyAs("UUID", TagCompound.class)) {
TagCompound uuidTag = playerTag.getAs("UUID", TagCompound.class);
if (uuidTag.getCompoundData().containsKey("Internal-UUID")) {
internalUUID = UUID.fromString(uuidTag.getAs("Internal-UUID", TagString.class).getStringData());
}
if (uuidTag.getCompoundData().containsKey("Mojang-UUID")) {
mojangUUID = UUID.fromString(uuidTag.getAs("Mojang-UUID", TagString.class).getStringData());
}
if (uuidTag.containsKeyAs("Name", TagString.class)) {
playerName = uuidTag.getAs("Name", TagString.class).getStringData();
}
}
if (playerTag.containsKeyAs("Name", TagString.class)) {
playerName = playerTag.getAs("Name", TagString.class).getStringData();
}
if (internalUUID == null) {
return null;
}
if (mojangUUID != null) {
petPlayer = new MyPetPlayerImpl(internalUUID, mojangUUID);
petPlayer.setLastKnownName(playerName);
} else if (playerName != null) {
petPlayer = new MyPetPlayerImpl(internalUUID, playerName);
petPlayer.setLastKnownName(playerName);
}
if (petPlayer != null) {
petPlayer.load(playerTag);
}
return petPlayer;
}
Aggregations