Code example for DataOutput

Methods: writeByte, writeShort

0
        this.ping = datainput.readShort();
    } 
 
    public void writePacketData(DataOutput dataoutput)
    { 
        writeString(this.playerName, dataoutput);
        dataoutput.writeByte(this.isConnected ? 1 : 0);
        dataoutput.writeShort(this.ping);
    } 
 
    public void processPacket(NetHandler connection)
    { 
        connection.handlePlayerInfo(this);
    } 
 
    public int getPacketSize() 
    { 
        return this.playerName.length() + 2 + 1 + 2;
    } 
}