Items

Discussion in 'Plugin Development' started by ewrs, Aug 22, 2018.

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

    ewrs

    Hello. I have a question. How can I make sure that some things do not stack on the ground and in the inventory? It is very necessary for me.

    Sorry for my english, he's not among the best

    up

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 22, 2018
  2. Offline

    MrGeneralQ

    If the ItemName or MetaData of the item is different, it won't stack
     
  3. Offline

    ewrs

    When a player dies, a bone is dropped from him, but if he dies again, the thing stacks.
    And on ordinary cubecraft diamonds and do not stack, and they are without metadata
     
  4. Offline

    MrGeneralQ

    If it doesn't have ItemMeta then set some yourself
     
  5. Offline

    ewrs

    Why are you so hard to understand so obvious things? I DO NOT (DO NOT NEED) MetaData
     
  6. Offline

    Zombie_Striker

    @ewrs
    Because you're not understanding something so obvious. If you change the item meta, the ItemStacks won't stack.

    There is no other built-in method to change the max-amount for stacked items.
     
  7. Offline

    ewrs

    If two things are the same ItemMeta, they stack
     
  8. Offline

    Zombie_Striker

    @ewrs
    Exactly, so you want to make sure the item metas are different if you do not want them to stack.
     
  9. Offline

    ewrs

    I'm not very good with English, maybe I'm not reading this way, but I absolutely did not understand anything .... Example?
     
  10. Offline

    Zombie_Striker

    @ewrs
    Code:
    ItemStack stackableDiamond = new ItemStack(Material.DIAMOND);
    //This will be able to stack with all other diamonds.
    
    ItemSack unstackableDiamond = new ItemStack(Material.DIAMOMD);
    ItemMeta im = unstackableDiamond .getItemMeta();
    im.setLore(Arrays.asList(ChatColor.BLACK+UUID.randomUUID().toString()));
    unstackableDiamond.setItemMeta(im);
    //This will create a diamond that will not stack with any other diamonds.
    
     
  11. Offline

    ewrs

    How do I make sure that this thing is not pick uped if it generates randomly? ...
     
  12. Offline

    Zombie_Striker

    What do you mean by "randomly"? If you mean to generate it whenever any of the item is dropped/created, you will need to listen to the ItemPickupEvent and use the above method if the item does not have the lore/uuid.
     
  13. Offline

    ewrs

    Then why does not it work?
    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onDeath(PlayerPickupItemEvent e) {
            ItemStack unstackableBone = new ItemStack(Material.BONE);
            ItemMeta im = unstackableBone .getItemMeta();
            im.setLore(Arrays.asList(ChatColor.BLACK+UUID.randomUUID().toString()));
            unstackableBone.setItemMeta(im);
            if(e.getItem().getItemStack().equals(unstackableBone)) {
                e.setCancelled(true);
            }
        }
     
  14. Offline

    Zombie_Striker

    Because, again the whole point of setting the item meta is so the items are not equal to eachother. What you need to do is check if the item being picked up is the same type as the bone.
     
  15. Offline

    ewrs

  16. Offline

    Zombie_Striker

    @ewrs
    e.getItem().getItemStack().getType == unstackableBon.getType()
     
  17. Offline

    ewrs

    @Zombie_Striker

    Thank you so much! But one nuance, how do I make it a red dye? I get only black.

    Please check the subject with ArmorStand

    UPD: All. I figured it out myself. Thank you so much! Do not forget to check the subject with ArmorStand, please.

    @Zombie_Striker,

    Hey. I'm sorry, but I can not understand. Why do not objects have a name on this server, but can not they be lifted? I picked them up using a funnel and they do not have any LORE

    http://i.piccy.info/i9/b00bb449a6253b2fc6bcc2a5aa1dd501/1535189346/33556/1265090/mi720.jpg
    http://i.piccy.info/i9/8a0a28d5481d4a953dac73b1c50df514/1535189377/16331/1265090/mi721.jpg

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 25, 2018
  18. Offline

    ewrs

    Hey. Me again. Yes, your method really works, thanks. But here such a thing. When a player dies, a bone falls from him. it can not be raised and it disappears (as it should), but if it falls off the skeleton, the plugin recognizes it is the same and the players can not raise it. What should I do?
     
  19. Offline

    ewrs

Thread Status:
Not open for further replies.

Share This Page