コード例 #1
0
  @Override
  public void j_() {
    super.j_();
    if (npc == null) return;
    boolean navigating = npc.getNavigator().isNavigating();
    updatePackets(navigating);
    if (gravity
        && !navigating
        && getBukkitEntity() != null
        && Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))
        && !NMS.inWater(getBukkitEntity())) {
      move(0, -0.2, 0);
      // gravity. also works around an entity.onGround not updating issue
      // (onGround is normally updated by the client)
    }
    if (!npc.data().get("removefromplayerlist", true)) g();
    if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
      motX = motY = motZ = 0;

    NMS.updateSenses(this);
    if (navigating) {
      Navigation navigation = getNavigation();
      if (!navigation.f()) navigation.e();
      moveOnCurrentHeading();
    } else if (motX != 0 || motZ != 0 || motY != 0) {
      e(0, 0); // is this necessary? it does controllable but sometimes
      // players sink into the ground
    }

    if (noDamageTicks > 0) --noDamageTicks;
    npc.update();
  }
コード例 #2
0
  @Override
  public void A_() {
    super.A_();
    if (npc == null) return;
    if (updateCounter + 1 > Setting.PACKET_UPDATE_DELAY.asInt()) {
      updateEffects = true;
    }
    livingEntityBaseTick();

    boolean navigating = npc.getNavigator().isNavigating();
    updatePackets(navigating);
    if (!navigating
        && getBukkitEntity() != null
        && npc.getTrait(Gravity.class).hasGravity()
        && Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
      g(0, 0);
    }
    if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
      motX = motY = motZ = 0;
    }
    if (navigating) {
      if (!NMSImpl.isNavigationFinished(navigation)) {
        NMSImpl.updateNavigation(navigation);
      }
      moveOnCurrentHeading();
    }
    NMSImpl.updateAI(this);

    if (noDamageTicks > 0) {
      --noDamageTicks;
    }

    npc.update();
  }
コード例 #3
0
 @Override
 public void m() {
   if (npc != null) {
     npc.update();
     if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
       super.m();
     }
   } else {
     super.m();
   }
 }
コード例 #4
0
 @Override
 public boolean bH() {
   if (npc == null) return super.bH();
   boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
   if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
     return super.bH();
   if (super.bH()) {
     a(true, false); // clearLeash with client update
   }
   return false; // shouldLeash
 }
コード例 #5
0
  @Override
  public void setSkinName(String name, boolean forceUpdate) {
    Preconditions.checkNotNull(name);

    npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, name.toLowerCase());
    skinTracker.notifySkinChange(forceUpdate);
  }
コード例 #6
0
 @Override
 public boolean m_() {
   if (npc == null || !npc.isFlyable()) {
     return super.m_();
   } else {
     return false;
   }
 }
コード例 #7
0
 @Override
 public void g(float f, float f1) {
   if (npc == null || !npc.isFlyable()) {
     super.g(f, f1);
   } else {
     NMS.flyingMoveLogic(this, f, f1);
   }
 }
コード例 #8
0
 @Override
 public void bn() {
   if (npc == null) super.bn();
   else {
     NMS.updateAI(this);
     npc.update();
   }
 }
コード例 #9
0
 @Override
 public void c() {
   if (npc == null) {
     super.c();
   } else {
     updateAIWithMovement();
     npc.update();
   }
 }
コード例 #10
0
 @Override
 public void m() {
   if (npc != null) {
     npc.update();
     NMSImpl.minecartItemLogic(this);
   } else {
     super.m();
   }
 }
コード例 #11
0
  @Override
  public String getSkinName() {
    MetadataStore meta = npc.data();

    String skinName = meta.get(NPC.PLAYER_SKIN_UUID_METADATA);
    if (skinName == null) {
      skinName = ChatColor.stripColor(getName());
    }
    return skinName.toLowerCase();
  }
コード例 #12
0
 @Override
 public void c() {
   if (npc != null) {
     npc.update();
     if (motX != 0 || motY != 0 || motZ != 0) {
       motX *= 0.98;
       motY *= 0.98;
       motZ *= 0.98;
       yaw = getCorrectYaw(locX + motX, locZ + motZ);
       setPosition(locX + motX, locY + motY, locZ + motZ);
     }
   } else super.c();
 }
コード例 #13
0
 @Override
 public void g(double x, double y, double z) {
   if (npc == null) {
     super.g(x, y, z);
     return;
   }
   if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
     if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) super.g(x, y, z);
     return;
   }
   Vector vector = new Vector(x, y, z);
   NPCPushEvent event = Util.callPushEvent(npc, vector);
   if (!event.isCancelled()) {
     vector = event.getCollisionVector();
     super.g(vector.getX(), vector.getY(), vector.getZ());
   }
   // when another entity collides, this method is called to push the
   // NPC so we prevent it from doing anything if the event is
   // cancelled.
 }
コード例 #14
0
 @Override
 protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
   if (npc == null || !npc.isFlyable()) {
     super.a(d0, flag, block, blockposition);
   }
 }
コード例 #15
0
 public boolean isNavigating() {
   return npc.getNavigator().isNavigating();
 }
コード例 #16
0
 @Override
 public boolean isCollidable() {
   return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
 }
コード例 #17
0
 private PlayerNPC(EntityHumanNPC entity) {
   super((CraftServer) Bukkit.getServer(), entity);
   this.npc = entity.npc;
   this.cserver = (CraftServer) Bukkit.getServer();
   npc.getTrait(Inventory.class);
 }
コード例 #18
0
 @Override
 public float bB() {
   return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
 }
コード例 #19
0
 @Override
 public void e(float f, float f1) {
   if (npc == null || !npc.isFlyable()) {
     super.e(f, f1);
   }
 }
コード例 #20
0
 @Override
 public void bc() {
   super.bc();
   if (npc != null) npc.update();
 }
コード例 #21
0
 @Override
 public boolean damageEntity(DamageSource damagesource, float f) {
   if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
     return super.damageEntity(damagesource, f);
   return false;
 }