Search in sources :

Example 31 with Item

use of net.minecraft.server.v1_8_R3.Item in project MyPet by xXKeyleXx.

the class ConfigItem method load.

public void load(MaterialHolder material, String data) {
    MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
    Item item = Item.REGISTRY.get(key);
    if (item == null) {
        return;
    }
    net.minecraft.server.v1_9_R2.ItemStack is = new net.minecraft.server.v1_9_R2.ItemStack(item, 1, material.getLegacyName().getData());
    if (data != null) {
        NBTTagCompound tag = null;
        String nbtString = data.trim();
        if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
            try {
                tag = MojangsonParser.parse(nbtString);
            } catch (Exception e) {
                MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
                MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
            }
            if (tag != null) {
                is.setTag(tag);
            }
        }
    }
    this.item = CraftItemStack.asCraftMirror(is);
}
Also used : Item(net.minecraft.server.v1_9_R2.Item) NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_9_R2.MinecraftKey) CraftItemStack(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)6 ItemStack (org.bukkit.inventory.ItemStack)5 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ArrayList (java.util.ArrayList)4 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)4 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)3 NBTTagList (net.minecraft.server.v1_8_R3.NBTTagList)3 NBTTagString (net.minecraft.server.v1_8_R3.NBTTagString)3 Url (org.orcid.jaxb.model.common_v2.Url)3 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)2 ListTag (com.wasteofplastic.org.jnbt.ListTag)2 StringTag (com.wasteofplastic.org.jnbt.StringTag)2 Tag (com.wasteofplastic.org.jnbt.Tag)2 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)2 Font (java.awt.Font)2 Point (java.awt.Point)2 Map (java.util.Map)2