private void d() {
    DataWatcher datawatcher = this.tracker.getDataWatcher();

    if (datawatcher.a()) {
      this.broadcastIncludingSelf(
          new PacketPlayOutEntityMetadata(this.tracker.getId(), datawatcher, false));
    }

    if (this.tracker instanceof EntityLiving) {
      AttributeMapServer attributemapserver =
          (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap();
      Set set = attributemapserver.getAttributes();

      if (!set.isEmpty()) {
        // CraftBukkit start - Send scaled max health
        if (this.tracker instanceof EntityPlayer) {
          ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false);
        }
        // CraftBukkit end
        this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set));
      }

      set.clear();
    }
  }
示例#2
0
  public void a(DataOutputStream dataoutputstream) {
    Iterator iterator = this.b.values().iterator();

    while (iterator.hasNext()) {
      WatchableObject watchableobject = (WatchableObject) iterator.next();

      a(dataoutputstream, watchableobject);
    }

    dataoutputstream.writeByte(127);
  }
示例#3
0
  public static void a(List list, DataOutputStream dataoutputstream) {
    if (list != null) {
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        WatchableObject watchableobject = (WatchableObject) iterator.next();

        a(dataoutputstream, watchableobject);
      }
    }

    dataoutputstream.writeByte(127);
  }
  @Override
  public void b(PacketDataSerializer packetdataserializer)
      throws IOException { // CraftBukkit - added throws
    packetdataserializer.b(a);

    UUID uuid = b.getId();
    // Spigot start - protocol patch
    if (packetdataserializer.version < 20) {
      packetdataserializer.a(
          uuid == null
              ? ""
              : packetdataserializer.version >= 5
                  ? uuid.toString()
                  : uuid.toString().replaceAll("-", "")); // Spigot
      packetdataserializer.a(
          b.getName().length() > 16
              ? b.getName().substring(0, 16)
              : b.getName()); // CraftBukkit - Limit name length to 16 characters
      if (packetdataserializer.version >= 5) { // Spigot
        packetdataserializer.b(b.getProperties().size());
        Iterator iterator = b.getProperties().values().iterator();

        while (iterator.hasNext()) {
          Property property = (Property) iterator.next();

          packetdataserializer.a(property.getName());
          packetdataserializer.a(property.getValue());
          packetdataserializer.a(property.getSignature());
        }
      }
    } else {
      packetdataserializer.writeUUID(uuid);
    }
    // Spigot end

    packetdataserializer.writeInt(c);
    packetdataserializer.writeInt(d);
    packetdataserializer.writeInt(e);
    packetdataserializer.writeByte(f);
    packetdataserializer.writeByte(g);
    // Spigot start - protocol patch
    if (packetdataserializer.version >= 47) {
      packetdataserializer.writeShort(org.spigotmc.SpigotDebreakifier.getItemId(h));
    } else {
      packetdataserializer.writeShort(h);
    }
    i.a(packetdataserializer);
  }
示例#5
0
  public void track(List list) {
    this.n = false;
    if (!this.s || this.tracker.e(this.p, this.q, this.r) > 16.0D) {
      this.p = this.tracker.locX;
      this.q = this.tracker.locY;
      this.r = this.tracker.locZ;
      this.s = true;
      this.n = true;
      this.scanPlayers(list);
    }

    if (this.v != this.tracker.vehicle) {
      this.v = this.tracker.vehicle;
      this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
    }

    if (this.tracker.vehicle == null) {
      ++this.u;
      if (this.m++ % this.c == 0 || this.tracker.al) {
        int i = this.tracker.am.a(this.tracker.locX);
        int j = MathHelper.floor(this.tracker.locY * 32.0D);
        int k = this.tracker.am.a(this.tracker.locZ);
        int l = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
        int i1 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
        int j1 = i - this.xLoc;
        int k1 = j - this.yLoc;
        int l1 = k - this.zLoc;
        Object object = null;
        boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4;
        boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4;

        if (j1 >= -128
            && j1 < 128
            && k1 >= -128
            && k1 < 128
            && l1 >= -128
            && l1 < 128
            && this.u <= 400) {
          if (flag && flag1) {
            object =
                new Packet33RelEntityMoveLook(
                    this.tracker.id, (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1);
          } else if (flag) {
            object = new Packet31RelEntityMove(this.tracker.id, (byte) j1, (byte) k1, (byte) l1);
          } else if (flag1) {
            object = new Packet32EntityLook(this.tracker.id, (byte) l, (byte) i1);
          }
        } else {
          this.u = 0;
          object = new Packet34EntityTeleport(this.tracker.id, i, j, k, (byte) l, (byte) i1);
        }

        if (this.isMoving) {
          double d0 = this.tracker.motX - this.j;
          double d1 = this.tracker.motY - this.k;
          double d2 = this.tracker.motZ - this.l;
          double d3 = 0.02D;
          double d4 = d0 * d0 + d1 * d1 + d2 * d2;

          if (d4 > d3 * d3
              || d4 > 0.0D
                  && this.tracker.motX == 0.0D
                  && this.tracker.motY == 0.0D
                  && this.tracker.motZ == 0.0D) {
            this.j = this.tracker.motX;
            this.k = this.tracker.motY;
            this.l = this.tracker.motZ;
            this.broadcast(new Packet28EntityVelocity(this.tracker.id, this.j, this.k, this.l));
          }
        }

        if (object != null) {
          this.broadcast((Packet) object);
        }

        DataWatcher datawatcher = this.tracker.getDataWatcher();

        if (datawatcher.a()) {
          this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher));
        }

        int i2 = MathHelper.d(this.tracker.am() * 256.0F / 360.0F);

        if (Math.abs(i2 - this.i) >= 4) {
          this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i2));
          this.i = i2;
        }

        if (flag) {
          this.xLoc = i;
          this.yLoc = j;
          this.zLoc = k;
        }

        if (flag1) {
          this.yRot = l;
          this.xRot = i1;
        }
      }

      this.tracker.al = false;
    }

    if (this.tracker.velocityChanged) {
      this.broadcastIncludingSelf(new Packet28EntityVelocity(this.tracker));
      this.tracker.velocityChanged = false;
    }
  }