ItemStack with amount higher than 64 doesnt work in chests?

Discussion in 'Spigot Plugin Development' started by Defanive, May 25, 2016.

  1. I'm trying to put ItemStacks that have amount higher than 64 in a chest interface.

    I use setAmount to make it have higher than 64 count, and when used in player.getInventory() it works perfectly.
    However, when such ItemStack put in chest interface, it doesnt go over 64 (simply shows 64).
    I also tried inventory.setMaxStackSize and it didnt work.

    The ItemStack is simply used to show numbers (currency), so it does not need to work when player click it (I will disable clicking/right clicking/what not).

    Any solution?

    Edit: using latest spigot 1.9.4
    • Useful Useful x 1
  2. Well, minecraft don't support more than 64 items stacked.
  3. It's possible to have them, I have seen it before. (On a server in 1.9.2) Maybe they used packets; but I highly doubt that.
  4. Its possible the max stack size is from -127 ((signed byte) 0xFF) to 127 ((signed byte) 0x00). If you want to show an itemstack in the chest with over an stacksize of 64 than you must create a own inventory and you also must redefine the max stack size.
  5. Oh, wow.. I had the same problem, in which I even pointed out that the different inventories were problematic... But until now I didn't think that the inventories themselves were the problem, so I found this: Inventory#setMaxStackSize(int size). In my initial testing, it does not seem as to work as requested, though, so I'm looking into an nms solution / custom inventory.
  6. The inventory has ha check if the itemstack over 64. If is over 64 than its sets to 64 ;)
    • Like Like x 1
  7. A project of mine required me to change the max stack size of an ItemStack with NMS, and the following is for 1.9.4 (I have not tested this on inventories, although I would presume it would work fine):

    Code (Text):
    public ItemStack setMaxStackSize(ItemStack item, int amount) {
            net.minecraft.server.v1_9_R1.ItemStack otherItem = CraftItemStack.asNMSCopy(item);
            return CraftItemStack.asBukkitCopy(otherItem);
  8. Thanks for all the replies.

    It partially does. I succeeded putting such a stack in player.getInventory() and it shows correctly. The problem is it doesnt work in chest interface

    I tried it. The interface is created by Bukkit.getServer().createInventory, and I use setMaxStackSize before adding the ItemStack, however it still doesnt not display over 64. Whats even more weird is that the same exact ItemStack is also in player.getInventory() and it shows over 64 just fine.

    Let me know if you find any solution!

    I think this is likely the case, since the exact same ItemStack but put into player.getInventory() shows over 64 just fine (even in the same interface)

    I tried this as well. This modifies the functionality of maxStackSize, so things like how much can this item stack up to when player moves it around with mouse clicking are affected (but changing it over 64 still doesnt work properly, lower than 64 works like a charm). However, the problem is that the item isnt displayed correctly, rather than its functionality..
  9. This is why Java needs unsigned bytes...
  10. Cast it to a short and than all its okey ;)
    • Informative Informative x 1
  11. @MinePlayer64 oh, it does my friend. You can encode an 8-bit integer and load all bits as number, don't care about the sign
  12. Hello,

    I have attempted to do this as well on Minecraft 1.11 by using NMS, but encountered the same problems as those described by Defanive.

    After doing some testing using a debugger, I do not think this is the case. I set the inventory's max stack size to a number greater than 64 (89 for instance) and added an ItemStack with an amount greater than 64 as well but smaller than the inventory's max stack size (88 for instance). I created a listener to capture InventoryClickEvent (in order to make sure that the inventory doesn't set the values back to 64 after the item is inserted, or when openInventory is called). The inventory would still have the 89 max stack size, and the clicked item would still have the 88 amount when interacting with the displayed inventory. Only the text would show as 64. This leads me to think that the issue that occurs when using a custom chest inventory (and probably anything else than the standard player.getInventory()) is caused by a limitation client side, or by a check when the server is creating the packets to send to the client.

    I hope this extra bit of information can be helpful and I am curious to know if anyone has managed to solve this problem. ;)
  13. TL;DR

    Please create your own thread instead of necroposting on a half year old one.
  14. I am adding valuable information and investigation to a thread that has never received a valid solution and that appears among the top threads on Google when searching how to create stacks with more than 64 items. There is no point in creating a new identical thread if it directly depends on the messages in this one, does not ask any questions, and will likely help any person searching how to do this and will end up reading this thread. Your two posts so far on this thread do not contribute to the problem of not being able to create stacks with more than 64 items, please at least read the messages instead of rudely posting a "TL;DR" and dismissing a constructive discussion just because it is a few months old (not even half a year in this case).

    As stated in the READ ME of this section, this forum can be seen as a huge database; I am simply contributing to it.
    • Like Like x 1
    • Agree Agree x 1
  15. The reason people do not want necroposting to happen on forums, is partially because people who once replied to it have to look at it again. On top of that, if a thread is at least a few months old, and nobody has replied to it, the problem is probably not relevant anymore. If it were, OP would have chosen to bump the thread and ask for more help. But they haven't, so they probably do not care about it anymore. It's best if people create new threads, as people who don't want to get involved anymore won't have to pay attention to it again.
    • Agree Agree x 1