Issue with velocity/fall damage

Discussion in 'Plugin Development' started by monfernobud, Aug 10, 2015.

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

    monfernobud

    I'm having an issue with a plugin I'm making. When a pig takes damage I want to apply a velocity to them. To test it, I've simplified the idea to start, but even this version won't work.
    Code:
        @EventHandler
        public void onFall(EntityDamageEvent event) {
            Entity s = event.getEntity();
    
            s.setVelocity(new Vector(0, 1, 0));
            event.setCancelled(true);
        }
    With this, the pigs will fly up if they take damage any way other than fall damage for some reason. The event is working fine. Even with fall damage it's running the code. It works for players for some reason, but not mobs.
     
  2. Offline

    AcePilot10

    Use
    Code:
    s.setVelocity(s.getVelocity().multiply(3));
    //ANYTHING BETWEEN 2 AND 5 SHOULD BE GOOD
     
  3. Offline

    monfernobud

    Did you read the post?
     
  4. Offline

    AcePilot10

  5. Offline

    567legodude

    @AcePilot10 They don't want to multiply the velocity, they want them to fly up (meaning (0, 1, 0)).
    That's what they need.
     
  6. Offline

    Cycryl

    Add an if(event.getCause().equals(DamageCause.FALL))
     
Thread Status:
Not open for further replies.

Share This Page