READ

Discussion in 'Spigot Plugin Development' started by Kadioshi, May 7, 2015.

  1. Hey, I have two questions;
    How can I make myself COMPLETLY invisible to other players using the PlayerItemConsumeEvent, and
    how would I add health using the PlayerItemConsumeEvent?
     
  2. Add invisibility potion effect, and p.setHealth();
    You also asked this in another thread? People answered you.. Why not just stick to that one?
     
  3. gigosaurus

    Supporter

    • Agree Agree x 1
  4. How would I make it so when I ate the bread it insta eat. like instead of waiting a long time to eat it instaeats?
     
  5. gigosaurus

    Supporter

    Not sure why the other thread was closed rather than this one.

    Listen to the PlayerInteractEvent and check for the Action being a right click of some sort and the item being bread. Cancel the event, remove 1 of the item from the players inventory and increase their hunger bar the correct amount.
     
  6. @Kadioshi you listen for the PlayerInteractEvent, and if they right click bread, remove the bread from their hand and do whatever you want to do.
     
  7. @Kadioshi, if im understanding this correct, u want to eat an item, lets say steak, and when u eat it, it gives you invis right?
     
  8. But will this remove the animation completely? How would I count like half the amount of ticks.
     
  9. No. When you eat an item I want it to add the health that is solved however.
    I want it to make it so it like does a half animation of eating then stops the animation.
     
  10. How would I remove the bread?
     
  11. Ah ok so you want to eat it them basically remove it from your inventory then gives you health
     
  12. Detect start of eating, then run a timer, which cancels the event, then set player's health.
     
  13. @vk2gpz No, he wants to eat a food item play half an animation them remove from his inventory, to do this you need to add the onPlayerInteractEvent(PlayerInteractEvent) then add which food, along with setting the health which would be p.setHealth(20); then make it remove from the inventory. thats how you would do it.
     
  14. How would you remove it from the inventory then?
     
  15. Hmm, you know im not sure, ill look into it, im coding myself a SMP Plugin, and this has interested me, to maybe implement something like this, but when i find something that can remove it from the inventory ill let you know wont take long
     
  16. That's what I described. You just run the timer to make the animation goin a very short period of time and start do the rest of process, giving health, decrement the count of itemstack(food), etc. if you just start processing what you described, I don't think you can see the animation.
     
  17. Just decrement the stack count.
     
  18. Pm me, I can show you...it would be 10-20(max) lines of code.
     
  19. @Kadioshi When ill find it ill just see if i can code it for myself then give you the code, and yes @vk2gpz i understand this but he wanted it explained more in detail