use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EggIconService method updateIcon.
@Override
public void updateIcon(MyPetType type, IconMenuItem icon) {
icon.setMaterial(Material.MONSTER_EGG);
TagCompound entityTag = new TagCompound();
switch(type) {
case Bat:
entityTag.put("id", new TagString("minecraft:bat"));
break;
case Blaze:
entityTag.put("id", new TagString("minecraft:blaze"));
break;
case CaveSpider:
entityTag.put("id", new TagString("minecraft:cave_spider"));
break;
case Chicken:
entityTag.put("id", new TagString("minecraft:chicken"));
break;
case Cow:
entityTag.put("id", new TagString("minecraft:cow"));
break;
case Creeper:
entityTag.put("id", new TagString("minecraft:creeper"));
break;
case EnderDragon:
entityTag.put("id", new TagString("minecraft:ender_dragon"));
break;
case Enderman:
entityTag.put("id", new TagString("minecraft:enderman"));
break;
case Endermite:
entityTag.put("id", new TagString("minecraft:endermite"));
break;
case Evoker:
entityTag.put("id", new TagString("minecraft:evocation_illager"));
break;
case Ghast:
entityTag.put("id", new TagString("minecraft:ghast"));
break;
case Giant:
entityTag.put("id", new TagString("minecraft:giant"));
break;
case Guardian:
entityTag.put("id", new TagString("minecraft:guardian"));
break;
case ElderGuardian:
entityTag.put("id", new TagString("minecraft:elder_guardian"));
break;
case Horse:
entityTag.put("id", new TagString("minecraft:horse"));
break;
case Donkey:
entityTag.put("id", new TagString("minecraft:donkey"));
break;
case Mule:
entityTag.put("id", new TagString("minecraft:mule"));
break;
case SkeletonHorse:
entityTag.put("id", new TagString("minecraft:skeleton_horse"));
break;
case ZombieHorse:
entityTag.put("id", new TagString("minecraft:zombie_horse"));
break;
case Illusioner:
entityTag.put("id", new TagString("minecraft:squid"));
icon.setGlowing(true);
break;
case IronGolem:
entityTag.put("id", new TagString("minecraft:skeleton"));
icon.setGlowing(true);
break;
case Llama:
entityTag.put("id", new TagString("minecraft:llama"));
break;
case MagmaCube:
entityTag.put("id", new TagString("minecraft:magma_cube"));
break;
case Mooshroom:
entityTag.put("id", new TagString("minecraft:mooshroom"));
break;
case Ocelot:
entityTag.put("id", new TagString("minecraft:ocelot"));
break;
case Parrot:
entityTag.put("id", new TagString("minecraft:parrot"));
break;
case Pig:
entityTag.put("id", new TagString("minecraft:pig"));
break;
case PigZombie:
entityTag.put("id", new TagString("minecraft:zombie_pigman"));
break;
case PolarBear:
entityTag.put("id", new TagString("minecraft:polar_bear"));
break;
case Rabbit:
entityTag.put("id", new TagString("minecraft:rabbit"));
break;
case Sheep:
entityTag.put("id", new TagString("minecraft:sheep"));
break;
case Silverfish:
entityTag.put("id", new TagString("minecraft:silverfish"));
break;
case Skeleton:
entityTag.put("id", new TagString("minecraft:skeleton"));
break;
case Stray:
entityTag.put("id", new TagString("minecraft:stray"));
break;
case WitherSkeleton:
entityTag.put("id", new TagString("minecraft:wither_skeleton"));
break;
case Slime:
entityTag.put("id", new TagString("minecraft:slime"));
break;
case Snowman:
entityTag.put("id", new TagString("minecraft:snowman"));
break;
case Spider:
entityTag.put("id", new TagString("minecraft:spider"));
break;
case Squid:
entityTag.put("id", new TagString("minecraft:squid"));
break;
case Witch:
entityTag.put("id", new TagString("minecraft:witch"));
break;
case Wither:
entityTag.put("id", new TagString("minecraft:endermite"));
icon.setGlowing(true);
break;
case Wolf:
entityTag.put("id", new TagString("minecraft:wolf"));
break;
case Vex:
entityTag.put("id", new TagString("minecraft:vex"));
break;
case Villager:
entityTag.put("id", new TagString("minecraft:villager"));
break;
case Vindicator:
entityTag.put("id", new TagString("minecraft:vindication_illager"));
break;
case Zombie:
entityTag.put("id", new TagString("minecraft:zombie"));
break;
case ZombieVillager:
entityTag.put("id", new TagString("minecraft:zombie_villager"));
break;
case Husk:
entityTag.put("id", new TagString("minecraft:husk"));
break;
}
icon.addTag("EntityTag", entityTag);
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class EntityConverterService method convertHorse.
public void convertHorse(Horse horse, TagCompound properties) {
int style = horse.getStyle().ordinal();
int color = horse.getColor().ordinal();
int variant = color & 255 | style << 8;
if (horse.getInventory().getArmor() != null) {
TagCompound armor = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getArmor());
properties.getCompoundData().put("Armor", armor);
}
properties.getCompoundData().put("Variant", new TagInt(variant));
if (horse.isCarryingChest()) {
ItemStack[] contents = horse.getInventory().getContents();
for (int i = 2; i < contents.length; i++) {
ItemStack item = contents[i];
if (item != null) {
horse.getWorld().dropItem(horse.getLocation(), item);
}
}
}
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class IconMenuInventory method createItemStack.
protected ItemStack createItemStack(IconMenuItem icon) {
ItemStack is = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(icon.getMaterial(), icon.getAmount(), (short) icon.getData()));
if (is == null) {
is = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.STONE));
}
if (is.getTag() == null) {
is.setTag(new NBTTagCompound());
}
if (icon.getBukkitMeta() != null) {
try {
applyToItemMethhod.invoke(icon.getBukkitMeta(), is.getTag());
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
// add enchantment glowing
if (icon.isGlowing()) {
TagCompound enchTag = new TagCompound();
enchTag.put("id", new TagString("minecraft:feather_falling"));
enchTag.put("lvl", new TagShort(1));
TagList enchList = new TagList();
enchList.addTag(enchTag);
is.getTag().set("Enchantments", ItemStackNBTConverter.compoundToVanillaCompound(enchList));
} else {
is.getTag().remove("Enchantments");
}
// hide item attributes like attack damage
is.getTag().setInt("HideFlags", 63);
// Prepare display tag
NBTTagCompound display;
if (is.getTag().hasKey("display")) {
display = is.getTag().getCompound("display");
} else {
display = new NBTTagCompound();
is.getTag().set("display", display);
}
// set Title
if (!icon.getTitle().equals("")) {
display.setString("Name", "{\"text\":\"" + icon.getTitle() + "\"}");
}
if (icon.getLore().size() > 0) {
// set Lore
NBTTagList loreTag = new NBTTagList();
display.set("Lore", loreTag);
for (String loreLine : icon.getLore()) {
IChatBaseComponent cm = CraftChatMessage.fromStringOrNull(loreLine);
loreTag.add(NBTTagString.a(IChatBaseComponent.ChatSerializer.a(cm)));
}
}
if (icon.hasMeta()) {
TagCompound tag = new TagCompound();
icon.getMeta().applyTo(tag);
NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag);
for (String key : vanillaTag.getKeys()) {
is.getTag().set(key, vanillaTag.get(key));
}
}
if (icon.getTags() != null) {
NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(icon.getTags());
for (String key : vanillaTag.getKeys()) {
is.getTag().set(key, vanillaTag.get(key));
}
}
return is;
}
use of de.keyle.knbt.TagCompound in project MyPet by xXKeyleXx.
the class RepositoryMyPetConverterService method v1_16_R3.
public void v1_16_R3(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 CustomInventory method save.
@Override
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 != ItemStack.EMPTY) {
TagCompound item = ItemStackNBTConverter.itemStackToCompound(itemStack);
item.getCompoundData().put("Slot", new TagByte((byte) i));
itemList.add(item);
}
}
compound.getCompoundData().put("Items", new TagList(itemList));
return compound;
}
Aggregations