@Override
 public void read(NetInput in) throws IOException {
   this.entityId = in.readVarInt();
   this.x = in.readDouble();
   this.y = in.readDouble();
   this.z = in.readDouble();
   this.yaw = in.readByte() * 360 / 256f;
   this.pitch = in.readByte() * 360 / 256f;
   this.onGround = in.readBoolean();
 }
  @Override
  public void read(NetInput in) throws IOException {
    this.entityId = in.readVarInt();
    this.effect = MagicValues.key(Effect.class, in.readByte());
    this.amplifier = in.readByte();
    this.duration = in.readVarInt();

    int flags = in.readByte();
    this.ambient = (flags & 0x1) == 0x1;
    this.showParticles = (flags & 0x2) == 0x2;
  }
Exemplo n.º 3
0
 public static ItemStack readItem(NetInput in) throws IOException {
   short item = in.readShort();
   if (item < 0) {
     return null;
   } else {
     return new ItemStack(item, in.readByte(), in.readShort(), readNBT(in));
   }
 }
Exemplo n.º 4
0
 public static CompoundTag readNBT(NetInput in) throws IOException {
   byte b = in.readByte();
   if (b == 0) {
     return null;
   } else {
     return (CompoundTag) NBTIO.readTag(new DataInputStream(new NetInputStream(in, b)));
   }
 }
 @Override
 public void read(NetInput in) throws IOException {
   this.name = in.readString();
   this.action = MagicValues.key(ObjectiveAction.class, in.readByte());
   if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) {
     this.displayName = in.readString();
     this.type = MagicValues.key(ScoreType.class, in.readString());
   }
 }
Exemplo n.º 6
0
  public static EntityMetadata[] readEntityMetadata(NetInput in) throws IOException {
    List<EntityMetadata> ret = new ArrayList<EntityMetadata>();
    byte b;
    while ((b = in.readByte()) != 127) {
      int typeId = (b & 0xE0) >> 5;
      int id = b & 0x1F;
      MetadataType type = MagicValues.key(MetadataType.class, typeId);
      Object value;
      switch (type) {
        case BYTE:
          value = in.readByte();
          break;
        case SHORT:
          value = in.readShort();
          break;
        case INT:
          value = in.readInt();
          break;
        case FLOAT:
          value = in.readFloat();
          break;
        case STRING:
          value = in.readString();
          break;
        case ITEM:
          value = readItem(in);
          break;
        case POSITION:
          value = new Position(in.readInt(), in.readInt(), in.readInt());
          break;
        case ROTATION:
          value = new Rotation(in.readFloat(), in.readFloat(), in.readFloat());
          break;
        default:
          throw new IOException("Unknown metadata type id: " + typeId);
      }

      ret.add(new EntityMetadata(id, type, value));
    }

    return ret.toArray(new EntityMetadata[ret.size()]);
  }