Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
91386ce
minecraft/protocol/packet/update_sub_chunk_blocks.go: Fix data type o…
Happy2018new Jul 12, 2025
512e122
Fix marshal for `io.PlayerInventoryAction`
Happy2018new Jul 13, 2025
635645d
minecraft/protocol/packet/add_volume_entity.go: Fix `EntityRuntimeID`
Happy2018new Jul 13, 2025
d1b6d53
minecraft/protocol/packet/remove_volume_entity.go: Fix `RemoveVolumeE…
Happy2018new Jul 13, 2025
a8cb51c
minecraft/protocol/packet/agent_action.go: Fix `Action`
Happy2018new Jul 13, 2025
9b9f3a6
minecraft/protocol/packet/change_mob_property.go: Fix `EntityUniqueID`
Happy2018new Jul 13, 2025
7d4f293
minecraft/protocol/packet/command_block_update.go: Fix `TickDelay`
Happy2018new Jul 13, 2025
ad799c8
minecraft/protocol/packet/lesson_progress.go: Fix `Action`
Happy2018new Jul 13, 2025
b3fccf8
minecraft/protocol/packet/on_screen_texture_animation.go: Fix `Animat…
Happy2018new Jul 13, 2025
00fc00c
minecraft/protocol/packet/request_chunk_radius.go: Fix `MaxChunkRadius`
Happy2018new Jul 13, 2025
52ca205
minecraft/protocol/packet/request_permissions.go: Fix `PermissionLevel`
Happy2018new Jul 13, 2025
36b7e40
minecraft/protocol/packet/simple_event.go: Fix `EventType`
Happy2018new Jul 13, 2025
51a2118
minecraft/protocol/packet/start_game.go: Fix `ForceExperimentalGameplay`
Happy2018new Jul 13, 2025
b2f4425
minecraft/protocol/packet/agent_action.go: Use `io.Int32` for `Action`
Happy2018new Jul 13, 2025
4dc2797
minecraft/protocol/packet/change_dimension.go: Fix typo
Happy2018new Jul 27, 2025
4bec758
minecraft/protocol/events.go: Fix missing marshal agent created event
Happy2018new Aug 9, 2025
d402923
minecraft/protocol/events.go: Fix the comments of `AgentCreatedEvent`
Happy2018new Sep 1, 2025
4505329
minecraft/protocol/packet/update_sub_chunk_blocks.go: Remove unnecess…
Happy2018new Sep 2, 2025
adb20ef
Merge branch 'Sandertv:master' into master
Happy2018new Oct 9, 2025
9bb3370
minecraft/protocol/player.go: Fix marshal of `ArmourSlot`
Happy2018new Oct 9, 2025
6978594
minecraft/protocol/player.go: Revert changes related to package import
Happy2018new Oct 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions minecraft/protocol/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func lookupEvent(eventType int32, x *Event) bool {
*x = &BossKilledEvent{}
case EventTypeAgentCommand:
*x = &AgentCommandEvent{}
case EventTypeAgentCreated:
*x = &AgentCreatedEvent{}
case EventTypePatternRemoved:
*x = &PatternRemovedEvent{}
case EventTypeSlashCommandExecuted:
Expand Down Expand Up @@ -128,6 +130,8 @@ func lookupEventType(x Event, eventType *int32) bool {
*eventType = EventTypeBossKilled
case *AgentCommandEvent:
*eventType = EventTypeAgentCommand
case *AgentCreatedEvent:
*eventType = EventTypeAgentCreated
case *PatternRemovedEvent:
*eventType = EventTypePatternRemoved
case *SlashCommandExecutedEvent:
Expand Down Expand Up @@ -347,6 +351,12 @@ func (a *AgentCommandEvent) Marshal(r IO) {
r.String(&a.Output)
}

// AgentCreatedEvent is the event data sent when an agent is created.
type AgentCreatedEvent struct{}

// Marshal ...
func (a *AgentCreatedEvent) Marshal(r IO) {}

// PatternRemovedEvent is the event data sent when a pattern is removed.
type PatternRemovedEvent struct{}

Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/add_volume_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type AddVolumeEntity struct {
// EntityRuntimeID is the runtime ID of the volume. The runtime ID is unique for each world session, and
// entities are generally identified in packets using this runtime ID.
EntityRuntimeID uint64
EntityRuntimeID uint32
// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
// particular the way the volume functions or looks.
EntityMetadata map[string]any
Expand All @@ -33,7 +33,7 @@ func (*AddVolumeEntity) ID() uint32 {
}

func (pk *AddVolumeEntity) Marshal(io protocol.IO) {
io.Uint64(&pk.EntityRuntimeID)
io.Varuint32(&pk.EntityRuntimeID)
io.NBT(&pk.EntityMetadata, nbt.NetworkLittleEndian)
io.String(&pk.EncodingIdentifier)
io.String(&pk.InstanceIdentifier)
Expand Down
2 changes: 1 addition & 1 deletion minecraft/protocol/packet/agent_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ func (*AgentAction) ID() uint32 {

func (pk *AgentAction) Marshal(io protocol.IO) {
io.String(&pk.Identifier)
io.Varint32(&pk.Action)
io.Int32(&pk.Action)
io.ByteSlice(&pk.Response)
}
2 changes: 1 addition & 1 deletion minecraft/protocol/packet/change_dimension.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ChangeDimension struct {
// LoadingScreenID is a unique ID for the loading screen that the player is currently in. The client will
// update the server on its state through the ServerBoundLoadingScreen packet, and it can be used to not
// send specific packets to the client if it is changing dimensions. This field should be unique for every
//ChangeDimension packet sent.
// ChangeDimension packet sent.
LoadingScreenID protocol.Optional[uint32]
}

Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/change_mob_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// ChangeMobProperty is a packet sent from the server to the client to change one of the properties of a mob client-side.
type ChangeMobProperty struct {
// EntityUniqueID is the unique ID of the entity whose property is being changed.
EntityUniqueID uint64
EntityUniqueID int64
// Property is the name of the property being updated.
Property string
// BoolValue is set if the property value is a bool type. If the type is not a bool, this field is ignored.
Expand All @@ -26,7 +26,7 @@ func (*ChangeMobProperty) ID() uint32 {
}

func (pk *ChangeMobProperty) Marshal(io protocol.IO) {
io.Uint64(&pk.EntityUniqueID)
io.Varint64(&pk.EntityUniqueID)
io.String(&pk.Property)
io.Bool(&pk.BoolValue)
io.String(&pk.StringValue)
Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/command_block_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type CommandBlockUpdate struct {
ShouldTrackOutput bool
// TickDelay is the delay in ticks between executions of a command block, if it is a repeating command
// block.
TickDelay int32
TickDelay uint32
// ExecuteOnFirstTick specifies if the command block should execute on the first tick, AKA as soon as the
// command block is enabled.
ExecuteOnFirstTick bool
Expand All @@ -79,6 +79,6 @@ func (pk *CommandBlockUpdate) Marshal(io protocol.IO) {
io.String(&pk.Name)
io.String(&pk.FilteredName)
io.Bool(&pk.ShouldTrackOutput)
io.Int32(&pk.TickDelay)
io.Uint32(&pk.TickDelay)
io.Bool(&pk.ExecuteOnFirstTick)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/lesson_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type LessonProgress struct {
// Identifier is the identifier of the lesson that is being progressed.
Identifier string
// Action is the action the client should perform to show progress. This is one of the constants defined above.
Action uint8
Action int32
// Score is the score the client should use when displaying the progress.
Score int32
}
Expand All @@ -27,7 +27,7 @@ func (*LessonProgress) ID() uint32 {
}

func (pk *LessonProgress) Marshal(io protocol.IO) {
io.Uint8(&pk.Action)
io.Varint32(&pk.Action)
io.Varint32(&pk.Score)
io.String(&pk.Identifier)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/on_screen_texture_animation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type OnScreenTextureAnimation struct {
// AnimationType is the type of the animation to show. The packet provides no further extra data to allow
// modifying the duration or other properties of the animation.
AnimationType int32
AnimationType uint32
}

// ID ...
Expand All @@ -18,5 +18,5 @@ func (*OnScreenTextureAnimation) ID() uint32 {
}

func (pk *OnScreenTextureAnimation) Marshal(io protocol.IO) {
io.Int32(&pk.AnimationType)
io.Uint32(&pk.AnimationType)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/remove_volume_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// RemoveVolumeEntity indicates a volume entity to be removed from server to client.
type RemoveVolumeEntity struct {
// EntityRuntimeID ...
EntityRuntimeID uint64
EntityRuntimeID uint32
// Dimension ...
Dimension int32
}
Expand All @@ -18,6 +18,6 @@ func (*RemoveVolumeEntity) ID() uint32 {
}

func (pk *RemoveVolumeEntity) Marshal(io protocol.IO) {
io.Uint64(&pk.EntityRuntimeID)
io.Varuint32(&pk.EntityRuntimeID)
io.Varint32(&pk.Dimension)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/request_chunk_radius.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type RequestChunkRadius struct {
ChunkRadius int32
// MaxChunkRadius is the maximum chunk radius that the player wants to receive. The reason for the client sending this
// is currently unknown.
MaxChunkRadius int32
MaxChunkRadius uint8
}

// ID ...
Expand All @@ -23,5 +23,5 @@ func (*RequestChunkRadius) ID() uint32 {

func (pk *RequestChunkRadius) Marshal(io protocol.IO) {
io.Varint32(&pk.ChunkRadius)
io.Varint32(&pk.MaxChunkRadius)
io.Uint8(&pk.MaxChunkRadius)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/request_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type RequestPermissions struct {
EntityUniqueID int64
// PermissionLevel is the current permission level of the player. This is one of the constants that may be found
// in the AdventureSettings packet.
PermissionLevel uint8
PermissionLevel int32
// RequestedPermissions contains the requested permission flags.
RequestedPermissions uint16
}
Expand All @@ -24,6 +24,6 @@ func (*RequestPermissions) ID() uint32 {

func (pk *RequestPermissions) Marshal(io protocol.IO) {
io.Int64(&pk.EntityUniqueID)
io.Uint8(&pk.PermissionLevel)
io.Varint32(&pk.PermissionLevel)
io.Uint16(&pk.RequestedPermissions)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/simple_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
// additional event data. The event is typically used by the client for telemetry.
type SimpleEvent struct {
// EventType is the type of the event to be called. It is one of the constants that may be found above.
EventType int16
EventType uint16
}

// ID ...
Expand All @@ -23,5 +23,5 @@ func (*SimpleEvent) ID() uint32 {
}

func (pk *SimpleEvent) Marshal(io protocol.IO) {
io.Int16(&pk.EventType)
io.Uint16(&pk.EventType)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/packet/start_game.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ type StartGame struct {
EducationSharedResourceURI protocol.EducationSharedResourceURI
// ForceExperimentalGameplay specifies if experimental gameplay should be force enabled. For servers this
// should always be set to false.
ForceExperimentalGameplay protocol.Optional[bool]
ForceExperimentalGameplay bool
// LevelID is a base64 encoded world ID that is used to identify the world.
LevelID string
// WorldName is the name of the world that the player is joining. Note that this field shows up above the
Expand Down Expand Up @@ -317,7 +317,7 @@ func (pk *StartGame) Marshal(io protocol.IO) {
io.Int32(&pk.LimitedWorldDepth)
io.Bool(&pk.NewNether)
protocol.Single(io, &pk.EducationSharedResourceURI)
protocol.OptionalFunc(io, &pk.ForceExperimentalGameplay, io.Bool)
io.Bool(&pk.ForceExperimentalGameplay)
io.Uint8(&pk.ChatRestrictionLevel)
io.Bool(&pk.DisablePlayerInteractions)
io.String(&pk.ServerID)
Expand Down
6 changes: 3 additions & 3 deletions minecraft/protocol/packet/update_sub_chunk_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "github.com/sandertv/gophertunnel/minecraft/protocol"

// UpdateSubChunkBlocks is essentially just UpdateBlock packet, however for a set of blocks in a sub-chunk.
type UpdateSubChunkBlocks struct {
// Position is the position of the sub-chunk being referred to.
Position protocol.SubChunkPos
// Position is the block position of the sub-chunk being referred to.
Position protocol.BlockPos
// Blocks contains each updated block change entry.
Blocks []protocol.BlockChangeEntry
// Extra contains each updated block change entry for the second layer, usually for waterlogged blocks.
Expand All @@ -18,7 +18,7 @@ func (*UpdateSubChunkBlocks) ID() uint32 {
}

func (pk *UpdateSubChunkBlocks) Marshal(io protocol.IO) {
io.SubChunkPos(&pk.Position)
io.UBlockPos(&pk.Position)
protocol.Slice(io, &pk.Blocks)
protocol.Slice(io, &pk.Extra)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ func (x *PlayerBlockAction) Marshal(r IO) {
// PlayerArmourDamageEntry represents an entry for a single piece of armour that should be damaged.
type PlayerArmourDamageEntry struct {
// ArmourSlot is the index of the armour slot to damage.
ArmourSlot uint8
ArmourSlot int32
// Damage is the amount of damage to apply to the armour in the specified slot.
Damage int16
}

// Marshal encodes/decodes a PlayerArmourDamageEntry.
func (x *PlayerArmourDamageEntry) Marshal(r IO) {
r.Uint8(&x.ArmourSlot)
r.Varint32(&x.ArmourSlot)
r.Int16(&x.Damage)
}
2 changes: 1 addition & 1 deletion minecraft/protocol/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (r *Reader) PlayerInventoryAction(x *UseItemTransactionData) {
Slice(r, &x.Actions)
r.Varuint32(&x.ActionType)
r.Varuint32(&x.TriggerType)
r.BlockPos(&x.BlockPosition)
r.UBlockPos(&x.BlockPosition)
r.Varint32(&x.BlockFace)
r.Varint32(&x.HotBarSlot)
r.ItemInstance(&x.HeldItem)
Expand Down
2 changes: 1 addition & 1 deletion minecraft/protocol/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (w *Writer) PlayerInventoryAction(x *UseItemTransactionData) {
Slice(w, &x.Actions)
w.Varuint32(&x.ActionType)
w.Varuint32(&x.TriggerType)
w.BlockPos(&x.BlockPosition)
w.UBlockPos(&x.BlockPosition)
w.Varint32(&x.BlockFace)
w.Varint32(&x.HotBarSlot)
w.ItemInstance(&x.HeldItem)
Expand Down