Search in sources :

Example 61 with Item

use of net.minecraft.server.v1_11_R1.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_R3.Item) Field(java.lang.reflect.Field) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey)

Example 62 with Item

use of net.minecraft.server.v1_11_R1.Item in project PaperDev by Kamillaova.

the class MaterialTest method verifyMapping.

@Test
public void verifyMapping() {
    Map<Integer, Material> materials = Maps.newHashMap();
    for (Material material : Material.values()) {
        if (INVALIDATED_MATERIALS.contains(material)) {
            continue;
        }
        materials.put(material.getId(), material);
    }
    Iterator<Item> items = Item.REGISTRY.iterator();
    while (items.hasNext()) {
        Item item = items.next();
        if (item == null)
            continue;
        int id = CraftMagicNumbers.getId(item);
        String name = item.getName();
        Material material = materials.remove(id);
        assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue())));
    }
    assertThat(materials, is(Collections.EMPTY_MAP));
}
Also used : Item(net.minecraft.server.v1_12_R1.Item) Test(org.junit.Test)

Example 63 with Item

use of net.minecraft.server.v1_11_R1.Item in project PaperDev by Kamillaova.

the class CraftStatistic method getMaterialFromStatistic.

public static Material getMaterialFromStatistic(net.minecraft.server.v1_12_R1.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
Also used : Item(net.minecraft.server.v1_12_R1.Item) Block(net.minecraft.server.v1_12_R1.Block) MinecraftKey(net.minecraft.server.v1_12_R1.MinecraftKey)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 CraftItemStack (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack)17 ItemStack (org.bukkit.inventory.ItemStack)13 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)12 Test (org.junit.Test)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Field (java.lang.reflect.Field)6 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)5 Item (net.minecraft.server.v1_12_R1.Item)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ArrayList (java.util.ArrayList)4 Container (net.minecraft.server.v1_11_R1.Container)3 NBTTagList (net.minecraft.server.v1_11_R1.NBTTagList)3 NBTTagString (net.minecraft.server.v1_11_R1.NBTTagString)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)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