Increase stack sizes

Discussion in 'Plugin Development' started by andrewginn, Apr 5, 2016.

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

    andrewginn

    Hello I am new to coding and I want to code a plugin so I can get used to all the events I have to use, I came across this plugin and I was wondering if anyone could give me a jump start, please don't spoonfeed me that's the last thing I want to do, just someone give me a heads up on how I can get closer to my goal for this plugin. What I was wanting to do is change the stackamount for a certain item.

    Thanks for all the help!
     
    Last edited: Apr 5, 2016
  2. Offline

    WolfMage1

    isn't there a setAmount method in item stack?
     
  3. Offline

    mcdorli

    Yeah, but if you pick up and place down ab overflowed stack, ut splits up.
     
  4. Offline

    andrewginn

    @mcdorli Yeah I saw that except I cannot find anything on the web on how to put that into a method
     
  5. Offline

    mcdorli

    How do you mean you don't know how to put it in a method?
     
  6. Offline

    andrewginn

    For instance I could make a class extend the javaplugin and all, make the public void and I dunno how I would make it so when the bucket enters the players inventory it scans for others of the same material and then stacks them. I don't know how to put that into code.

    @mcdorli
     
  7. Offline

    mcdorli

    You need a playerpickupitemevent
     
  8. Offline

    andrewginn

    @mcdorli I will try and test for a bit
     
  9. Offline

    DoggyCode™

    I think you could achieve this nicely by modifying one of the packets (idk which xD).
     
  10. Offline

    andrewginn

  11. Offline

    DoggyCode™

    Packets are basically the only access we have to modify the game.

    You can find a list of them here: http://wiki.vg/Protocol (they allow you to do client side cool stuff)
     
  12. Offline

    andrewginn

    Ahh okay I understand @DoggyCode™

    I got somewhere with another plugin I was testing but for some reason when I change the b.getType to b.getDrops it starts throwing the red lines at me. Any idea on how to fix this? Here is my code http://pastebin.com/y2CxM3W5
     
  13. Offline

    DoggyCode™

    getDrops should return a ItemStack list. Loop through it
    Code:
    for(ItemStack item : b.getDrops()){
      //then add the item to the inventory
      p.getInventory().addItem(item);
    }
    Edit:
    Or idk, possibly do something like:
    Code:
    //make an ItemStack array
    ItemStack[] itemStacks = b.getDrops();
    //I believe you can add arrays to inventory 
    p.getInventory().addItem(itemStacks);
     
    Last edited: Apr 6, 2016
  14. Offline

    andrewginn

    Thanks man, from all the java researching I did last never I never saw for? I did do java a long time ago and it does ring a bell is it something to do with numbers like doubles or floats?
     
  15. Offline

    DoggyCode™

    Umm, yeah, number increment are often done in loops. I'd suggest you take a look at all the possible loops: http://www.tutorialspoint.com/java/java_loop_control.htm

    Generally, you have the for loop and while loop, but there are some others. Example:
    Code:
    int i = 0;
    //this loop would stop whenever i reached 10
    while(i<10){
      i++; //increases the int by one every time it loops
    }
    You would probably use the for loop more :p
     
  16. Offline

    andrewginn

    Okay so I got all that working thanks, I wanted to go on from this plugin and to make a autosmelt method, in my case will I have to create a list of blocks that will be autosmelted if entered into the players inventory? I can explain what I want but I don't know how to do it xD For instance I can make lists but I don't have a clue on what the code is for autosmelting. Could u start me off? xD @DoggyCode™
     
  17. Offline

    DoggyCode™

    I could probably, but I need to go. However, there should be some sort of inventory event that detects whenever you get a item in ur inventory.
     
  18. Offline

    andrewginn

    @DoggyCode™ Okay no worries I will take a look at the java api docs
     
Thread Status:
Not open for further replies.

Share This Page