public virtual void WriteVarShort(int value) { WriteBytes(VarShort.GetBytes(value)); }
public override byte[] ToBytes(int compress = -1) { byte[] channel = Encoding.UTF8.GetBytes(Channel); byte[] PacketData; //14w31a: The length prefix on the payload of Plugin Message has been removed (Both ways) if (_protocolVersion <= ProtocolVersionNumbers.V14w31a) { if (HasForge) { PacketData = ProtocolHandler.ConcatBytes(VarInt.GetBytes(channel.Length), channel, VarShort.GetBytes(Data.Count), Data.ToArray()); } else { PacketData = ProtocolHandler.ConcatBytes(VarInt.GetBytes(channel.Length), channel, ProtocolHandler.GetBytes((short)Data.Count), Data.ToArray()); } } else { PacketData = ProtocolHandler.ConcatBytes(VarInt.GetBytes(channel.Length), channel, Data.ToArray()); } int DataLength = PacketData.Length; PacketData = ProtocolHandler.ConcatBytes(VarInt.GetBytes(ID), PacketData); if (compress > 0) { if (DataLength >= compress) { PacketData = ProtocolHandler.ConcatBytes(VarInt.GetBytes(PacketData.Length), ZlibUtils.Compress(PacketData)); } else { PacketData = ProtocolHandler.ConcatBytes(new byte[] { 0 }, PacketData); } } return(ProtocolHandler.ConcatBytes(VarInt.GetBytes(PacketData.Length), PacketData)); }