Search in sources :

Example 51 with Item

use of net.minecraft.server.v1_16_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_R2.Item) Field(java.lang.reflect.Field) MinecraftKey(net.minecraft.server.v1_16_R2.MinecraftKey)

Example 52 with Item

use of net.minecraft.server.v1_16_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 53 with Item

use of net.minecraft.server.v1_16_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 54 with Item

use of net.minecraft.server.v1_16_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_16_R1.inventory.CraftItemStack)9 ItemStack (org.bukkit.inventory.ItemStack)9 Test (org.junit.Test)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Field (java.lang.reflect.Field)6 Item (net.minecraft.server.v1_12_R1.Item)5 NBTTagCompound (net.minecraft.server.v1_16_R1.NBTTagCompound)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 Container (net.minecraft.server.v1_16_R1.Container)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer)3 Font (java.awt.Font)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 Block (net.minecraft.server.v1_12_R1.Block)2 Item (net.minecraft.server.v1_13_R2.Item)2 Item (net.minecraft.server.v1_14_R1.Item)2 Item (net.minecraft.server.v1_15_R1.Item)2 ContainerAnvil (net.minecraft.server.v1_16_R1.ContainerAnvil)2