Set Horse Max Speed

Discussion in 'Plugin Development' started by TheHandfish, May 6, 2014.

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

    TheHandfish

    Hey,

    I was wondering how I modify a horse's max speed? Each horse spawns with a different max health, speed, and jump force but I'm not sure how to modify it.
     
  2. Offline

    DxDy

    Have you looked at Horse?
     
  3. Offline

    AdamQpzm

    DxDy Have you? There's not actually a method to set the max speed, which is the exactly thing that is asked for.
     
  4. Offline

    Konkz

  5. Offline

    TheHandfish

    Eh...

    ^ Thanks, but I'm not really sure what I'm supposed to do with that. ;_; I'm a newbie with NMS...

    Konkz: Any help?

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

    Drkmaster83

    I'm not a genius on mob speeds, but you edit the mob's "GenericAttributes", which are basically it's max health and NBT tag data. Here's the line of code, but be careful with the values...
    Code:
    ((CraftLivingEntity) horse).getHandle().getAttributeInstance(GenericAttributes.d).setValue(speed);
    
    Assuming 'horse' is a Horse object, this should work. I think .225 is a typical horse's speed, and it goes pretty fast if it's beyond .5-.6.

    I have no idea how to calculate it's 'max' speed, though.
     
  7. Offline

    TheHandfish

    Naaah...

    I'm not using NMS. I don't want my plugin to break that way every update. .-.
     
  8. Offline

    Panjab

    I thought every class extending Entity (which Horse definitely does) owns the method .setVelocity(Vector vec);
     
  9. Offline

    TheHandfish

    @Panjab:
     
  10. Offline

    Drkmaster83

    .setVelocity() only works until the entity's velocity degrades or updates upon each tick.
    The only way to make it not break is use Reflection, but either way, this is done by using CraftBukkit/NMS code/imports.
     
  11. Offline

    coasterman10

    Reflection will prevent your plugin from breaking for several updates. Use that to get and set the generic attributes for the entity.
     
Thread Status:
Not open for further replies.

Share This Page