setting max stack size?

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

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

    -_Husky_-

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

    bleachisback

    Yes, there is.
    Code:java
    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

    -_Husky_-

    Code:java
    1.  
    2. Cheers mate
    3.  
    4. Hang on, how will this work with bukkit
    5. [USER=21175]bleachisback[/USER]
    6.  
    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

    Njol

    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

    bleachisback

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

    nisovin

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

    mushroomhostage

    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:

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

Share This Page