Solved Disable stacking for a certain item

Discussion in 'Plugin Development' started by TheGamblingMan, Jul 3, 2014.

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

    TheGamblingMan

    I think the title tells moste of that what i want :)

    But again i want to disable that a certain item doesn't stack when it get's dropped 1 by 1
     
  2. Offline

    Epicballzy

    I'm not sure that can be done. But then again, I haven't had to something like that. Try changing the items metadata?
     
  3. Offline

    TheGamblingMan

    Do you mean that i change the item meta for every item that gets dopped and than remove it when a player pick's it up?
     
  4. Offline

    Zettelkasten

  5. Offline

    whitehooder

    Just to be clear... Do you mean stacking in the inventory or the grouping of dropped items laying on the ground?
    Sounds like that's what you're getting at, and I believe it is all client-side. Not a hundred percent sure about this, but I've glanced over the Craftbukkit source and didn't find anything related to grouping. If you'd like to take a look yourself: https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/EntityItem.java
    Bounding box seemed a bit interesting and it might be that. You could try to mess about with it and see if it makes any difference. Also, the metadata thing might work and might not work, but I'd rather try just adding a custom code to the item's lore. Give it a shot, best of luck.
     
  6. Offline

    TheGamblingMan

    i know that it works because in many rush plugins i see that the items don't stack when they get dropped so in the inventory they get stacked but on the ground not
     
  7. Offline

    MordorKing78

    I Did this before but not in a Real code way. So my script were if a zombie dies he will drop a nugget. But I did not want it to stack. I Used a config like:
    - You get the Name of the nugget (Using getConfig method)
    - You set the name +1 every time a zombie dies (Using +1(eZ))
    Its hard to explain. (Result: All de nugget will have an oher name, 1 2 3 4 5 6 7 8 etc) And you cant stack it in your inventory. You can check if its in he invenory and remove it and replace it with an regular gn. But thats up to you.
     
  8. Offline

    TheGamblingMan

    so you mean that every time i dropp a item i add something different to the name so that it's never the same and when a player picks it up i change it to the old name
     
  9. Offline

    Skye

    Sounds like it'd be easy to do with:
    • PlayerInventoryEvent by checking if the InventoryAction is a place and cancelling it if cursor ItemStack is similar to the one in the clicked slot
    • PlayerPickupItemEvent by removing drop and manually adding it to the player's inventory in a null slot
     
  10. Offline

    TheGamblingMan

    i understand the player pickup event but not the playerinventory event
    what do you mean if the inventoryaction is a place
    and is there a other way to because the playerinventoryevent is deprecated i know i can use it but i only wanted to know it?

    i made it now so that every item that get's dropped has a nother itemlore but how can i remove the lore of that item when a player picks it up?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  11. Offline

    whitehooder

    On PlayerPickupItemEvent simply set the lore to zero. Might be a wise choice to set the lores to something special (a code for instance followed by a number to make the lore unique (might not have to be unique, you should test that out)) so that items with lore that is supposed to be there, won't lose it.
     
  12. Offline

    TheGamblingMan

    but i don't want to set all lores to zero when i pick up something
     
  13. Offline

    Skye

    I meant the InventoryClickEvent, I always mix the two up. You'd have to use getAction() to get the InventoryAction that was used. If you check to see that the item is what you don't want stacked and that the InventoryAction is one of the place events, you can cancel it, and players will be unable to manually stack them.
     
  14. Offline

    whitehooder

    Which is why I said you should only remove the lore you've created. Set the lore of a dropped item to a code, for instance a color code sequence. When an item is picked up, check if the lore is that special code of yours. If it matches you go ahead and remove the lore.
     
  15. Offline

    TheGamblingMan

    but when i set for every item the same lore they stack again

    ok found solution anyways thy for the help :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page