I want to know what code is instead of MaterialData

Discussion in 'Plugin Development' started by UnNature, Mar 8, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    UnNature

    Hello
    First, i don't speak English well. There will be some typo.

    Anyway, my question is this.
    MaterialData() is deprecated . so how do I programming?

    I watched video for develop plugins. In the video, he used MaterialData() for expression GUI
    Here is code (not all code. just part of it.)
    Code:
        public void Stack(String Display, int ID, int DATA, int STACK, List<String> lore, int loc, Inventory inv) {
            ItemStack item = new MaterialData(ID, (byte)DATA).toItemStack(STACK);
            ItemMeta item_Meta = item.getItemMeta();
            item_Meta.setDisplayName(Display);
            item_Meta.setLore(lore);
            item.setItemMeta(item_Meta);
            inv.setItem(loc, item);
        }
    
    I got red line first code. so i think 'oh! parameter ID is not Material type!'.
    and change 'int ID' to 'Material ID'. But still red line. the message is ''MaterialData() is deprecated".

    What should I do in this case??? I want use all there parameter.
     
    Last edited by a moderator: Mar 8, 2020
  2. Offline

    Machine Maker

    So yeah, don't use MaterialData to create an item.
    Use the ItemStack constructors. (aka new ItemStack())
    Then you can get the item meta, set the name, lore, etc.
     
  3. Offline

    UnNature

    thx for you reply. I will do coding with your comment!! :)
     
Thread Status:
Not open for further replies.

Share This Page