Search in sources :

Example 56 with Item

use of net.minecraft.server.v1_12_R1.DataWatcher.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 57 with Item

use of net.minecraft.server.v1_12_R1.DataWatcher.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

CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)30 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)27 ItemStack (org.bukkit.inventory.ItemStack)22 ItemMeta (org.bukkit.inventory.meta.ItemMeta)12 ArrayList (java.util.ArrayList)10 Player (org.bukkit.entity.Player)9 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)8 ChannelPromise (io.netty.channel.ChannelPromise)8 PreparedStatement (java.sql.PreparedStatement)7 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)7 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 Item (net.minecraft.server.v1_12_R1.Item)5 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)5 Location (org.bukkit.Location)5 OfflinePlayer (org.bukkit.OfflinePlayer)5 PlayerInventory (org.bukkit.inventory.PlayerInventory)5