Unlimited stacks?

Discussion in 'Plugin Development' started by spankynutbean, May 20, 2013.

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

    spankynutbean

    I was just wondering how you can make an item e.g gold nugget stack over 64 for an unlimited amount?
     
  2. Offline

    Skyshayde

    I do not believe you can have it store more than 64, but what you can do is add one. I'll show some psuedocode

    Code:
    Integer count = null;
    onItemUse(event which fires on item/block use event) {
    count--
    if count != 0) { 
    increment the item stack 1
    }
    }
    
    Something like this, with config storage for persistence might work
     
  3. You can add a lore to an item to make it say unlimited. Then register the events that are fired when an inventory changes, when the item lore contains unlimited you can set the amount back to the original size.
    Hope that helped you.
     
  4. You can use reflection to edit the max stack ammount, I don't know if you can make it higher then 64...
     
  5. You can't. There is a method (item.setMaxStackSize(int)) but it does not accept values higher than 64.
     
  6. If you are referring to my post then please re-read my post because I'm talking about reflection and cbo code, not bukkit code.

    The reflection way =
    Code:
    public void setStackSize(Item item, int i){
    try {
      Field field = Item.class.getDeclaredField("maxStackSize");
      field.setAccessible(true);
      field.setInt(item, i);
     
    } catch (Exception e) {}
    }
     
  7. CaptainBern
    Must have missed that. The reflection way might just work.
     
  8. Offline

    spankynutbean

    How do i make this work for one item, say gold nuggets?
     
  9. the method he posted accepts a item argument, guess what happens when you pass the gold nugget item as the argument
     
  10. Offline

    spankynutbean

    ferrybig So...
    Code:
    public void setStackSize(Item GOLD_NUGGET, int i){
            try {
              Field field = Item.class.getDeclaredField("maxStackSize");
              field.setAccessible(true);
              field.setInt(GOLD_NUGGET, i);
            //TODO Make it work
            } catch (Exception e) {}
            }
    ?
     
  11. Offline

    spankynutbean

  12. Offline

    Skyshayde

    Do you actually want it to hold an unlimited amount of items? or just a higher than 64 amount?
     
  13. Offline

    spankynutbean

    Unlimited would be nice but any number above 64 would do
     
  14. Offline

    Skyshayde

    just give them another one whenever they use one?
     
Thread Status:
Not open for further replies.

Share This Page