Advertisement
jcgru

nms

Oct 23rd, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package me.yakovliam.pets.pet.v1_12.pets.flying.bat;
  2.  
  3. import net.minecraft.server.v1_12_R1.*;
  4. import org.bukkit.Location;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.util.Vector;
  7.  
  8. public class PetEntityBat extends EntityBat {
  9.  
  10.     private Player owner;
  11.     private BlockPosition b;
  12.  
  13.     public PetEntityBat(World world, Player owner) {
  14.         super(world);
  15.         this.owner = owner;
  16.     }
  17.  
  18.     @Override
  19.     protected void M() {
  20.  
  21.         if (isAsleep()) {
  22.             return;
  23.         }
  24.  
  25.         Location location = owner.getLocation();
  26.         this.b = new BlockPosition((int) location.getX() + 2, (int) location.getY() + 1, (int) location.getZ() + 2);
  27.  
  28.         if (passengers.size()  == 1) {
  29.  
  30.             Vector direction = owner.getLocation().getDirection();
  31.             Location entityLocation = getBukkitEntity().getLocation();
  32.  
  33.             this.b = new BlockPosition(entityLocation.getX() + direction.getX(), entityLocation.getY() + direction.getY(), entityLocation.getZ() + direction.getZ());
  34.         }
  35.  
  36.         double var3 = (double) this.b.getX() + 0.2D - this.locX;
  37.         double var5 = (double) this.b.getY() + 0.1D - this.locY;
  38.         double var7 = (double) this.b.getZ() + 0.2D - this.locZ;
  39.  
  40.         this.motX += (Math.signum(var3) * 0.5D - this.motX) * 0.10000000149011612D;
  41.         this.motY += (Math.signum(var5) * 0.699999988079071D - this.motY) * 0.10000000149011612D;
  42.         this.motZ += (Math.signum(var7) * 0.5D - this.motZ) * 0.10000000149011612D;
  43.  
  44.         if (passengers.size() == 1) {
  45.             this.yaw = owner.getLocation().getYaw();
  46.         } else {
  47.             this.yaw = (owner.getLocation().getYaw() < 0 ? owner.getLocation().getYaw() : -owner.getLocation().getYaw());
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement