@Override
 public void write(NetOutput out) throws IOException {
   out.writeString(this.serverId);
   byte encoded[] = this.publicKey.getEncoded();
   out.writeVarInt(encoded.length);
   out.writeBytes(encoded);
   out.writeVarInt(this.verifyToken.length);
   out.writeBytes(this.verifyToken);
 }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeString(this.name);
   out.writeByte(MagicValues.value(Integer.class, this.action));
   if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
     out.writeString(this.displayName);
     out.writeString(MagicValues.value(String.class, this.type));
   }
 }
Ejemplo n.º 3
0
 public static void writeItem(NetOutput out, ItemStack item) throws IOException {
   if (item == null) {
     out.writeShort(-1);
   } else {
     out.writeShort(item.getId());
     out.writeByte(item.getAmount());
     out.writeShort(item.getData());
     writeNBT(out, item.getNBT());
   }
 }
Ejemplo n.º 4
0
  public static void writePosition(NetOutput out, Position pos) throws IOException {
    long x = pos.getX() & POSITION_WRITE_SHIFT;
    long y = pos.getY() & POSITION_Y_SHIFT;
    long z = pos.getZ() & POSITION_WRITE_SHIFT;

    out.writeLong(x << POSITION_X_SIZE | y << POSITION_Y_SIZE | z);
  }
Ejemplo n.º 5
0
 public static void writeNBT(NetOutput out, CompoundTag tag) throws IOException {
   if (tag == null) {
     out.writeByte(0);
   } else {
     NBTIO.writeTag(new DataOutputStream(new NetOutputStream(out)), tag);
   }
 }
  @Override
  public void write(NetOutput out) throws IOException {
    out.writeVarInt(this.entityId);
    out.writeByte(MagicValues.value(Integer.class, this.effect));
    out.writeByte(this.amplifier);
    out.writeVarInt(this.duration);

    int flags = 0;
    if (this.ambient) {
      flags |= 0x1;
    }

    if (this.showParticles) {
      flags |= 0x2;
    }

    out.writeByte(flags);
  }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeVarInt(this.entityId);
   out.writeDouble(this.x);
   out.writeDouble(this.y);
   out.writeDouble(this.z);
   out.writeByte((byte) (this.yaw * 256 / 360));
   out.writeByte((byte) (this.pitch * 256 / 360));
   out.writeBoolean(this.onGround);
 }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeInt(this.entityId);
   out.writeInt(this.attachedToId);
 }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeString(this.channel);
   out.writeBytes(this.data);
 }
Ejemplo n.º 10
0
  public static void writeEntityMetadata(NetOutput out, EntityMetadata[] metadata)
      throws IOException {
    for (EntityMetadata meta : metadata) {
      int id = MagicValues.value(Integer.class, meta.getType()) << 5 | meta.getId() & 0x1F;
      out.writeByte(id);
      switch (meta.getType()) {
        case BYTE:
          out.writeByte((Byte) meta.getValue());
          break;
        case SHORT:
          out.writeShort((Short) meta.getValue());
          break;
        case INT:
          out.writeInt((Integer) meta.getValue());
          break;
        case FLOAT:
          out.writeFloat((Float) meta.getValue());
          break;
        case STRING:
          out.writeString((String) meta.getValue());
          break;
        case ITEM:
          writeItem(out, (ItemStack) meta.getValue());
          break;
        case POSITION:
          Position pos = (Position) meta.getValue();
          out.writeInt(pos.getX());
          out.writeInt(pos.getY());
          out.writeInt(pos.getZ());
          break;
        case ROTATION:
          Rotation rot = (Rotation) meta.getValue();
          out.writeFloat(rot.getPitch());
          out.writeFloat(rot.getYaw());
          out.writeFloat(rot.getRoll());
          break;
        default:
          throw new IOException("Unmapped metadata type: " + meta.getType());
      }
    }

    out.writeByte(127);
  }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeVarInt(this.entityId);
   out.writeVarInt(MagicValues.value(Integer.class, this.slot));
   NetUtil.writeItem(out, this.item);
 }
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeFloat(this.health);
   out.writeVarInt(this.food);
   out.writeFloat(this.saturation);
 }
Ejemplo n.º 13
0
 @Override
 public void write(NetOutput out) throws IOException {
   out.writeLong(this.time);
 }