Refactor sub-chunk structure and align PlayerMovementSettings with proto package. Update gophertunnel dependency to v1.47.3.
This commit is contained in:
2
go.mod
2
go.mod
@@ -12,7 +12,7 @@ require (
|
|||||||
github.com/pelletier/go-toml v1.9.5
|
github.com/pelletier/go-toml v1.9.5
|
||||||
github.com/rogpeppe/go-internal v1.14.1
|
github.com/rogpeppe/go-internal v1.14.1
|
||||||
github.com/samber/lo v1.49.1
|
github.com/samber/lo v1.49.1
|
||||||
github.com/sandertv/gophertunnel v1.47.2-0.20250618150444-d66380c4a00b
|
github.com/sandertv/gophertunnel v1.47.3
|
||||||
github.com/segmentio/fasthash v1.0.3
|
github.com/segmentio/fasthash v1.0.3
|
||||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394
|
||||||
golang.org/x/image v0.25.0
|
golang.org/x/image v0.25.0
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -58,6 +58,8 @@ github.com/sandertv/gophertunnel v1.46.1-0.20250511074107-85599aa3447c h1:cZlIS0
|
|||||||
github.com/sandertv/gophertunnel v1.46.1-0.20250511074107-85599aa3447c/go.mod h1:lvzOdyb2fkoo3uySe++hy4UKq0I649oUFJKkro2ZHpY=
|
github.com/sandertv/gophertunnel v1.46.1-0.20250511074107-85599aa3447c/go.mod h1:lvzOdyb2fkoo3uySe++hy4UKq0I649oUFJKkro2ZHpY=
|
||||||
github.com/sandertv/gophertunnel v1.47.2-0.20250618150444-d66380c4a00b h1:/kNTXzMPTigd+ctGH3c4xVOnzxqyVCB11vikFPhvZqY=
|
github.com/sandertv/gophertunnel v1.47.2-0.20250618150444-d66380c4a00b h1:/kNTXzMPTigd+ctGH3c4xVOnzxqyVCB11vikFPhvZqY=
|
||||||
github.com/sandertv/gophertunnel v1.47.2-0.20250618150444-d66380c4a00b/go.mod h1:lvzOdyb2fkoo3uySe++hy4UKq0I649oUFJKkro2ZHpY=
|
github.com/sandertv/gophertunnel v1.47.2-0.20250618150444-d66380c4a00b/go.mod h1:lvzOdyb2fkoo3uySe++hy4UKq0I649oUFJKkro2ZHpY=
|
||||||
|
github.com/sandertv/gophertunnel v1.47.3 h1:MsHv8QEx17+N/39BnAvHn/KU9zv8Rt9ZHTKaZK9vSuo=
|
||||||
|
github.com/sandertv/gophertunnel v1.47.3/go.mod h1:lvzOdyb2fkoo3uySe++hy4UKq0I649oUFJKkro2ZHpY=
|
||||||
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
|
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
|
||||||
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
|
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ type StartGame struct {
|
|||||||
// on the world.
|
// on the world.
|
||||||
Trial bool
|
Trial bool
|
||||||
// PlayerMovementSettings ...
|
// PlayerMovementSettings ...
|
||||||
PlayerMovementSettings protocol.PlayerMovementSettings
|
PlayerMovementSettings proto.PlayerMovementSettings
|
||||||
// Time is the total time that has elapsed since the start of the world.
|
// Time is the total time that has elapsed since the start of the world.
|
||||||
Time int64
|
Time int64
|
||||||
// EnchantmentSeed is the seed used to seed the random used to produce enchantments in the enchantment
|
// EnchantmentSeed is the seed used to seed the random used to produce enchantments in the enchantment
|
||||||
@@ -319,7 +319,7 @@ func (pk *StartGame) Marshal(io protocol.IO) {
|
|||||||
io.String(&pk.WorldName)
|
io.String(&pk.WorldName)
|
||||||
io.String(&pk.TemplateContentIdentity)
|
io.String(&pk.TemplateContentIdentity)
|
||||||
io.Bool(&pk.Trial)
|
io.Bool(&pk.Trial)
|
||||||
protocol.PlayerMoveSettings(io, &pk.PlayerMovementSettings)
|
proto.PlayerMoveSettings(io, &pk.PlayerMovementSettings)
|
||||||
io.Int64(&pk.Time)
|
io.Int64(&pk.Time)
|
||||||
io.Varint32(&pk.EnchantmentSeed)
|
io.Varint32(&pk.EnchantmentSeed)
|
||||||
protocol.Slice(io, &pk.Blocks)
|
protocol.Slice(io, &pk.Blocks)
|
||||||
|
|||||||
@@ -95,3 +95,41 @@ func (x *PlayerListEntry) ToLatest() protocol.PlayerListEntry {
|
|||||||
func PlayerListRemoveEntry(r protocol.IO, x *PlayerListEntry) {
|
func PlayerListRemoveEntry(r protocol.IO, x *PlayerListEntry) {
|
||||||
r.UUID(&x.UUID)
|
r.UUID(&x.UUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlayerMovementSettings represents the different server authoritative movement settings. These control how
|
||||||
|
// the client will provide input to the server.
|
||||||
|
type PlayerMovementSettings struct {
|
||||||
|
// MovementType ...
|
||||||
|
MovementType int32
|
||||||
|
// RewindHistorySize is the amount of history to keep at maximum.
|
||||||
|
RewindHistorySize int32
|
||||||
|
// ServerAuthoritativeBlockBreaking specifies if block breaking should be sent through
|
||||||
|
// packet.PlayerAuthInput or not.
|
||||||
|
ServerAuthoritativeBlockBreaking bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PlayerMovementSettings) FromLatest(x protocol.PlayerMovementSettings) PlayerMovementSettings {
|
||||||
|
p.MovementType = 1
|
||||||
|
if p.RewindHistorySize > 0 {
|
||||||
|
p.MovementType = 2
|
||||||
|
}
|
||||||
|
p.RewindHistorySize = x.RewindHistorySize
|
||||||
|
p.ServerAuthoritativeBlockBreaking = x.ServerAuthoritativeBlockBreaking
|
||||||
|
return *p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PlayerMovementSettings) ToLatest() protocol.PlayerMovementSettings {
|
||||||
|
return protocol.PlayerMovementSettings{
|
||||||
|
RewindHistorySize: p.RewindHistorySize,
|
||||||
|
ServerAuthoritativeBlockBreaking: p.ServerAuthoritativeBlockBreaking,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PlayerMoveSettings reads/writes PlayerMovementSettings x to/from IO r.
|
||||||
|
func PlayerMoveSettings(r protocol.IO, x *PlayerMovementSettings) {
|
||||||
|
if IsProtoLT(r, ID818) {
|
||||||
|
r.Varint32(&x.MovementType)
|
||||||
|
}
|
||||||
|
r.Varint32(&x.RewindHistorySize)
|
||||||
|
r.Bool(&x.ServerAuthoritativeBlockBreaking)
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,14 +15,12 @@ type SubChunkEntry struct {
|
|||||||
HeightMapType byte
|
HeightMapType byte
|
||||||
// HeightMapData is the data for the height map.
|
// HeightMapData is the data for the height map.
|
||||||
HeightMapData []int8
|
HeightMapData []int8
|
||||||
// BlobHash is the hash of the blob.
|
|
||||||
BlobHash uint64
|
|
||||||
// RenderHeightMapType is always one of the constants defined in the HeightMapData constants.
|
// RenderHeightMapType is always one of the constants defined in the HeightMapData constants.
|
||||||
RenderHeightMapType byte
|
RenderHeightMapType byte
|
||||||
// RenderHeightMapData is the data for the render height map.
|
// RenderHeightMapData is the data for the render height map.
|
||||||
RenderHeightMapData []int8
|
RenderHeightMapData []int8
|
||||||
// RenderBlobHash is the hash of the render blob.
|
// BlobHash is the hash of the blob.
|
||||||
RenderBlobHash uint64
|
BlobHash uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToLatest ...
|
// ToLatest ...
|
||||||
@@ -33,10 +31,9 @@ func (x *SubChunkEntry) ToLatest() protocol.SubChunkEntry {
|
|||||||
RawPayload: x.RawPayload,
|
RawPayload: x.RawPayload,
|
||||||
HeightMapType: x.HeightMapType,
|
HeightMapType: x.HeightMapType,
|
||||||
HeightMapData: x.HeightMapData,
|
HeightMapData: x.HeightMapData,
|
||||||
BlobHash: x.BlobHash,
|
|
||||||
RenderHeightMapType: x.RenderHeightMapType,
|
RenderHeightMapType: x.RenderHeightMapType,
|
||||||
RenderHeightMapData: x.RenderHeightMapData,
|
RenderHeightMapData: x.RenderHeightMapData,
|
||||||
RenderBlobHash: x.RenderBlobHash,
|
BlobHash: x.BlobHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +44,9 @@ func (x *SubChunkEntry) FromLatest(y protocol.SubChunkEntry) SubChunkEntry {
|
|||||||
x.RawPayload = y.RawPayload
|
x.RawPayload = y.RawPayload
|
||||||
x.HeightMapType = y.HeightMapType
|
x.HeightMapType = y.HeightMapType
|
||||||
x.HeightMapData = y.HeightMapData
|
x.HeightMapData = y.HeightMapData
|
||||||
x.BlobHash = y.BlobHash
|
|
||||||
x.RenderHeightMapType = y.RenderHeightMapType
|
x.RenderHeightMapType = y.RenderHeightMapType
|
||||||
x.RenderHeightMapData = y.RenderHeightMapData
|
x.RenderHeightMapData = y.RenderHeightMapData
|
||||||
x.RenderBlobHash = y.RenderBlobHash
|
x.BlobHash = y.BlobHash
|
||||||
return *x
|
return *x
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,14 +61,13 @@ func (x *SubChunkEntry) Marshal(r protocol.IO) {
|
|||||||
if x.HeightMapType == protocol.HeightMapDataHasData {
|
if x.HeightMapType == protocol.HeightMapDataHasData {
|
||||||
protocol.FuncSliceOfLen(r, 256, &x.HeightMapData, r.Int8)
|
protocol.FuncSliceOfLen(r, 256, &x.HeightMapData, r.Int8)
|
||||||
}
|
}
|
||||||
r.Uint64(&x.BlobHash)
|
|
||||||
if IsProtoGTE(r, ID818) {
|
if IsProtoGTE(r, ID818) {
|
||||||
r.Uint8(&x.RenderHeightMapType)
|
r.Uint8(&x.RenderHeightMapType)
|
||||||
if x.RenderHeightMapType == protocol.HeightMapDataHasData {
|
if x.RenderHeightMapType == protocol.HeightMapDataHasData {
|
||||||
protocol.FuncSliceOfLen(r, 256, &x.RenderHeightMapData, r.Int8)
|
protocol.FuncSliceOfLen(r, 256, &x.RenderHeightMapData, r.Int8)
|
||||||
}
|
}
|
||||||
r.Uint64(&x.RenderBlobHash)
|
|
||||||
}
|
}
|
||||||
|
r.Uint64(&x.BlobHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubChunkEntryNoCache encodes/decodes a SubChunkEntry assuming the blob cache is not enabled.
|
// SubChunkEntryNoCache encodes/decodes a SubChunkEntry assuming the blob cache is not enabled.
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
|||||||
WorldName: pk.WorldName,
|
WorldName: pk.WorldName,
|
||||||
TemplateContentIdentity: pk.TemplateContentIdentity,
|
TemplateContentIdentity: pk.TemplateContentIdentity,
|
||||||
Trial: pk.Trial,
|
Trial: pk.Trial,
|
||||||
PlayerMovementSettings: pk.PlayerMovementSettings,
|
PlayerMovementSettings: (&proto.PlayerMovementSettings{}).FromLatest(pk.PlayerMovementSettings),
|
||||||
Time: pk.Time,
|
Time: pk.Time,
|
||||||
EnchantmentSeed: pk.EnchantmentSeed,
|
EnchantmentSeed: pk.EnchantmentSeed,
|
||||||
Blocks: pk.Blocks,
|
Blocks: pk.Blocks,
|
||||||
@@ -1130,7 +1130,7 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
|||||||
WorldName: pk.WorldName,
|
WorldName: pk.WorldName,
|
||||||
TemplateContentIdentity: pk.TemplateContentIdentity,
|
TemplateContentIdentity: pk.TemplateContentIdentity,
|
||||||
Trial: pk.Trial,
|
Trial: pk.Trial,
|
||||||
PlayerMovementSettings: pk.PlayerMovementSettings,
|
PlayerMovementSettings: pk.PlayerMovementSettings.ToLatest(),
|
||||||
Time: pk.Time,
|
Time: pk.Time,
|
||||||
EnchantmentSeed: pk.EnchantmentSeed,
|
EnchantmentSeed: pk.EnchantmentSeed,
|
||||||
Blocks: pk.Blocks,
|
Blocks: pk.Blocks,
|
||||||
|
|||||||
Reference in New Issue
Block a user