Solved Allowing more potion ingredients?

Discussion in 'Plugin Development' started by RAFA_GATO_FOFO, May 28, 2014.

Thread Status:
Not open for further replies.
  1. Hey,

    I'm trying to add new potion ingredients like apples, regular melons and stuff like that. The thing is I can't actually place them on a Brewing Stand. So what I've been trying to do is make it possible to place these items in the Brewing Stand's Inventory. I've researched a bit on brewing and it seems like moving an item into the Brewing Stand calls out the InventoryMoveItemEvent but for some odd reason that's not working. Whenever I try placing an item in the brewing stand (like sugar for example), the debug broadcasts still don't show.
    Here's what I've got so far:
    Code:java
    1. @EventHandler
    2. public void onBrew(BrewEvent event){
    3. BrewerInventory inv = event.getContents();
    4. ItemStack ingredient = inv.getIngredient();
    5.  
    6. for (ItemStack is : Core.getIngredients()){
    7. if (is.equals(ingredient)){
    8. Bukkit.broadcastMessage("YAY");
    9. }
    10. }
    11. }
    12.  
    13. @EventHandler
    14. public void onIngredientPlace(InventoryMoveItemEvent event){
    15. Bukkit.broadcastMessage("moving an item are yah?");
    16. if (event.getDestination().equals(InventoryType.BREWING)){
    17. Bukkit.broadcastMessage("yup destination is brewing stand");
    18. for (ItemStack is : Core.getIngredients()){
    19. if (is.equals(event.getItem())){
    20. event.setCancelled(false);
    21. Bukkit.broadcastMessage("worksings");
    22. }
    23. }
    24. }
    25. }


    Cheers.
     
  2. Offline

    mine-care

    RAFA_GATO_FOFO
    Isnt there a brewing recipe like shapeless craft recipe?
     
  3. mine-care
    I'm afraid I haven't found anything regarding that.
     
  4. Offline

    Onlineids

    Heres the best I could do xD buggy as hell tho
    Code:java
    1. @EventHandler
    2. public void onClick(final InventoryClickEvent e){
    3. if(!(e.getInventory().getType() == (InventoryType.BREWING))) return;
    4. String action = e.getAction().toString();
    5. if(e.getAction() == InventoryAction.PLACE_ALL || e.getAction() == InventoryAction.PLACE_ONE){
    6. String slot = String.valueOf(e.getRawSlot());
    7. if(e.getRawSlot() == 3){
    8. ItemStack[] contents = e.getInventory().getContents();
    9. e.getInventory().clear();
    10. final Inventory inv = Bukkit.createInventory(null, InventoryType.BREWING);
    11. ItemStack item = e.getInventory().getItem(3);
    12. if(item != null){inv.addItem(item);}
    13. for(ItemStack i : contents){
    14. if(i != null){
    15. e.getWhoClicked().getInventory().addItem(i);
    16. }
    17. }
    18. inv.setItem(3, e.getCursor());
    19. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    20. public void run() {
    21. e.getWhoClicked().openInventory(inv);
    22. }
    23. }, 3);
    24. }
    25. }
    26. }
     
  5. Onlineids
    Thanks man but does that even do anything? I've loaded it on my server and all I get is Stack Trace upon Stack Trace :p
     
  6. Offline

    Onlineids

    Worked fine for me :eek:
     
  7. Onlineids
    Does it allow you to place items that you usually wouldn't be able to in a brewing stand? Because I couldn't really do anything other than the normal stuff. Plus the Stack Traces :cool:
     
  8. Offline

    Onlineids

    Yea what errors are you getting? For me it allowed you to place anything you want in the ingredient slot
     
  9. Onlineids

    Alright so I've registered the event wrong from another class to main lol
    When I grab 3 apples and try to place 1 it suddenly places all 3 apples and drops the 3 I have. So basically it doubles them.
    But whenever I retrieve an Item from the Brewing Stand to my inventory I get this:
    http://pastebin.com/7hxNCzuY
     
  10. Offline

    Onlineids

    Like I said very buggy :3
     
  11. Onlineids
    ahaha Alright I'll take what I can get and work from there. Thanks for the help man!
     
Thread Status:
Not open for further replies.

Share This Page