예제 #1
0
 public void updatePlayerList(List list)
 {
     playerEntitiesUpdated = false;
     if (!firstUpdateDone ||
         trackedEntity.getDistanceSq(lastTrackedEntityPosX, lastTrackedEntityPosY, lastTrackedEntityPosZ) > 16D)
     {
         lastTrackedEntityPosX = trackedEntity.posX;
         lastTrackedEntityPosY = trackedEntity.posY;
         lastTrackedEntityPosZ = trackedEntity.posZ;
         firstUpdateDone = true;
         playerEntitiesUpdated = true;
         updatePlayerEntities(list);
     }
     if (++updateCounter%field_9234_e == 0)
     {
         int i = MathHelper.floor_double(trackedEntity.posX*32D);
         int j = MathHelper.floor_double(trackedEntity.posY*32D);
         int k = MathHelper.floor_double(trackedEntity.posZ*32D);
         int l = MathHelper.floor_float((trackedEntity.rotationYaw*256F)/360F);
         int i1 = MathHelper.floor_float((trackedEntity.rotationPitch*256F)/360F);
         int j1 = i - encodedPosX;
         int k1 = j - encodedPosY;
         int l1 = k - encodedPosZ;
         object obj = null;
         bool flag = Math.abs(i) >= 8 || Math.abs(j) >= 8 || Math.abs(k) >= 8;
         bool flag1 = Math.abs(l - encodedRotationYaw) >= 8 || Math.abs(i1 - encodedRotationPitch) >= 8;
         if (j1 < -128 || j1 >= 128 || k1 < -128 || k1 >= 128 || l1 < -128 || l1 >= 128)
         {
             obj = new Packet34EntityTeleport(trackedEntity.entityId, i, j, k, (byte) l, (byte) i1);
         }
         else if (flag && flag1)
         {
             obj = new Packet33RelEntityMoveLook(trackedEntity.entityId, (byte) j1, (byte) k1, (byte) l1,
                                                 (byte) l, (byte) i1);
         }
         else if (flag)
         {
             obj = new Packet31RelEntityMove(trackedEntity.entityId, (byte) j1, (byte) k1, (byte) l1);
         }
         else if (flag1)
         {
             obj = new Packet32EntityLook(trackedEntity.entityId, (byte) l, (byte) i1);
         }
         if (shouldSendMotionUpdates)
         {
             double d = trackedEntity.motionX - lastTrackedEntityMotionX;
             double d1 = trackedEntity.motionY - lastTrackedEntityMotionY;
             double d2 = trackedEntity.motionZ - lastTrackedEntityMotionZ;
             double d3 = 0.02D;
             double d4 = d*d + d1*d1 + d2*d2;
             if (d4 > d3*d3 ||
                 d4 > 0.0D && trackedEntity.motionX == 0.0D && trackedEntity.motionY == 0.0D &&
                 trackedEntity.motionZ == 0.0D)
             {
                 lastTrackedEntityMotionX = trackedEntity.motionX;
                 lastTrackedEntityMotionY = trackedEntity.motionY;
                 lastTrackedEntityMotionZ = trackedEntity.motionZ;
                 sendPacketToTrackedPlayers(new Packet28(trackedEntity.entityId, lastTrackedEntityMotionX,
                                                         lastTrackedEntityMotionY, lastTrackedEntityMotionZ));
             }
         }
         if (obj != null)
         {
             sendPacketToTrackedPlayers(((Packet) (obj)));
         }
         DataWatcher datawatcher = trackedEntity.getDataWatcher();
         if (datawatcher.hasObjectChanged())
         {
             sendPacketToTrackedPlayersAndTrackedEntity(new Packet40(trackedEntity.entityId, datawatcher));
         }
         if (flag)
         {
             encodedPosX = i;
             encodedPosY = j;
             encodedPosZ = k;
         }
         if (flag1)
         {
             encodedRotationYaw = l;
             encodedRotationPitch = i1;
         }
     }
     if (trackedEntity.beenAttacked)
     {
         sendPacketToTrackedPlayersAndTrackedEntity(new Packet28(trackedEntity));
         trackedEntity.beenAttacked = false;
     }
 }
예제 #2
0
 public void updatePlayerList(List list)
 {
     playerEntitiesUpdated = false;
     if (!firstUpdateDone ||
         trackedEntity.getDistanceSq(lastTrackedEntityPosX, lastTrackedEntityPosY, lastTrackedEntityPosZ) > 16D)
     {
         lastTrackedEntityPosX = trackedEntity.posX;
         lastTrackedEntityPosY = trackedEntity.posY;
         lastTrackedEntityPosZ = trackedEntity.posZ;
         firstUpdateDone       = true;
         playerEntitiesUpdated = true;
         updatePlayerEntities(list);
     }
     if (++updateCounter % field_9234_e == 0)
     {
         int    i     = MathHelper.floor_double(trackedEntity.posX * 32D);
         int    j     = MathHelper.floor_double(trackedEntity.posY * 32D);
         int    k     = MathHelper.floor_double(trackedEntity.posZ * 32D);
         int    l     = MathHelper.floor_float((trackedEntity.rotationYaw * 256F) / 360F);
         int    i1    = MathHelper.floor_float((trackedEntity.rotationPitch * 256F) / 360F);
         int    j1    = i - encodedPosX;
         int    k1    = j - encodedPosY;
         int    l1    = k - encodedPosZ;
         object obj   = null;
         bool   flag  = Math.abs(i) >= 8 || Math.abs(j) >= 8 || Math.abs(k) >= 8;
         bool   flag1 = Math.abs(l - encodedRotationYaw) >= 8 || Math.abs(i1 - encodedRotationPitch) >= 8;
         if (j1 < -128 || j1 >= 128 || k1 < -128 || k1 >= 128 || l1 < -128 || l1 >= 128)
         {
             obj = new Packet34EntityTeleport(trackedEntity.entityId, i, j, k, (byte)l, (byte)i1);
         }
         else if (flag && flag1)
         {
             obj = new Packet33RelEntityMoveLook(trackedEntity.entityId, (byte)j1, (byte)k1, (byte)l1,
                                                 (byte)l, (byte)i1);
         }
         else if (flag)
         {
             obj = new Packet31RelEntityMove(trackedEntity.entityId, (byte)j1, (byte)k1, (byte)l1);
         }
         else if (flag1)
         {
             obj = new Packet32EntityLook(trackedEntity.entityId, (byte)l, (byte)i1);
         }
         if (shouldSendMotionUpdates)
         {
             double d  = trackedEntity.motionX - lastTrackedEntityMotionX;
             double d1 = trackedEntity.motionY - lastTrackedEntityMotionY;
             double d2 = trackedEntity.motionZ - lastTrackedEntityMotionZ;
             double d3 = 0.02D;
             double d4 = d * d + d1 * d1 + d2 * d2;
             if (d4 > d3 * d3 ||
                 d4 > 0.0D && trackedEntity.motionX == 0.0D && trackedEntity.motionY == 0.0D &&
                 trackedEntity.motionZ == 0.0D)
             {
                 lastTrackedEntityMotionX = trackedEntity.motionX;
                 lastTrackedEntityMotionY = trackedEntity.motionY;
                 lastTrackedEntityMotionZ = trackedEntity.motionZ;
                 sendPacketToTrackedPlayers(new Packet28(trackedEntity.entityId, lastTrackedEntityMotionX,
                                                         lastTrackedEntityMotionY, lastTrackedEntityMotionZ));
             }
         }
         if (obj != null)
         {
             sendPacketToTrackedPlayers(((Packet)(obj)));
         }
         DataWatcher datawatcher = trackedEntity.getDataWatcher();
         if (datawatcher.hasObjectChanged())
         {
             sendPacketToTrackedPlayersAndTrackedEntity(new Packet40(trackedEntity.entityId, datawatcher));
         }
         if (flag)
         {
             encodedPosX = i;
             encodedPosY = j;
             encodedPosZ = k;
         }
         if (flag1)
         {
             encodedRotationYaw   = l;
             encodedRotationPitch = i1;
         }
     }
     if (trackedEntity.beenAttacked)
     {
         sendPacketToTrackedPlayersAndTrackedEntity(new Packet28(trackedEntity));
         trackedEntity.beenAttacked = false;
     }
 }