Vinetos

[Bukkit NMS] Mount - 3

Sep 9th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. public class CustomPig extends EntityPig/*Changer le type d'animal Ex: EntityCow, EntityHorse*/{
  2.  
  3. private float speed = 0.1F;/*Vitesse de déplacement*/
  4.  
  5. public CustomPig(World world) {
  6. super(world);
  7. }
  8.  
  9. @Override
  10. public void g(float sideMot, float forMot) {
  11. if (this.passenger != null && this.passenger instanceof EntityHuman) {
  12. this.lastYaw = this.yaw = this.passenger.yaw;
  13. this.pitch = this.passenger.pitch * 0.5F;
  14. this.setYawPitch(this.yaw, this.pitch);
  15. this.aI = this.aG = this.yaw;
  16. sideMot = ((EntityLiving) this.passenger).aZ * 0.5F;
  17. forMot = ((EntityLiving) this.passenger).ba;
  18. if (forMot <= 0.0F) {
  19. forMot *= 0.25F;
  20. }
  21.  
  22. Field jump = null;
  23. try {
  24. jump = EntityLiving.class.getDeclaredField("aY");
  25. } catch (NoSuchFieldException e1) {
  26. e1.printStackTrace();
  27. } catch (SecurityException e1) {
  28. e1.printStackTrace();
  29. }
  30. jump.setAccessible(true);
  31.  
  32. if (jump != null && this.onGround) {
  33. try {
  34. if (jump.getBoolean(this.passenger)) {
  35. double jumpHeight = 0.5D;/*Hauteur du saut*/
  36. this.motY = jumpHeight;
  37. }
  38. } catch (IllegalAccessException e) {
  39. e.printStackTrace();
  40. }
  41. }
  42.  
  43. this.S = 1.0F;
  44. this.aK = this.bI() * 0.1F;
  45. if (!this.world.isClientSide) {
  46. this.k(speed); //Ou n'importe quel float, sa controle la vitesse de déplacement.
  47. super.g(sideMot, forMot);
  48. }
  49.  
  50. this.ay = this.az;//Some extra things
  51. double d0 = this.locX - this.lastX;
  52. double d1 = this.locZ - this.lastZ;
  53. float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
  54. if (f4 > 1.0F) {
  55. f4 = 1.0F;
  56. }
  57.  
  58. this.az += (f4 - this.az) * 0.4F;
  59. this.aA += this.az;
  60. } else {
  61. this.S = 0.5F;
  62. this.aK = 0.02F;
  63. super.g(sideMot, forMot);
  64. }
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment