monorepo fixes

This commit is contained in:
adman
2025-12-15 22:46:34 +01:00
parent 6108534a12
commit c58dbbe5b0
83 changed files with 2273 additions and 2042 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
package bot
package api
import (
"bytes"
+19 -19
View File
@@ -7,8 +7,8 @@ import (
"io"
"net"
"github.com/admin-else/queser"
"github.com/admin-else/queser/generated"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/strom/proto_generated"
)
var BadPacketTypeError = errors.New("bad packet type")
@@ -27,23 +27,23 @@ const (
Client
)
func (a Actor) SendDirection() queser.Direction {
func (a Actor) SendDirection() proto_base.Direction {
switch a {
case Server:
return queser.ToClient
return proto_base.ToClient
case Client:
return queser.ToServer
return proto_base.ToServer
default:
panic("invalid actor")
}
}
func (a Actor) ReceiveDirection() queser.Direction {
func (a Actor) ReceiveDirection() proto_base.Direction {
switch a {
case Server:
return queser.ToServer
return proto_base.ToServer
case Client:
return queser.ToClient
return proto_base.ToClient
default:
panic("invalid actor")
}
@@ -54,7 +54,7 @@ type Conn struct {
R io.Reader
W io.Writer
CompressionThreshold int32
State queser.State
State proto_base.State
Actor Actor
Version string
}
@@ -65,13 +65,13 @@ func (c *Conn) Send(packet any) (err error) {
case UnCodablePacket:
rawPacketBytes = packet.Data
default:
packetIdentifier := generated.TypeToPacketIdentifier(c.Version, c.Actor.SendDirection(), c.State, packet)
packetIdentifier := proto_generated.TypeToPacketIdentifier(c.Version, c.Actor.SendDirection(), c.State, packet)
if packetIdentifier == "" {
err = BadPacketTypeError
return
}
rawPacketBuffer := bytes.NewBuffer(nil)
err = generated.EncodePacket(c.Version, c.Actor.SendDirection(), c.State, packetIdentifier, packet, rawPacketBuffer)
err = proto_generated.EncodePacket(c.Version, c.Actor.SendDirection(), c.State, packetIdentifier, packet, rawPacketBuffer)
if err != nil {
return
}
@@ -81,7 +81,7 @@ func (c *Conn) Send(packet any) (err error) {
if c.CompressionThreshold > 0 {
packetBuffer := bytes.NewBuffer(nil)
if int32(len(packetBytes)) >= c.CompressionThreshold {
err = queser.VarInt(len(packetBytes)).Encode(packetBuffer)
err = proto_base.VarInt(len(packetBytes)).Encode(packetBuffer)
if err != nil {
return
}
@@ -90,7 +90,7 @@ func (c *Conn) Send(packet any) (err error) {
return
}
} else {
err = queser.VarInt(0).Encode(packetBuffer)
err = proto_base.VarInt(0).Encode(packetBuffer)
if err != nil {
return
}
@@ -103,7 +103,7 @@ func (c *Conn) Send(packet any) (err error) {
} else {
packetBytes = rawPacketBytes
}
err = queser.VarInt(len(packetBytes)).Encode(c.W)
err = proto_base.VarInt(len(packetBytes)).Encode(c.W)
if err != nil {
return
}
@@ -112,7 +112,7 @@ func (c *Conn) Send(packet any) (err error) {
}
func (c *Conn) Receive() (packet any, err error) {
var rawPacketLen queser.VarInt
var rawPacketLen proto_base.VarInt
rawPacketLen, err = rawPacketLen.Decode(c.R)
if err != nil {
return
@@ -124,7 +124,7 @@ func (c *Conn) Receive() (packet any, err error) {
rawPacketBuffer := bytes.NewBuffer(rawPacketBytes)
var packetBytes []byte
if c.CompressionThreshold > 0 {
var packetLen queser.VarInt
var packetLen proto_base.VarInt
packetLen, err = packetLen.Decode(rawPacketBuffer)
if err != nil {
return
@@ -147,7 +147,7 @@ func (c *Conn) Receive() (packet any, err error) {
packetBytes = rawPacketBytes
}
packetBuff := bytes.NewBuffer(packetBytes)
packet, err = generated.DecodePacket(c.Version, c.Actor.ReceiveDirection(), c.State, packetBuff)
packet, err = proto_generated.DecodePacket(c.Version, c.Actor.ReceiveDirection(), c.State, packetBuff)
if err != nil {
packet = UnCodablePacket{Err: err, Data: packetBytes, Partial: packet}
err = nil
@@ -158,7 +158,7 @@ func (c *Conn) Receive() (packet any, err error) {
func Connect(addr string) (ret *Conn, err error) {
ret = &Conn{}
ret.Version = "1.21.8"
ret.State = queser.Handshaking
ret.State = proto_base.Handshaking
ret.CompressionThreshold = -1
ret.Actor = Client
ret.Conn, err = net.Dial("tcp", addr)
@@ -173,7 +173,7 @@ func Connect(addr string) (ret *Conn, err error) {
func Servee(c net.Conn) (ret *Conn) {
ret = &Conn{}
ret.Version = "1.21.8"
ret.State = queser.Handshaking
ret.State = proto_base.Handshaking
ret.CompressionThreshold = -1
ret.Actor = Server
ret.Conn = c
@@ -4,14 +4,13 @@ import (
"errors"
"fmt"
"github.com/admin-else/strom"
"github.com/admin-else/queser"
"github.com/admin-else/queser/generated/v1_21_8"
"github.com/admin-else/strom/bot"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/strom/proto_generated/v1_21_8"
)
type ConfigIgnorer struct {
*strom.Conn
*bot.Conn
}
func (c *ConfigIgnorer) Default(event any) (err error) {
@@ -23,13 +22,13 @@ func (c *ConfigIgnorer) OnKnownPacks(packet v1_21_8.PacketCommonSelectKnownPacks
return c.Send(packet)
}
func (c *ConfigIgnorer) OnFinish(packet v1_21_8.ConfigurationToClientPacketFinishConfiguration) (err error) {
func (c *ConfigIgnorer) OnFinish(_ v1_21_8.ConfigurationToClientPacketFinishConfiguration) (err error) {
err = c.Send(v1_21_8.ConfigurationToServerPacketFinishConfiguration{})
if err != nil {
return
}
c.State = queser.Play
err = strom.HandlerDone
c.State = proto_base.Play
err = bot.HandlerDone
return
}
@@ -43,7 +42,7 @@ func (c *ConfigIgnorer) OnKeepAlive(packet v1_21_8.ConfigurationToClientPacketKe
return
}
func IgnoreConfig(c *strom.Conn) (err error) {
func IgnoreConfig(c *bot.Conn) (err error) {
err = c.Start(&ConfigIgnorer{c})
if err != nil {
err = errors.Join(err, errors.New("failed to ignore config"))
+19 -53
View File
@@ -5,25 +5,24 @@ import (
"crypto/cipher"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/hex"
"errors"
"fmt"
"net"
"strconv"
"strings"
"github.com/admin-else/strom"
"github.com/admin-else/strom/api"
"github.com/admin-else/strom/bot"
"github.com/admin-else/strom/crypto"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/queser"
"github.com/admin-else/queser/data"
"github.com/admin-else/queser/generated/v1_21_8"
"github.com/admin-else/strom/data"
"github.com/admin-else/strom/proto_generated/v1_21_8"
)
type LoginClient struct {
*strom.Conn
Account strom.Account
*bot.Conn
Account api.Account
GivenAccount v1_21_8.LoginToClientPacketSuccess
}
@@ -33,11 +32,11 @@ func (s *LoginClient) Default(event any) (err error) {
return
}
func (s *LoginClient) OnCycle(_ strom.OnLoopCycle) (err error) {
func (s *LoginClient) OnCycle(_ bot.OnLoopCycle) (err error) {
return
}
func (s *LoginClient) OnStart(_ strom.OnStart) (err error) {
func (s *LoginClient) OnStart(_ bot.OnStart) (err error) {
host, portStr, err := net.SplitHostPort(s.RemoteAddr().String())
if err != nil {
return
@@ -51,15 +50,15 @@ func (s *LoginClient) OnStart(_ strom.OnStart) (err error) {
return
}
err = s.Send(v1_21_8.HandshakingToServerPacketSetProtocol{
ProtocolVersion: queser.VarInt(versionData.Version),
ProtocolVersion: proto_base.VarInt(versionData.Version),
ServerHost: host,
ServerPort: uint16(port),
NextState: queser.VarInt(queser.Login),
NextState: proto_base.VarInt(proto_base.Login),
})
if err != nil {
return
}
s.State = queser.Login
s.State = proto_base.Login
err = s.Send(v1_21_8.LoginToServerPacketLoginStart{Username: s.Account.Name, PlayerUUID: s.Account.Uuid})
return
}
@@ -69,39 +68,6 @@ func (s *LoginClient) OnCompress(compress v1_21_8.LoginToClientPacketCompress) (
return
}
func twosComplement(p []byte) []byte {
carry := true
for i := len(p) - 1; i >= 0; i-- {
p[i] = byte(^p[i])
if carry {
carry = p[i] == 0xff
p[i]++
}
}
return p
}
// AuthDigest stolen from https://gist.github.com/toqueteos/5372776
func AuthDigest(elems ...[]byte) string {
h := sha1.New()
for _, elem := range elems {
h.Write(elem)
}
hash := h.Sum(nil)
negative := (hash[0] & 0x80) == 0x80
if negative {
hash = twosComplement(hash)
}
res := strings.TrimLeft(hex.EncodeToString(hash), "0")
if negative {
res = "-" + res
}
return res
}
func (s *LoginClient) OnEncrypt(packet v1_21_8.LoginToClientPacketEncryptionBegin) (err error) {
sharedSecret := make([]byte, 16)
_, _ = rand.Read(sharedSecret) //never fails
@@ -111,7 +77,7 @@ func (s *LoginClient) OnEncrypt(packet v1_21_8.LoginToClientPacketEncryptionBegi
err = fmt.Errorf("the account has no token so we cant join online servers")
return
}
serverId := AuthDigest([]byte(packet.ServerId), sharedSecret, packet.PublicKey)
serverId := crypto.AuthDigest([]byte(packet.ServerId), sharedSecret, packet.PublicKey)
err = s.Account.JoinServer(serverId)
if err != nil {
return
@@ -147,11 +113,11 @@ func (s *LoginClient) OnEncrypt(packet v1_21_8.LoginToClientPacketEncryptionBegi
return
}
s.R = cipher.StreamReader{
S: strom.NewCFB8Decrypt(b, sharedSecret),
S: crypto.NewCFB8Decrypt(b, sharedSecret),
R: s.Conn,
}
s.W = cipher.StreamWriter{
S: strom.NewCFB8Encrypt(b, sharedSecret),
S: crypto.NewCFB8Encrypt(b, sharedSecret),
W: s.Conn,
}
return
@@ -164,12 +130,12 @@ func (s *LoginClient) OnSuccess(success v1_21_8.LoginToClientPacketSuccess) (err
if err != nil {
return
}
s.State = queser.Configuration
err = strom.HandlerDone
s.State = proto_base.Configuration
err = bot.HandlerDone
return
}
func Login(c *strom.Conn, account strom.Account) (err error) {
func Login(c *bot.Conn, account api.Account) (err error) {
err = c.Start(&LoginClient{
Conn: c,
Account: account,
+10 -10
View File
@@ -5,15 +5,15 @@ import (
"strconv"
"strings"
"github.com/admin-else/strom"
"github.com/admin-else/strom/bot"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/queser"
"github.com/admin-else/queser/data"
"github.com/admin-else/queser/generated/v1_21_8"
"github.com/admin-else/strom/data"
"github.com/admin-else/strom/proto_generated/v1_21_8"
)
type StatusClient struct {
*strom.Conn
*bot.Conn
Status string
}
@@ -22,7 +22,7 @@ func (s *StatusClient) Default(event any) (err error) {
return
}
func (s *StatusClient) OnStart(_ strom.OnStart) (err error) {
func (s *StatusClient) OnStart(_ bot.OnStart) (err error) {
parts := strings.Split(s.RemoteAddr().String(), ":")
versionData, err := data.LookUpProtocolVersionByName(s.Version)
if err != nil {
@@ -33,21 +33,21 @@ func (s *StatusClient) OnStart(_ strom.OnStart) (err error) {
return
}
err = s.Send(v1_21_8.HandshakingToServerPacketSetProtocol{
ProtocolVersion: queser.VarInt(versionData.Version),
ProtocolVersion: proto_base.VarInt(versionData.Version),
ServerHost: parts[0],
ServerPort: uint16(port),
NextState: queser.VarInt(queser.Status),
NextState: proto_base.VarInt(proto_base.Status),
})
if err != nil {
return
}
s.State = queser.Status
s.State = proto_base.Status
err = s.Send(v1_21_8.StatusToServerPacketPingStart{})
return
}
func (s *StatusClient) OnStatus(p v1_21_8.StatusToClientPacketServerInfo) (err error) {
s.Status = p.Response
err = strom.HandlerDone
err = bot.HandlerDone
return
}
+4 -3
View File
@@ -5,17 +5,18 @@ import (
"crypto/x509"
"encoding/pem"
"github.com/admin-else/strom/api"
"github.com/google/uuid"
)
type SecureChatSession struct {
Account *Account
PlayerKeys PlayerKeys
Account *api.Account
PlayerKeys api.PlayerKeys
Private *rsa.PrivateKey
SessionId uuid.UUID
}
func NewSecureChat(a *Account) (s *SecureChatSession, err error) {
func NewSecureChat(a *api.Account) (s *SecureChatSession, err error) {
s = &SecureChatSession{Account: a}
s.PlayerKeys, err = a.FetchKeys()
+40
View File
@@ -0,0 +1,40 @@
package crypto
import (
"crypto/sha1"
"encoding/hex"
"strings"
)
func twosComplement(p []byte) []byte {
carry := true
for i := len(p) - 1; i >= 0; i-- {
p[i] = byte(^p[i])
if carry {
carry = p[i] == 0xff
p[i]++
}
}
return p
}
// AuthDigest stolen from https://gist.github.com/toqueteos/5372776
func AuthDigest(elems ...[]byte) string {
h := sha1.New()
for _, elem := range elems {
h.Write(elem)
}
hash := h.Sum(nil)
negative := (hash[0] & 0x80) == 0x80
if negative {
hash = twosComplement(hash)
}
res := strings.TrimLeft(hex.EncodeToString(hash), "0")
if negative {
res = "-" + res
}
return res
}
+1 -1
View File
@@ -1,4 +1,4 @@
package bot
package crypto
// https://github.com/Tnze/go-mc/blob/master/net/CFB8/cfb8.go
// Package CFB8 implements CFB8 block cipher mode of operation used by Minecraft protocol.
+1 -1
View File
@@ -3,7 +3,7 @@ package data_test
import (
"testing"
"github.com/admin-else/queser/data"
"github.com/admin-else/strom/data"
)
func TestLookupBiomeById(t *testing.T) {
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"github.com/admin-else/queser/data"
"github.com/admin-else/strom/data"
)
func TestLookupBlockByStateId(t *testing.T) {
@@ -36,7 +36,7 @@ async function handle (ourPR, genPullNo, version, artifactURL, shouldPull) {
if (ourPR.body) {
await github.updateIssue(ourPR.number, {
body: ourPR.body.replace('<!--minecraft-data-generator-placeholder-->', `- https://github.com/PrismarineJS/minecraft-data-generator/pull/${genPullNo}`)
body: ourPR.body.replace('<!--minecraft-data-proto_generator-placeholder-->', `- https://github.com/PrismarineJS/minecraft-data-generator/pull/${genPullNo}`)
})
}
@@ -92,7 +92,7 @@ async function main (versions, genPullNo, artifactUrl, createPR) {
console.log('PR', details)
await handle(details, genPullNo, version, artifactUrl, true)
} else if (createPR) {
const pr = await createInitialPR('pc', '(This issue was created for a minecraft-data-generator PR)', {
const pr = await createInitialPR('pc', '(This issue was created for a minecraft-data-proto_generator PR)', {
version,
protocolVersion: null
})
+2 -2
View File
@@ -166,10 +166,10 @@ async function openIssueAndDispatch (title, versionJson, latestVersionData, late
protocolVersion: versionJson.protocol_version
})
console.log('Created PR', pr)
// Ask minecraft-data-generator to handle new update
// Ask minecraft-data-proto_generator to handle new update
const dispatchPayload = {
owner: 'PrismarineJS',
repo: 'minecraft-data-generator',
repo: 'minecraft-data-proto_generator',
workflow: 'handle-mcdata-update.yml',
branch: 'main',
inputs: {
@@ -1,16 +1,16 @@
name: handle-mcpc-generator
name: handle-mcpc-proto_generator
on:
workflow_dispatch:
inputs:
versions:
description: 'JSON stringified list of known versions in generator (last is expected to be latest)'
description: 'JSON stringified list of known versions in proto_generator (last is expected to be latest)'
required: true
default: '["1.21.6"]'
mergedArtifactURL:
description: 'Merged artifact download URL'
required: true
prNumber:
description: 'Relevant minecraft-data-generator PR #'
description: 'Relevant minecraft-data-proto_generator PR #'
required: false
createPr:
description: 'Whether to create a new PR if none exists'
@@ -234,7 +234,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -234,7 +234,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -236,7 +236,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -236,7 +236,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -238,7 +238,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -238,7 +238,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -238,7 +238,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -238,7 +238,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -238,7 +238,7 @@ packet_start_game:
# Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2,
# with 0 being the overworld, 1 being the nether and 2 being the end.
dimension: zigzag32
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -241,7 +241,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -241,7 +241,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -245,7 +245,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -245,7 +245,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -245,7 +245,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -246,7 +246,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -251,7 +251,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -254,7 +254,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -254,7 +254,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -254,7 +254,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -257,7 +257,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -258,7 +258,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -259,7 +259,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -259,7 +259,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -263,7 +263,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -258,7 +258,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -257,7 +257,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -140,11 +140,11 @@ packet_resource_packs_info:
has_scripts: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -265,7 +265,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -141,11 +141,11 @@ packet_resource_packs_info:
has_scripts: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -266,7 +266,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -141,11 +141,11 @@ packet_resource_packs_info:
has_scripts: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -266,7 +266,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -141,11 +141,11 @@ packet_resource_packs_info:
has_scripts: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -266,7 +266,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
@@ -25,7 +25,7 @@ nbtLoop: native
enum_size_based_on_values_len: native # Packet-specific custom logic
MapInfo: native
# load the packet map file (auto-generated)
# load the packet map file (auto-proto_generated)
!import: packet_map.yml
!StartDocs: Packets
@@ -149,11 +149,11 @@ packet_resource_packs_info:
disable_vibrant_visuals: bool
world_template:
# WorldTemplateUUID is teh UUID of the template that has been used to generate the world. Templates can
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not generated
# be downloaded from the marketplace or installed via '.mctemplate' files. If the world was not proto_generated
# from a template, this field is empty.
uuid: uuid
# WorldTemplateVersion is the version of the world template that has been used to generate the world. If
# the world was not generated from a template, this field is empty.
# the world was not proto_generated from a template, this field is empty.
version: string
# A list of resource packs that the client needs to download before joining the server.
# The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet.
@@ -274,7 +274,7 @@ packet_start_game:
0: overworld
1: nether
2: end
# Generator is the generator used for the world. It is a value from 0-4, with 0 being old
# Generator is the proto_generator used for the world. It is a value from 0-4, with 0 being old
# limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and
# 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you
# send beyond the world limit.
+1 -1
View File
@@ -555,7 +555,7 @@
# This represents a single component within an UntrustedSlot.
# The 'data' field is a varint-prefixed byte array that contains the actual component data.
# The code generator will need to know that it should read a varint for length, then the bytes.
# The code proto_generator will need to know that it should read a varint for length, then the bytes.
UntrustedSlotComponent:
type: SlotComponentType
data: ByteArray
+1 -1
View File
@@ -558,7 +558,7 @@
# This represents a single component within an UntrustedSlot.
# The 'data' field is a varint-prefixed byte array that contains the actual component data.
# The code generator will need to know that it should read a varint for length, then the bytes.
# The code proto_generator will need to know that it should read a varint for length, then the bytes.
UntrustedSlotComponent:
type: SlotComponentType
data: ByteArray
+1 -1
View File
@@ -558,7 +558,7 @@
# This represents a single component within an UntrustedSlot.
# The 'data' field is a varint-prefixed byte array that contains the actual component data.
# The code generator will need to know that it should read a varint for length, then the bytes.
# The code proto_generator will need to know that it should read a varint for length, then the bytes.
UntrustedSlotComponent:
type: SlotComponentType
data: ByteArray
@@ -80,7 +80,7 @@ function validate (edition, ver, path) {
? JSON.stringify({ types: json }, visitor, 2)
: JSON.stringify(json, visitor, 2)
// If you crash here, no protocol.json was generated - run `npm run build`
// If you crash here, no protocol.json was proto_generated - run `npm run build`
const actual = JSON.stringify(getJSON(`../${version}/protocol.json`), null, 2)
// Make sure the protocol_expected.json file equals the protocol.json file; otherwise the JSON must be rebuilt
+1 -1
View File
@@ -3,7 +3,7 @@ package data_test
import (
"testing"
"github.com/admin-else/queser/data"
"github.com/admin-else/strom/data"
)
func TestLookUpProtocolVersion(t *testing.T) {
-37
View File
@@ -1,37 +0,0 @@
package generated
import (
"io"
"github.com/admin-else/queser"
"github.com/admin-else/queser/generated/v1_21_8"
)
func PacketIdentifierToType(v string, d queser.Direction, s queser.State, i string) (t any) {
switch v {
case "1.21.8":
t = v1_21_8.PacketIdentifierToType(d, s, i)
default:
}
return
}
func TypeToPacketIdentifier(v string, d queser.Direction, s queser.State, t any) (i string) {
switch v {
case "1.21.8":
i = v1_21_8.TypeToPacketIdentifier(d, s, t)
}
return
}
func DecodePacket(v string, d queser.Direction, s queser.State, r io.Reader) (packet any, err error) {
switch v {
case "1.21.8":
packet, err = v1_21_8.DecodePacket(d, s, r)
}
return
}
func EncodePacket(v string, d queser.Direction, s queser.State, i string, p any, w io.Writer) (err error) {
switch v {
case "1.21.8":
err = v1_21_8.EncodePacket(d, s, i, p, w)
}
return
}
+5
View File
@@ -3,3 +3,8 @@ module github.com/admin-else/strom
go 1.24
require github.com/google/uuid v1.6.0
require (
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
)
+4
View File
@@ -1,3 +1,7 @@
github.com/admin-else/queser v0.0.0-20251204142744-84a884c09415 h1:79NZpiedySnmgHDh/SebJ6qIenijozOOmiVys8P1y9Q=
github.com/admin-else/queser v0.0.0-20251204142744-84a884c09415/go.mod h1:yDPy6zf+PgSaggT3ongNpb6JSgNFt6Z8ryomGEbLNmE=
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+71
View File
@@ -0,0 +1,71 @@
package proto_base_test
import (
"bytes"
"math"
"testing"
"github.com/admin-else/strom/nbt"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/strom/proto_generated/v1_21_8"
"github.com/google/uuid"
"github.com/google/go-cmp/cmp"
)
var nanIgnorer32 = cmp.Comparer(func(x, y float32) bool {
return (math.IsNaN(float64(x)) && math.IsNaN(float64(y))) || x == y
})
var nanIgnorer64 = cmp.Comparer(func(x, y float64) bool {
return (math.IsNaN(x) && math.IsNaN(y)) || x == y
})
func TestChat(t *testing.T) {
//p := v1_21_8.PlayToServerPacketChatMessage{Message: "dfs", Timestamp: 1764153707364, Salt: -5634100397920314628, Signature: (*[256]uint8)(nil), Offset: 0, Acknowledged: [3]uint8{0x0, 0x0, 0x0}, Checksum: 0x1}
p := v1_21_8.PlayToClientPacketPlayerChat{GlobalIndex: 0, SenderUuid: uuid.UUID{0x1d, 0xc5, 0x57, 0x82, 0x3c, 0x0, 0x3e, 0xd4, 0xbf, 0x8b, 0x76, 0xd4, 0xc6, 0xd9, 0xcc, 0x47}, Index: 0, Signature: (*[256]uint8)(nil), PlainMessage: "csdf", Timestamp: 1764153823132, Salt: 0, PreviousMessages: v1_21_8.PreviousMessages{Val: []struct {
Id proto_base.VarInt
Signature interface{}
}{}}, UnsignedChatContent: (*nbt.Anon)(nil), FilterType: 0, FilterTypeMask: proto_base.Void{}, Type: v1_21_8.PlayToClientChatTypesHolder{Val: proto_base.VarInt(1)}, NetworkName: nbt.Anon{Value: map[string]interface{}{"click_event": map[string]interface{}{"action": "suggest_command", "command": "/tell Player659 "}, "hover_event": map[string]interface{}{"action": "show_entity", "id": "minecraft:player", "name": "Player659", "uuid": []int32{499472258, 1006649044, -1081379116, -958804921}}, "insertion": "Player659", "text": "Player659"}}, NetworkTargetName: (*nbt.Anon)(nil)}
b := bytes.NewBuffer(nil)
err := p.Encode(b)
if err != nil {
t.Fatal(err)
}
t.Logf("%q", b.Bytes())
}
func FuzzPlayPackets(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
t.Logf("Fuzz data %q\n", b)
p := v1_21_8.PlayToClientPacket{}
b1 := bytes.NewBuffer(b)
p, err := p.Decode(b1)
if err != nil {
t.Skipf("failed to decode %q because %v (partial %v)", b, err, p)
return
}
if b1.Len() != 0 {
t.Skipf("there are %d bytes left it should be read entirely", b1.Len())
return
}
t.Logf("decoded %#v\n", p)
b2 := bytes.NewBuffer(nil)
err = p.Encode(b2)
if err != nil {
t.Errorf("failed to encode %q because %v", b, err)
return
}
t.Logf("encoded %q\n", b2.Bytes())
p2 := v1_21_8.PlayToClientPacket{}
p2, err = p2.Decode(b2)
if err != nil {
t.Errorf("failed to decode encoded data: %v (partial %#v)", err, p2)
return
}
if !cmp.Equal(p, p2, nanIgnorer32, nanIgnorer64) {
t.Errorf("decoded and encoded decoded data are not equal: %#v", p2)
}
})
}
+144
View File
@@ -0,0 +1,144 @@
package proto_base
import (
"encoding/binary"
"errors"
"io"
)
type Direction int
const (
ToServer Direction = iota
ToClient
)
type State int
const (
Handshaking State = iota
Status
Login
Configuration
Play
)
type PacketIdentifier struct {
Direction Direction
State State
Name string
}
type (
VarInt int32
ToDo struct{}
Void struct{}
RestBuffer []byte
)
func (v Void) Encode(_ io.Writer) (err error) {
return
}
func (v Void) Decode(_ io.Reader) (ret Void, err error) {
return
}
var ToDoError = errors.New("to do")
var BadTypeError = errors.New("bad type")
func (r RestBuffer) Encode(w io.Writer) (err error) {
_, err = w.Write(r)
return
}
func (RestBuffer) Decode(r io.Reader) (ret RestBuffer, err error) {
b, err := io.ReadAll(r)
ret = b
return
}
func EncodeString(w io.Writer, s string) (err error) {
err = VarInt(len(s)).Encode(w)
if err != nil {
return
}
_, err = w.Write([]byte(s))
return
}
func DecodeString(r io.Reader) (ret string, err error) {
var l VarInt
l, err = l.Decode(r)
if err != nil {
return
}
rawString, err := io.ReadAll(io.LimitReader(r, int64(l)))
if err != nil {
return
}
if len(rawString) != int(l) {
err = errors.New("bad string length")
return
}
return string(rawString), nil
}
func (t ToDo) Encode(_ io.Writer) (err error) {
err = ToDoError
return
}
func (t ToDo) Decode(_ io.Reader) (ret ToDo, err error) {
err = ToDoError
return
}
func (v VarInt) Encode(w io.Writer) (err error) {
uv := uint32(v)
for {
b := uint8(uv & 0x7F)
uv >>= 7
if uv != 0 {
b |= 0x80
}
err := binary.Write(w, binary.BigEndian, b)
if err != nil {
return err
}
if uv == 0 {
break
}
}
return nil
}
func (v VarInt) Decode(r io.Reader) (ret VarInt, err error) {
for i := range 5 { // 32/7
var b uint8 = 0
err = binary.Read(r, binary.BigEndian, &b)
if err != nil {
return
}
ret |= VarInt(uint32(b&0x7F) << (7 * uint32(i)))
if b&0x80 == 0 {
return
}
}
err = errors.New("VarInt too long")
return
}
func ErroringIndex[K comparable, V any, M map[K]V](m M, i K) (v V, err error) {
var ok bool
v, ok = m[i]
if !ok {
err = errors.New("index not found")
}
return
}
type EncodeDecodeAble[Self any] interface {
Encode(w io.Writer) (err error)
Decode(r io.Reader) (ret Self, err error)
}
@@ -1,8 +1,8 @@
package v1_21_8
import (
"github.com/admin-else/strom/proto_base"
"io"
"github.com/admin-else/queser"
)
func HandshakingToServerPacketIdentifierToType(s string) (t any) {
@@ -582,7 +582,7 @@ func PlayToClientPacketIdentifierToType(s string) (t any) {
case "boss_bar":
t = PlayToClientPacketBossBar{}
case "bundle_delimiter":
t = queser.Void{}
t = proto_base.Void{}
case "camera":
t = PlayToClientPacketCamera{}
case "chat_suggestions":
@@ -1100,109 +1100,109 @@ func PlayToClientTypeToPacketIdentifier(t any) (s string) {
s = "world_event"
case PlayToClientPacketWorldParticles:
s = "world_particles"
case queser.Void:
case proto_base.Void:
s = "bundle_delimiter"
}
return
}
func TypeToPacketIdentifier(d queser.Direction, s queser.State, t any) (i string) {
func TypeToPacketIdentifier(d proto_base.Direction, s proto_base.State, t any) (i string) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
i = HandshakingToServerTypeToPacketIdentifier(t)
case queser.Status:
case proto_base.Status:
i = StatusToServerTypeToPacketIdentifier(t)
case queser.Login:
case proto_base.Login:
i = LoginToServerTypeToPacketIdentifier(t)
case queser.Configuration:
case proto_base.Configuration:
i = ConfigurationToServerTypeToPacketIdentifier(t)
case queser.Play:
case proto_base.Play:
i = PlayToServerTypeToPacketIdentifier(t)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
i = HandshakingToClientTypeToPacketIdentifier(t)
case queser.Status:
case proto_base.Status:
i = StatusToClientTypeToPacketIdentifier(t)
case queser.Login:
case proto_base.Login:
i = LoginToClientTypeToPacketIdentifier(t)
case queser.Configuration:
case proto_base.Configuration:
i = ConfigurationToClientTypeToPacketIdentifier(t)
case queser.Play:
case proto_base.Play:
i = PlayToClientTypeToPacketIdentifier(t)
}
}
return
}
func PacketIdentifierToType(d queser.Direction, s queser.State, i string) (t any) {
func PacketIdentifierToType(d proto_base.Direction, s proto_base.State, i string) (t any) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
t = HandshakingToServerPacketIdentifierToType(i)
case queser.Status:
case proto_base.Status:
t = StatusToServerPacketIdentifierToType(i)
case queser.Login:
case proto_base.Login:
t = LoginToServerPacketIdentifierToType(i)
case queser.Configuration:
case proto_base.Configuration:
t = ConfigurationToServerPacketIdentifierToType(i)
case queser.Play:
case proto_base.Play:
t = PlayToServerPacketIdentifierToType(i)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
t = HandshakingToClientPacketIdentifierToType(i)
case queser.Status:
case proto_base.Status:
t = StatusToClientPacketIdentifierToType(i)
case queser.Login:
case proto_base.Login:
t = LoginToClientPacketIdentifierToType(i)
case queser.Configuration:
case proto_base.Configuration:
t = ConfigurationToClientPacketIdentifierToType(i)
case queser.Play:
case proto_base.Play:
t = PlayToClientPacketIdentifierToType(i)
}
}
return
}
func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any, err error) {
func DecodePacket(d proto_base.Direction, s proto_base.State, r io.Reader) (params any, err error) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
var packet HandshakingToServerPacket
packet, err = HandshakingToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Status:
case proto_base.Status:
var packet StatusToServerPacket
packet, err = StatusToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Login:
case proto_base.Login:
var packet LoginToServerPacket
packet, err = LoginToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Configuration:
case proto_base.Configuration:
var packet ConfigurationToServerPacket
packet, err = ConfigurationToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Play:
case proto_base.Play:
var packet PlayToServerPacket
packet, err = PlayToServerPacket{}.Decode(r)
if err != nil {
@@ -1210,37 +1210,37 @@ func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any,
}
params = packet.Params
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
var packet HandshakingToClientPacket
packet, err = HandshakingToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Status:
case proto_base.Status:
var packet StatusToClientPacket
packet, err = StatusToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Login:
case proto_base.Login:
var packet LoginToClientPacket
packet, err = LoginToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Configuration:
case proto_base.Configuration:
var packet ConfigurationToClientPacket
packet, err = ConfigurationToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Play:
case proto_base.Play:
var packet PlayToClientPacket
packet, err = PlayToClientPacket{}.Decode(r)
if err != nil {
@@ -1252,32 +1252,32 @@ func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any,
return
}
func EncodePacket(d queser.Direction, s queser.State, i string, p any, w io.Writer) (err error) {
func EncodePacket(d proto_base.Direction, s proto_base.State, i string, p any, w io.Writer) (err error) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
err = HandshakingToServerPacket{i, p}.Encode(w)
case queser.Status:
case proto_base.Status:
err = StatusToServerPacket{i, p}.Encode(w)
case queser.Login:
case proto_base.Login:
err = LoginToServerPacket{i, p}.Encode(w)
case queser.Configuration:
case proto_base.Configuration:
err = ConfigurationToServerPacket{i, p}.Encode(w)
case queser.Play:
case proto_base.Play:
err = PlayToServerPacket{i, p}.Encode(w)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
err = HandshakingToClientPacket{i, p}.Encode(w)
case queser.Status:
case proto_base.Status:
err = StatusToClientPacket{i, p}.Encode(w)
case queser.Login:
case proto_base.Login:
err = LoginToClientPacket{i, p}.Encode(w)
case queser.Configuration:
case proto_base.Configuration:
err = ConfigurationToClientPacket{i, p}.Encode(w)
case queser.Play:
case proto_base.Play:
err = PlayToClientPacket{i, p}.Encode(w)
}
}
File diff suppressed because it is too large Load Diff
+37
View File
@@ -0,0 +1,37 @@
package proto_generated
import (
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/strom/proto_generated/v1_21_8"
"io"
)
func PacketIdentifierToType(v string, d proto_base.Direction, s proto_base.State, i string) (t any) {
switch v {
case "1.21.8":
t = v1_21_8.PacketIdentifierToType(d, s, i)
default:
}
return
}
func TypeToPacketIdentifier(v string, d proto_base.Direction, s proto_base.State, t any) (i string) {
switch v {
case "1.21.8":
i = v1_21_8.TypeToPacketIdentifier(d, s, t)
}
return
}
func DecodePacket(v string, d proto_base.Direction, s proto_base.State, r io.Reader) (packet any, err error) {
switch v {
case "1.21.8":
packet, err = v1_21_8.DecodePacket(d, s, r)
}
return
}
func EncodePacket(v string, d proto_base.Direction, s proto_base.State, i string, p any, w io.Writer) (err error) {
switch v {
case "1.21.8":
err = v1_21_8.EncodePacket(d, s, i, p, w)
}
return
}
@@ -1,101 +1,101 @@
func TypeToPacketIdentifier(d queser.Direction, s queser.State, t any) (i string) {
func TypeToPacketIdentifier(d proto_base.Direction, s proto_base.State, t any) (i string) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
i = HandshakingToServerTypeToPacketIdentifier(t)
case queser.Status:
case proto_base.Status:
i = StatusToServerTypeToPacketIdentifier(t)
case queser.Login:
case proto_base.Login:
i = LoginToServerTypeToPacketIdentifier(t)
case queser.Configuration:
case proto_base.Configuration:
i = ConfigurationToServerTypeToPacketIdentifier(t)
case queser.Play:
case proto_base.Play:
i = PlayToServerTypeToPacketIdentifier(t)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
i = HandshakingToClientTypeToPacketIdentifier(t)
case queser.Status:
case proto_base.Status:
i = StatusToClientTypeToPacketIdentifier(t)
case queser.Login:
case proto_base.Login:
i = LoginToClientTypeToPacketIdentifier(t)
case queser.Configuration:
case proto_base.Configuration:
i = ConfigurationToClientTypeToPacketIdentifier(t)
case queser.Play:
case proto_base.Play:
i = PlayToClientTypeToPacketIdentifier(t)
}
}
return
}
func PacketIdentifierToType(d queser.Direction, s queser.State, i string) (t any) {
func PacketIdentifierToType(d proto_base.Direction, s proto_base.State, i string) (t any) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
t = HandshakingToServerPacketIdentifierToType(i)
case queser.Status:
case proto_base.Status:
t = StatusToServerPacketIdentifierToType(i)
case queser.Login:
case proto_base.Login:
t = LoginToServerPacketIdentifierToType(i)
case queser.Configuration:
case proto_base.Configuration:
t = ConfigurationToServerPacketIdentifierToType(i)
case queser.Play:
case proto_base.Play:
t = PlayToServerPacketIdentifierToType(i)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
t = HandshakingToClientPacketIdentifierToType(i)
case queser.Status:
case proto_base.Status:
t = StatusToClientPacketIdentifierToType(i)
case queser.Login:
case proto_base.Login:
t = LoginToClientPacketIdentifierToType(i)
case queser.Configuration:
case proto_base.Configuration:
t = ConfigurationToClientPacketIdentifierToType(i)
case queser.Play:
case proto_base.Play:
t = PlayToClientPacketIdentifierToType(i)
}
}
return
}
func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any, err error) {
func DecodePacket(d proto_base.Direction, s proto_base.State, r io.Reader) (params any, err error) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
var packet HandshakingToServerPacket
packet, err = HandshakingToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Status:
case proto_base.Status:
var packet StatusToServerPacket
packet, err = StatusToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Login:
case proto_base.Login:
var packet LoginToServerPacket
packet, err = LoginToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Configuration:
case proto_base.Configuration:
var packet ConfigurationToServerPacket
packet, err = ConfigurationToServerPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Play:
case proto_base.Play:
var packet PlayToServerPacket
packet, err = PlayToServerPacket{}.Decode(r)
if err != nil {
@@ -103,37 +103,37 @@ func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any,
}
params = packet.Params
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
var packet HandshakingToClientPacket
packet, err = HandshakingToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Status:
case proto_base.Status:
var packet StatusToClientPacket
packet, err = StatusToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Login:
case proto_base.Login:
var packet LoginToClientPacket
packet, err = LoginToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Configuration:
case proto_base.Configuration:
var packet ConfigurationToClientPacket
packet, err = ConfigurationToClientPacket{}.Decode(r)
if err != nil {
return
}
params = packet.Params
case queser.Play:
case proto_base.Play:
var packet PlayToClientPacket
packet, err = PlayToClientPacket{}.Decode(r)
if err != nil {
@@ -145,32 +145,32 @@ func DecodePacket(d queser.Direction, s queser.State, r io.Reader) (params any,
return
}
func EncodePacket(d queser.Direction, s queser.State, i string, p any, w io.Writer) (err error) {
func EncodePacket(d proto_base.Direction, s proto_base.State, i string, p any, w io.Writer) (err error) {
switch d {
case queser.ToServer:
case proto_base.ToServer:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
err = HandshakingToServerPacket{i, p}.Encode(w)
case queser.Status:
case proto_base.Status:
err = StatusToServerPacket{i, p}.Encode(w)
case queser.Login:
case proto_base.Login:
err = LoginToServerPacket{i, p}.Encode(w)
case queser.Configuration:
case proto_base.Configuration:
err = ConfigurationToServerPacket{i, p}.Encode(w)
case queser.Play:
case proto_base.Play:
err = PlayToServerPacket{i, p}.Encode(w)
}
case queser.ToClient:
case proto_base.ToClient:
switch s {
case queser.Handshaking:
case proto_base.Handshaking:
err = HandshakingToClientPacket{i, p}.Encode(w)
case queser.Status:
case proto_base.Status:
err = StatusToClientPacket{i, p}.Encode(w)
case queser.Login:
case proto_base.Login:
err = LoginToClientPacket{i, p}.Encode(w)
case queser.Configuration:
case proto_base.Configuration:
err = ConfigurationToClientPacket{i, p}.Encode(w)
case queser.Play:
case proto_base.Play:
err = PlayToClientPacket{i, p}.Encode(w)
}
}
@@ -7,7 +7,7 @@ import (
_ "embed"
"github.com/admin-else/queser/data"
"github.com/admin-else/strom/data"
)
//go:embed helper_append.txt
@@ -25,7 +25,7 @@ func GenerateHelperTypes(t Types, prefix string, f *ast.File) (err error) {
if strings.HasPrefix(v2, "packet_common") {
m[k2] = CamelCase(v2)
} else if v2 == "void" {
m[k2] = "queser.Void"
m[k2] = "proto_base.Void"
} else {
m[k2] = prefix + CamelCase(v2)
}
@@ -115,7 +115,7 @@ func GenerateHelpers(version string, w io.Writer) (err error) {
return
}
f := NewFile("v" + strings.ReplaceAll(version, ".", "_"))
AppendDecl(f, Import("io", "github.com/admin-else/queser"))
AppendDecl(f, Import("io", "github.com/admin-else/strom/proto_base"))
err = GenerateHelperProtocol(protocol, f)
if err != nil {
return
@@ -10,7 +10,7 @@ import (
"slices"
"strings"
"github.com/admin-else/queser/data"
"github.com/admin-else/strom/data"
)
var ToDoError = errors.New("to do")
@@ -208,7 +208,7 @@ func (g *Generator) GenerateTypes(prefix string, types Types) error {
g.Depth = 0
e, err := g.VisitType(v)
if errors.Is(err, ToDoError) {
e = Selector("queser", "ToDo")
e = Selector("proto_base", "ToDo")
err = nil
}
if err != nil {
@@ -303,7 +303,7 @@ func Generate(version string, w io.Writer) (err error) {
g.Settings.ReplaceWithTodoNames = []string{"packet_scoreboard_score", "packet_advancements"}
g.File = NewFile("v" + strings.ReplaceAll(version, ".", "_"))
AppendDecl(g.File, Import("encoding/binary", "io", "github.com/admin-else/queser", "github.com/admin-else/queser/nbt", "github.com/google/uuid"))
AppendDecl(g.File, Import("encoding/binary", "io", "github.com/admin-else/strom/proto_base", "github.com/admin-else/strom/nbt", "github.com/google/uuid"))
g.RegisterNatives()
g.RegisterDecoderNatives()
g.RegisterEncoderNatives()
@@ -317,11 +317,11 @@ func Generate(version string, w io.Writer) (err error) {
func generateVersion(v string) (err error) {
vUnderscore := strings.ReplaceAll(v, ".", "_")
err = os.MkdirAll("generated/v"+vUnderscore, 0755)
err = os.MkdirAll("proto_generated/v"+vUnderscore, 0755)
if err != nil {
return
}
f, err := os.Create("generated/v" + vUnderscore + "/proto.go")
f, err := os.Create("proto_generated/v" + vUnderscore + "/proto.go")
if err != nil {
return
}
@@ -330,7 +330,7 @@ func generateVersion(v string) (err error) {
if err != nil {
return
}
helperF, err := os.Create("generated/v" + vUnderscore + "/helpers.go")
helperF, err := os.Create("proto_generated/v" + vUnderscore + "/helpers.go")
if err != nil {
return
}
@@ -340,15 +340,15 @@ func generateVersion(v string) (err error) {
}
func GenerateVersions(versions []string) (err error) {
err = os.RemoveAll("generated/")
err = os.RemoveAll("proto_generated/")
if err != nil {
return
}
err = os.MkdirAll("generated/", 0755)
err = os.MkdirAll("proto_generated/", 0755)
if err != nil {
return
}
f, err := os.Create("generated/version_switcher.go")
f, err := os.Create("proto_generated/version_switcher.go")
if err != nil {
return
}
@@ -75,7 +75,7 @@ func SimpleTypeDecoder(_ *Generator, varToSet ast.Expr, _ any, _ string) (s []as
func StringDecoder(_ *Generator, varToSet ast.Expr, _ any, _ string) (s []ast.Stmt, err error) {
s = Stmts(
Assign(Exprs(varToSet, Ident("err")), Exprs(Call(Selector("queser", "DecodeString"), Ident("r")))),
Assign(Exprs(varToSet, Ident("err")), Exprs(Call(Selector("proto_base", "DecodeString"), Ident("r")))),
IfErrNil(),
)
return
@@ -276,7 +276,7 @@ func SwitchDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
return
}
var ToDoStmts = Stmts(Assign121(Ident("err"), Selector("queser", "ToDoError")))
var ToDoStmts = Stmts(Assign121(Ident("err"), Selector("proto_base", "ToDoError")))
func ToDoDecoder(_ *Generator, _ ast.Expr, _ any, _ string) (s []ast.Stmt, err error) {
err = ToDoError
@@ -311,7 +311,7 @@ func MapperDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
expressions = append(expressions, KeyValueExpr(NumLitStr(k), StrLit(v)))
}
g.Decl(mName, token.VAR, CompLit(MapType(kType, Ident("string")), expressions))
s3 := Assign(Exprs(varToSet, Ident("err")), Exprs(Call(Selector("queser", "ErroringIndex"), Ident(mName), Ident(kName))))
s3 := Assign(Exprs(varToSet, Ident("err")), Exprs(Call(Selector("proto_base", "ErroringIndex"), Ident(mName), Ident(kName))))
s = append(s, s1)
s = append(s, s2...)
s = append(s, s3)
@@ -453,7 +453,7 @@ func RegistryEntryHolderDecoder(g *Generator, varToSet ast.Expr, dataRaw any, na
return
}
idName := name + "Id"
IdVar := VarStmt(idName, Selector("queser", "VarInt"))
IdVar := VarStmt(idName, Selector("proto_base", "VarInt"))
idDecodeStatements, err := g.VisitDecoder(Ident(idName), "varint", name)
if err != nil {
return
@@ -191,7 +191,7 @@ func SwitchEncoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
return
}
s1 := Define(Exprs(Ident(name), Ident("ok")), Exprs(TypeAssert(varToSet, tType)))
s2 := If(Not(Ident("ok")), NewBlockEllipsis(Assign121(Ident("err"), Selector("queser", "BadTypeError")), Return()))
s2 := If(Not(Ident("ok")), NewBlockEllipsis(Assign121(Ident("err"), Selector("proto_base", "BadTypeError")), Return()))
var caseDecodeValueStmts []ast.Stmt
caseDecodeValueStmts, err = g.VisitEncoder(Ident(name), fType, name)
if err != nil {
@@ -210,7 +210,7 @@ func SwitchEncoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
return
}
s1 := Define(Exprs(Ident("_"), Ident("ok")), Exprs(TypeAssert(varToSet, tType)))
s2 := If(Not(Ident("ok")), NewBlockEllipsis(Assign121(Ident("err"), Selector("queser", "BadTypeError")), Return()))
s2 := If(Not(Ident("ok")), NewBlockEllipsis(Assign121(Ident("err"), Selector("proto_base", "BadTypeError")), Return()))
defaultStmts := []ast.Stmt{s1, s2}
var defaultEncodingStmts []ast.Stmt
defaultEncodingStmts, err = g.VisitEncoder(TypeAssert(varToSet, tType), data.Default, name)
@@ -262,7 +262,7 @@ func MapperEncoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
vName := "v" + name
s1 := VarStmt(vName, kType)
s2 := Assign(Exprs(Ident(vName), Ident("err")), Exprs(Call(Selector("queser", "ErroringIndex"), Ident(mName), varToSet)))
s2 := Assign(Exprs(Ident(vName), Ident("err")), Exprs(Call(Selector("proto_base", "ErroringIndex"), Ident(mName), varToSet)))
s3 := IfErrNil()
s4, err := g.VisitEncoder(Ident(vName), data.Type, name)
if err != nil {
@@ -278,7 +278,7 @@ func MapperEncoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s
func StringEncoder(_ *Generator, varToSet ast.Expr, _ any, _ string) (s []ast.Stmt, err error) {
s = Stmts(
Assign121(Ident("err"), Call(Selector("queser", "EncodeString"), Ident("w"), varToSet)), IfErrNil())
Assign121(Ident("err"), Call(Selector("proto_base", "EncodeString"), Ident("w"), varToSet)), IfErrNil())
return
}
@@ -310,7 +310,7 @@ func RegistryEntryHolderEncoder(g *Generator, varToSet ast.Expr, dataRaw any, na
statements := Stmts()
statements = append(statements, Case(Exprs(baseType), baseEncodeStatements))
statements = append(statements, Case(Exprs(otherwiseType), otherwiseEncodeStatements))
statements = append(statements, Case(nil, Stmts(Assign121(Ident("err"), Selector("queser", "BadTypeError")))))
statements = append(statements, Case(nil, Stmts(Assign121(Ident("err"), Selector("proto_base", "BadTypeError")))))
s = Stmts(TypeSwitch(Define121(Ident(knownTypeName), TypeAssert(varToSet, Ident("type"))), NewBlock(statements)))
return
@@ -157,13 +157,13 @@ func (g *Generator) RegisterNatives() {
g.Natives = map[string]ExprGeneratorFunc{
"container": VisitContainerType,
"buffer": VisitBufferType,
"varint": MakeSelectorVisitor("queser", "VarInt"),
"varint": MakeSelectorVisitor("proto_base", "VarInt"),
"array": VisitArrayTypeVisitorType,
"mapper": MakeIdentVisitor("string"),
"native": VisitDontGenerateType,
"anonymousNbt": MakeSelectorVisitor("nbt", "Anon"),
"anonOptionalNbt": MakeSelectorVisitor("nbt", "Anon"), // I have no idea what the difference is between these two
"void": MakeSelectorVisitor("queser", "Void"),
"void": MakeSelectorVisitor("proto_base", "Void"),
"bool": MakeIdentVisitor("bool"),
"u8": MakeIdentVisitor("uint8"),
"u16": MakeIdentVisitor("uint16"),
@@ -184,7 +184,7 @@ func (g *Generator) RegisterNatives() {
"bitfield": VisitBitFieldType,
"pstring": VisitDontGenerateType,
"string": MakeIdentVisitor("string"),
"restBuffer": MakeSelectorVisitor("queser", "RestBuffer"),
"restBuffer": MakeSelectorVisitor("proto_base", "RestBuffer"),
"bitflags": VisitBitFlagsType,
"topBitSetTerminatedArray": VisitToDoType,
"todo": VisitToDoType,
@@ -16,8 +16,8 @@ func GeneratePacketIdentifierToType(versions []string) (decl ast.Decl) {
s = append(s, Case(nil, Stmts()))
fn := NewFunc("PacketIdentifierToType", []NameAndType{
{"v", Ident("string")},
{"d", Ident("queser.Direction")},
{"s", Ident("queser.State")},
{"d", Ident("proto_base.Direction")},
{"s", Ident("proto_base.State")},
{"i", Ident("string")},
}, []NameAndType{
{"t", Ident("any")},
@@ -28,7 +28,7 @@ func GeneratePacketIdentifierToType(versions []string) (decl ast.Decl) {
}
/*
func PacketIdentifierToType(v string, d queser.Direction, s queser.State, i string) (t any) {
func PacketIdentifierToType(v string, d proto_base.Direction, s proto_base.State, i string) (t any) {
switch v {
case "1.21.8":
t = v1_21_8.PacketIdentifierToType(d, s, i)
@@ -38,7 +38,7 @@ func PacketIdentifierToType(v string, d queser.Direction, s queser.State, i stri
return
}
func TypeToPacketIdentifier(v string, d queser.Direction, s queser.State, t any) (i string) {
func TypeToPacketIdentifier(v string, d proto_base.Direction, s proto_base.State, t any) (i string) {
switch v {
case "1.21.8":
i = v1_21_8.TypeToPacketIdentifier(d, s, t)
@@ -46,7 +46,7 @@ func TypeToPacketIdentifier(v string, d queser.Direction, s queser.State, t any)
return
}
func DecodePacket(v string, d queser.Direction, s queser.State, r io.Reader) (packet any, err error) {
func DecodePacket(v string, d proto_base.Direction, s proto_base.State, r io.Reader) (packet any, err error) {
switch v {
case "1.21.8":
packet, err = v1_21_8.DecodePacket(d, s, r)
@@ -54,7 +54,7 @@ func DecodePacket(v string, d queser.Direction, s queser.State, r io.Reader) (pa
return
}
func EncodePacket(v string, d queser.Direction, s queser.State, i string, p any, w io.Writer) (err error) {
func EncodePacket(v string, d proto_base.Direction, s proto_base.State, i string, p any, w io.Writer) (err error) {
switch v {
case "1.21.8":
err = v1_21_8.EncodePacket(d, s, i, p, w)
@@ -74,8 +74,8 @@ func GenerateTypeToPacketIdentifier(versions []string) (decl ast.Decl) {
}
fn := NewFunc("TypeToPacketIdentifier", []NameAndType{
{"v", Ident("string")},
{"d", Ident("queser.Direction")},
{"s", Ident("queser.State")},
{"d", Ident("proto_base.Direction")},
{"s", Ident("proto_base.State")},
{"t", Ident("any")},
}, []NameAndType{
{"i", Ident("string")},
@@ -94,8 +94,8 @@ func GenerateDecodePacket(versions []string) (decl ast.Decl) {
}
fn := NewFunc("DecodePacket", []NameAndType{
{"v", Ident("string")},
{"d", Ident("queser.Direction")},
{"s", Ident("queser.State")},
{"d", Ident("proto_base.Direction")},
{"s", Ident("proto_base.State")},
{"r", Ident("io.Reader")},
}, []NameAndType{
{"packet", Ident("any")},
@@ -115,8 +115,8 @@ func GenerateEncodePacket(versions []string) (decl ast.Decl) {
}
fn := NewFunc("EncodePacket", []NameAndType{
{"v", Ident("string")},
{"d", Ident("queser.Direction")},
{"s", Ident("queser.State")},
{"d", Ident("proto_base.Direction")},
{"s", Ident("proto_base.State")},
{"i", Ident("string")},
{"p", Ident("any")},
{"w", Ident("io.Writer")},
@@ -129,11 +129,12 @@ func GenerateEncodePacket(versions []string) (decl ast.Decl) {
}
func GenerateVersionSwitcher(versions []string, printTo io.Writer) (err error) {
f := NewFile("generated")
AppendDecl(f, Import(
"io",
"github.com/admin-else/queser",
"github.com/admin-else/queser/generated/v1_21_8"))
f := NewFile("proto_generated")
importPaths := []string{"io", "github.com/admin-else/strom/proto_base"}
for _, version := range versions {
importPaths = append(importPaths, "github.com/admin-else/strom/proto_generated/v"+strings.ReplaceAll(version, ".", "_"))
}
AppendDecl(f, Import(importPaths...))
AppendDecl(f, GeneratePacketIdentifierToType(versions))
AppendDecl(f, GenerateTypeToPacketIdentifier(versions))
AppendDecl(f, GenerateDecodePacket(versions))