Solved Returning Buckets from Crafting

Discussion in 'Plugin Development' started by SgtPunishment, Sep 26, 2013.

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

    SgtPunishment

    I've got a crafting recipe plugin and I'm adding a few new recipes that require lava/water buckets, but I'm wondering how do I return the correct amount of empty buckets?

    The code below returns 4 buckets in total (Even tho only two was used), two as soon as I pull the obsidian from the result slot and 2 more when I close the crafting grid...

    Here is my code so far.

    From the UberRecipes.java file
    Code:java
    1. if (getConfig().getBoolean("settings.recipes.obsidian", true)) {
    2. ItemStack Obsidian = new ItemStack(Material.OBSIDIAN);
    3. ShapelessRecipe Obby = new ShapelessRecipe(Obsidian).addIngredient(
    4. Material.LAVA_BUCKET).addIngredient(Material.WATER_BUCKET);
    5. getServer().addRecipe(Obby);
    6. } else {
    7. }


    From my CraftListener.java file
    Code:java
    1. if ((result.getCurrentItem().equals(Obsidian))
    2. && (!p.hasPermission("UberRep.Obsidian"))) {
    3. p.sendMessage(ChatColor.RED
    4. + "You do not have permission to craft Obsidian!");
    5. result.setCancelled(true);
    6. return;
    7. } else {
    8. p.getInventory().addItem(new ItemStack(Material.BUCKET, 2));
    9. }


    Every other recipe I have made works flawlessly, but with me returning buckets... having issues

    I tried to edit the original post, but it's not working... but it even effects the cake recipe... I get extra buckets when I close the crafting grid...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    3ptO

    SgtPunishment I don't see anything wrong, is Minecraft automatically returning the buckets?
     
  3. Offline

    SgtPunishment

    Basically when I pull the obsidian from the crafting grid I get 2 buckets, which is the desired result BUT when I leave the crafting grid, I get 2 EXTRA buckets, so I get 4 buckets total (Sorta like a Dupe bug) but this doesn't just effect recipes with buckets, I just tested a vanilla recipe and I get given 2 buckets...

    Okay, I have fixed the whole vanilla crafting recipe returning buckets... but I'm still been given extra buckets from my recipe...
     
  4. Offline

    3ptO

    SgtPunishment The vanilla recipe can be explained.
    Code:java
    1. if ((result.getCurrentItem().equals(Obsidian))
    2. && (!p.hasPermission("UberRep.Obsidian"))) {
    3. //ignore
    4. } else {
    5. p.getInventory().addItem(new ItemStack(Material.BUCKET, 2));
    6. }

    You are returning 2 buckets to anything that is not resulting to Obsidian as long as you have "UberRep.Obsidian" perm.
     
  5. Offline

    SgtPunishment

    I tried this

    Code:java
    1. if ((result.getCurrentItem().equals(Obsidian))
    2. && (!p.hasPermission("UberRep.Obsidian"))) {
    3. p.sendMessage(ChatColor.RED
    4. + "You do not have permission to craft Obsidian!");
    5. result.setCancelled(true);
    6.  
    7. } else if ((result.getCurrentItem().equals(Obsidian))
    8. && (p.hasPermission("UberRep.Obsidian"))) {
    9. p.getInventory().addItem(new ItemStack(Material.BUCKET, 2));
    10.  
    11. }


    same result
     
  6. Offline

    3ptO

    SgtPunishment That should have stopped vanilla recipes from returning the 2 buckets?

    Anyhoo, you are sure Minecraft is not automatically returning said buckets?

    Oh and you could always return one bucket and it actually give two haha
     
  7. Offline

    SgtPunishment

    Oh what do you know... it was actually returning the buckets... I didn't know LOL *facepalms*
     
  8. Offline

    3ptO

Thread Status:
Not open for further replies.

Share This Page