public int compare(EntityPlayerMP par1EntityPlayerMP, EntityPlayerMP par2EntityPlayerMP) {
   double d0 =
       par1EntityPlayerMP.getDistanceSq(
           (double) this.theChunkCoordinates.posX,
           (double) this.theChunkCoordinates.posY,
           (double) this.theChunkCoordinates.posZ);
   double d1 =
       par2EntityPlayerMP.getDistanceSq(
           (double) this.theChunkCoordinates.posX,
           (double) this.theChunkCoordinates.posY,
           (double) this.theChunkCoordinates.posZ);
   return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
 }
Exemple #2
0
  /** Send message to all within 64 blocks that have this chunk loaded */
  public static void sendToNearby(World world, BlockPos pos, IMessage toSend) {
    if (world instanceof WorldServer) {
      WorldServer ws = (WorldServer) world;

      for (EntityPlayer player : ws.playerEntities) {
        EntityPlayerMP playerMP = (EntityPlayerMP) player;

        if (playerMP.getDistanceSq(pos) < 64 * 64
            && ws.getPlayerChunkMap()
                .isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) {
          HANDLER.sendTo(toSend, playerMP);
        }
      }
    }
  }