Water on Players head.

Discussion in 'Plugin Development' started by MinezBombz, Nov 9, 2014.

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


    Okay so what I'm trying to do is, when a player is hit by another player (with a diamond sword), the player that got hit gets a block of water on their head(demostrated in the image) for 7 seconds. Could someone please tell me how I would achieve this? Thank you.

    P.S - Sorry for the bad artwork. :p

    Attached Files:

  2. Offline


    Is my browser forgetting something or did you forget something? I don't see any image.
  3. Offline


    Same :p i think we shoudl restart our computer. Its a outdated on from 1950 :p
  4. Offline


  5. Offline


    @MinerzBombz You can try to set the player's helmet to water.
  6. Offline


    Cute pic :3
    1. @EventHandler
    2. public void onDmg(EntityDamageByEntityEvent e) {
    3. if(e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
    4. Player p = (Player) e.getDamager();
    5. Player target = (Player) e.getEntity();
    6. if(p.getItemInHand().getType() == Material.DIAMOND_SWORD) {
    7. target.getInventory().setHelmet(new ItemStack(Material.WATER);
    8. }
    9. }
    10. }
  7. Offline


  8. xXBeLkAXx The spoonfeed.

    1. @EventHandler
    2. public void onSpoonFeed(PlayerSpoonFeedEvent e){
    3. Player player = e.getPlayer();
    5. if(e.getSpoonfeeders().contain(player)){
    6. player.setLame(true);
    7. }
    8. }

    Don't spoonfeed, he learns nothing from it.
  9. Offline


    bwfcwalshy I had everything apart from the setHelmet() part.
  10. MinezBombz Yeah because that is a hat. You may be able to achieve this by setting a block of water on the player.

    Check damage.
    Get location and put a stationary water block
    Check if they move, if so keep removing and setting the block
    Do this on a timer for 7 seconds.
    Zenexer likes this.
  11. Offline


    bwfcwalshy Thank you, I've got that working but how do I stop the water from flowing?
  12. Offline


  13. Offline


    It should be event-driven. Rather than checking if they moved, listen for a move event. It's much more efficient that way. Of course, you might've meant that, in which case I was just clarifying. ;)
  14. Zenexer Yeah I meant that :D, Sorry for not being clear.

    MinezBombz It shouldn't flow if you make it Stationary.

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


    bwfcwalshy I just figured out the problem. Thank you for your help.
Thread Status:
Not open for further replies.

Share This Page