Unlimited Dispenser?

Discussion in 'Plugin Development' started by Bobfan, Aug 8, 2012.

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

    Bobfan

    Is there a way to have dispensers shoot an item unlimited times?
     
  2. Offline

    Jogy34

    I would find when a dispenser shoots then either stop the item from being used or record the entity and then cancel the event and manually shoot it from the dispensers location
     
  3. Offline

    Bobfan

    So it would find the dispensers location, cancel the dispenser from shooting, but recording what item it is, and than dispensing it from the dispenser's location? I think that could work, ty.
     
  4. Offline

    chaseoes

    I would have listened for when it dispenses, get the item, and put the same type of item back in it. Not sure if it's possible to put items in one though, never worked with them.
     
    -_Husky_- likes this.
  5. Offline

    Bobfan

    no I think Jogy34's method would work better, but turns out I won't need this, I found a better way for my plugin instead of dispencers
     
  6. Offline

    kingBS11

    You will need to first get the dispenser. Then you need to get the dispenser's inventory. After that on the dispense event you need to add what is being dispensed.
    Code:
    Dispenser dispenser = (Dispenser) event.getBlock();
    Inventory inv = dispenser.getInventory();
    inv.addItem(event.getItem());
     
  7. Offline

    Tirelessly

    Thank you for answering this 4 month old question.
     
    kingBS11 likes this.
  8. Offline

    kingBS11

    Dude it's just for a reference in the future.
     
  9. Offline

    tommycake50

    maybe so but he has a point :/
     
  10. how i do it:
    Code:
    ItemStack newItemStack = event.getItem().clone();
            dispenser.getInventory().addItem(newItemStack);
    and it's NEVER too late to solve a post.
     
  11. Offline

    kingBS11

    I tried this way for my plugin and it didn't work
     
  12. Offline

    fireblast709

    kingBS11 check what the ItemStack is
     
  13. what i posted is not the entire code. it will give errors.
     
  14. Offline

    kingBS11

    This is solved :p
     
Thread Status:
Not open for further replies.

Share This Page