Hello there; I am trying to set the max stack size so that I players can only have one of the item in each slot, Any ideas on how do do this?
CaLxCyMru Checkout Inventory.setMaxStackSize(int size): http://jd.bukkit.org/rb/apidocs/org/bukkit/inventory/Inventory.html#setMaxStackSize(int) Code:java player.getInventory().setMaxStackSize(1);
Thanks for the help. I do not want to set the whole inventory; I just want to make it so "ink sacks" can't stack
CaLxCyMru Code:java public void modifyMaxStack(Item item, int amount) { try { Field f = Item.class.getDeclaredField("maxStackSize"); f.setAccessible(true); f.setInt(item, amount); } catch (Exception e) { e.printStackTrace(); return; }} This requires http://dl.bukkit.org/downloads/bukkit/, as it uses NMS Item. Usage: Code:java modifyMaxstack(Item.INK_SAC, 1); //or whatever the name of ink sac is in nms code.
Thanks; I will try this out now! Does any one know what the NMS name for Ink_Sack is ? -Thanks EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Will try it out now! Code:java modifyMaxstack(Item.BLACK_DYE, 1); modifyMaxstack(Item.INK_SACK, 1); Both do not work Bump. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
CaLxCyMru Write Item. then press ctrl + space and a list of possible values should show up in eclipse.
It is INK_SAC as can be seen in the source: https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/Item.java#L109
There is a list of the Jars I am using for my plugin, and also the code I am using, with the error. Can Any one see where I am going wrong? :? P.S I am using the LATEST Bukkit build ( http://dl.bukkit.org/downloads/bukkit/get/02390_1.6.4-R2.1/bukkit-dev.jar )