public void WriteChat(byte index, Chat value) { _writer.WriteUInt8(index); _writer.WriteUInt8(4); var data = JsonSerializer.SerializeToUtf8Bytes(value); _writer.WriteVarInt(data.Length); _writer.WriteBytes(data); }
public readonly void Write(IPacketWriter writer) { var data = JsonSerializer.SerializeToUtf8Bytes(Message, _jsonSerializerOptions); writer.WriteVarInt(data.Length); writer.WriteBytes(data); }
public static void WriteSecondaryStatsToLocal(this IPacketWriter writer, ISecondaryStats secondary) { var stats = secondary.ToDictionary(); var now = DateTime.UtcNow; writer.WriteSecondaryStatsFlag(stats); SecondaryStatsOrder.WriteOrderLocal.ForEach(t => { if (!secondary.HasStat(t)) { return; } var stat = stats[t]; var remaining = stat.DateExpire.HasValue ? (stat.DateExpire.Value - now).TotalMilliseconds : int.MaxValue; writer.WriteShort((short)stat.Value); writer.WriteInt(stat.Reason); writer.WriteInt((int)remaining); }); writer.WriteByte(0); // nDefenseAtt writer.WriteByte(0); // nDefenseState if ( secondary.HasStat(SecondaryStatType.SwallowAttackDamage) && secondary.HasStat(SecondaryStatType.SwallowDefence) && secondary.HasStat(SecondaryStatType.SwallowCritical) && secondary.HasStat(SecondaryStatType.SwallowMaxMP) && secondary.HasStat(SecondaryStatType.SwallowEvasion) ) { writer.WriteByte(0); } if (secondary.HasStat(SecondaryStatType.Dice)) { writer.WriteBytes(new byte[22]); } if (secondary.HasStat(SecondaryStatType.BlessingArmor)) { writer.WriteInt(0); } // TODO: TWOSTATE }
private void WriteSections(ReadOnlySpan <byte> light, int writeMask, IPacketWriter writer) { for (int section = -1; section < 17; section++) { if (((writeMask >> (section + 1)) & 0b1) == 0) { continue; } const int planeSize = Chunk.Width * Chunk.Depth; var data = light.Slice((section * 16 * planeSize) / 2, (16 * planeSize) / 2); Debug.Assert(data.Length == 2048); writer.WriteVarInt(2048); writer.WriteBytes(data); } }
public void Write(IPacketWriter writer) { writer.WriteString(Identifier); writer.WriteBytes(Data.Span); }