Search in sources :

Example 21 with Item

use of net.minecraft.server.v1_13_R2.Item in project SilkSpawners by timbru31.

the class NMSHandler method setSpawnersUnstackable.

@Override
public void setSpawnersUnstackable() {
    try {
        final Item spawner = IRegistry.ITEM.get(new MinecraftKey(NAMESPACED_SPAWNER_ID));
        final Field maxStackSize = Item.class.getDeclaredField("maxStackSize");
        maxStackSize.setAccessible(true);
        maxStackSize.set(spawner, 1);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : Item(net.minecraft.server.v1_16_R1.Item) Field(java.lang.reflect.Field) MinecraftKey(net.minecraft.server.v1_16_R1.MinecraftKey)

Example 22 with Item

use of net.minecraft.server.v1_13_R2.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)

Example 23 with Item

use of net.minecraft.server.v1_13_R2.Item in project ORCID-Source by ORCID.

the class ProfileFundingManagerImpl method createItem.

private Item createItem(ProfileFundingEntity profileFundingEntity) {
    Item item = new Item();
    item.setItemName(profileFundingEntity.getTitle());
    item.setItemType(ItemType.FUNDING);
    item.setPutCode(String.valueOf(profileFundingEntity.getId()));
    return item;
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Example 24 with Item

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

the class ConfigItem method load.

public void load(String data) {
    NBTBase nbtBase = null;
    if (data.contains("{")) {
        String tagString = data.substring(data.indexOf("{"));
        data = data.substring(0, data.indexOf("{"));
        try {
            nbtBase = MojangsonParser.parse(tagString);
        } catch (Exception e) {
            MyPetApi.getLogger().warning(ChatColor.RED + "Error" + ChatColor.RESET + " in config: " + ChatColor.YELLOW + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
            MyPetApi.getLogger().warning(data + tagString);
        }
    }
    String[] splitData = data.split("\\s+");
    if (splitData.length == 0) {
        return;
    }
    Item item = null;
    if (splitData.length >= 1) {
        if (Util.isInt(splitData[0])) {
            int itemId = Integer.parseInt(splitData[0]);
            item = Item.getById(itemId);
        } else {
            item = (Item) Item.REGISTRY.get(splitData[0]);
        }
    }
    if (item != null) {
        int itemDamage = 0;
        if (splitData.length >= 2) {
            if (splitData[1].startsWith("<")) {
                this.durabilityMode = DurabilityMode.Smaller;
                splitData[1] = splitData[1].substring(1);
            } else if (splitData[1].startsWith(">")) {
                this.durabilityMode = DurabilityMode.Bigger;
                splitData[1] = splitData[1].substring(1);
            } else {
                this.durabilityMode = DurabilityMode.Equal;
            }
            if (Util.isInt(splitData[1])) {
                itemDamage = Integer.parseInt(splitData[1]);
            }
        }
        net.minecraft.server.v1_7_R4.ItemStack is = new net.minecraft.server.v1_7_R4.ItemStack(item, 1, itemDamage);
        if (nbtBase != null) {
            is.setTag((NBTTagCompound) nbtBase);
        }
        this.item = CraftItemStack.asBukkitCopy(is);
    }
}
Also used : Item(net.minecraft.server.v1_7_R4.Item) NBTBase(net.minecraft.server.v1_7_R4.NBTBase) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 25 with Item

use of net.minecraft.server.v1_13_R2.Item in project ORCID-Source by ORCID.

the class WorkEntityFactory method create.

@Override
public NotificationWorkEntity create(Object source, MappingContext mappingContext) {
    mappingContext.getSourceObjects();
    NotificationWorkEntity nwe = new NotificationWorkEntity();
    String putCode = ((Item) source).getPutCode();
    if (putCode != null) {
        WorkEntity work = workDao.find(Long.valueOf(putCode));
        nwe.setWork(work);
    }
    return nwe;
}
Also used : NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity) Item(org.orcid.jaxb.model.notification.permission_v2.Item) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 CraftItemStack (org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Field (java.lang.reflect.Field)6 NBTTagCompound (net.minecraft.server.v1_13_R2.NBTTagCompound)5 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ItemStack (org.bukkit.inventory.ItemStack)4 Url (org.orcid.jaxb.model.common_v2.Url)3 Font (java.awt.Font)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 Item (net.minecraft.server.v1_13_R2.Item)2 ItemStack (net.minecraft.server.v1_13_R2.ItemStack)2 MinecraftKey (net.minecraft.server.v1_13_R2.MinecraftKey)2 Item (net.minecraft.server.v1_14_R1.Item)2 Item (net.minecraft.server.v1_15_R1.Item)2 Item (net.minecraft.server.v1_16_R3.Item)2 Source (org.orcid.jaxb.model.common_v2.Source)2