@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.writeString(this.serverId); byte encoded[] = this.publicKey.getEncoded(); out.writeVarInt(encoded.length); out.writeBytes(encoded); out.writeVarInt(this.verifyToken.length); out.writeBytes(this.verifyToken); }
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.writeString(this.channel); out.writeBytes(this.data); }