0.0
No commit activity in last 3 years
No release in over 3 years
minecraft protocol packet encode/decode utility.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

Takumi::Packet

minecraft protocol packet encode/decode utility.

Details: Protocol - MinecraftCoalition

Installation

Add this line to your application's Gemfile:

gem 'takumi-packet'

And then execute:

$ bundle

Or install it yourself as:

$ gem install takumi-packet

Usage

Gems use takumi-packet

Define packet

require 'ostruct'
require 'takumi/packet'

class Handshake < OpenStruct
  include ::Takumi::Packet::Dsl

  field :packet_id,      :varint
  field :version,        :varint
  field :server_address, :string
  field :port,           :ushort
  field :next_state,     :varint
end

Encode packet

p Handshake.new({
  packet_id:      0,
  version:        4,
  server_address: 'localhost',
  port:           25565,
  next_state:     1
}).to_s

# => "\x0F\x00\x04\tlocalhostc\xDD\x01"

Decode packet

packet = "\x0F\x00\x04\tlocalhostc\xDD\x01"

p Handshake.decode(packet)
# => #<Handshake packet_id=0, version=4, server_address="localhost", port=[25565], next_state=1>

Contributing

  1. Fork it ( https://github.com/blockgiven/takumi-packet/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request