@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);
 }
Ejemplo n.º 2
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.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));
   }
 }
  @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);
  }
Ejemplo n.º 5
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.º 6
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);
  }