I need to create a packet and send it to a Minecraft server. The packet needs to packed in a specific way. I managed this in python but ruby seems to be giving me the slip.
Here is the Python code that packs it:
def short(data):
return pack('>h',data)
def shortchar(data):
return pack('>H',ord(data))
def string16(data):
chars = ''.join([shortchar(i) for i in data])
return short(len(data))+chars
packetbytes = '\x02\x33' + string16(name) + string16(host) + '\x00\x00\x63\xdd'
How would I do this is Ruby?
Try this: