setting max stack size?

Discussion in 'Plugin Development' started by -_Husky_-, Mar 20, 2012.

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


    Alright. my aim is to make enderpearls take 1 whole inventory space.
    is there a "simple" way i can do this?
  2. Offline


    Yes, there is.
    1. Field field=net.minecraft.server.Item.class.getDeclaredField("maxStackSize");
    2. field.setAccessible(true);
    3. field.setInt(net.minecraft.server.Item.ENDER_PEARL, 1);
    mushroomhostage and -_Husky_- like this.
  3. Offline


    2. Cheers mate
    4. Hang on, how will this work with bukkit
    5. [USER=21175]bleachisback[/USER]
    7. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  4. Offline


    It works perfectly with (Craft)Bukkit, in fact this only works with CraftBukkit since maxStackSize is unobfuscated (assuming bleachisback is correct about the name).
  5. Offline


    Yes, that's one of the unobfuscated fields in craftbukkit
  6. Offline


    You can create this functionality without setting the maxStackSize with clever usage of the new inventory events.
  7. Offline


    Does anyone know how to do this for blocks (id < 256), as opposed to items? They're in net.minecraft.server.Block instead of net.minecraft.server.Item but Block doesn't have a maxStackSize field (and there is net.minecraft.server.ItemBlock extends Item, how does that fit in?)

    edit: nevermind, I see there is a byId array to lookup block items, instead of referencing the items in the class itself. This works for any id:

    maxStackSizeField.setInt(net.minecraft.server.Item.byId[material.getId()], 1);
    LRRoberts0122 likes this.
Thread Status:
Not open for further replies.

Share This Page