diff --git a/minecraft/protocol/events.go b/minecraft/protocol/events.go index 16537a98..239d3a9f 100644 --- a/minecraft/protocol/events.go +++ b/minecraft/protocol/events.go @@ -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: @@ -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: @@ -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{} diff --git a/minecraft/protocol/packet/add_volume_entity.go b/minecraft/protocol/packet/add_volume_entity.go index 51ef5e90..19dcb24c 100644 --- a/minecraft/protocol/packet/add_volume_entity.go +++ b/minecraft/protocol/packet/add_volume_entity.go @@ -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 @@ -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) diff --git a/minecraft/protocol/packet/agent_action.go b/minecraft/protocol/packet/agent_action.go index c2f43363..5e6d17f3 100644 --- a/minecraft/protocol/packet/agent_action.go +++ b/minecraft/protocol/packet/agent_action.go @@ -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) } diff --git a/minecraft/protocol/packet/change_dimension.go b/minecraft/protocol/packet/change_dimension.go index e7a6b5e2..8a265ba5 100644 --- a/minecraft/protocol/packet/change_dimension.go +++ b/minecraft/protocol/packet/change_dimension.go @@ -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] } diff --git a/minecraft/protocol/packet/change_mob_property.go b/minecraft/protocol/packet/change_mob_property.go index c41e8936..419936d9 100644 --- a/minecraft/protocol/packet/change_mob_property.go +++ b/minecraft/protocol/packet/change_mob_property.go @@ -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. @@ -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) diff --git a/minecraft/protocol/packet/command_block_update.go b/minecraft/protocol/packet/command_block_update.go index a73b366a..3121eda9 100644 --- a/minecraft/protocol/packet/command_block_update.go +++ b/minecraft/protocol/packet/command_block_update.go @@ -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 @@ -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) } diff --git a/minecraft/protocol/packet/lesson_progress.go b/minecraft/protocol/packet/lesson_progress.go index 172cb7b2..9eff22f5 100644 --- a/minecraft/protocol/packet/lesson_progress.go +++ b/minecraft/protocol/packet/lesson_progress.go @@ -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 } @@ -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) } diff --git a/minecraft/protocol/packet/on_screen_texture_animation.go b/minecraft/protocol/packet/on_screen_texture_animation.go index 0faa6de0..76dc51b4 100644 --- a/minecraft/protocol/packet/on_screen_texture_animation.go +++ b/minecraft/protocol/packet/on_screen_texture_animation.go @@ -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 ... @@ -18,5 +18,5 @@ func (*OnScreenTextureAnimation) ID() uint32 { } func (pk *OnScreenTextureAnimation) Marshal(io protocol.IO) { - io.Int32(&pk.AnimationType) + io.Uint32(&pk.AnimationType) } diff --git a/minecraft/protocol/packet/remove_volume_entity.go b/minecraft/protocol/packet/remove_volume_entity.go index f283fe3e..29f70017 100644 --- a/minecraft/protocol/packet/remove_volume_entity.go +++ b/minecraft/protocol/packet/remove_volume_entity.go @@ -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 } @@ -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) } diff --git a/minecraft/protocol/packet/request_chunk_radius.go b/minecraft/protocol/packet/request_chunk_radius.go index fb972559..0c584279 100644 --- a/minecraft/protocol/packet/request_chunk_radius.go +++ b/minecraft/protocol/packet/request_chunk_radius.go @@ -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 ... @@ -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) } diff --git a/minecraft/protocol/packet/request_permissions.go b/minecraft/protocol/packet/request_permissions.go index 390e4d3e..7e7739cd 100644 --- a/minecraft/protocol/packet/request_permissions.go +++ b/minecraft/protocol/packet/request_permissions.go @@ -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 } @@ -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) } diff --git a/minecraft/protocol/packet/simple_event.go b/minecraft/protocol/packet/simple_event.go index feb76a96..684d4178 100644 --- a/minecraft/protocol/packet/simple_event.go +++ b/minecraft/protocol/packet/simple_event.go @@ -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 ... @@ -23,5 +23,5 @@ func (*SimpleEvent) ID() uint32 { } func (pk *SimpleEvent) Marshal(io protocol.IO) { - io.Int16(&pk.EventType) + io.Uint16(&pk.EventType) } diff --git a/minecraft/protocol/packet/start_game.go b/minecraft/protocol/packet/start_game.go index 9a75100f..fd7ec5f9 100644 --- a/minecraft/protocol/packet/start_game.go +++ b/minecraft/protocol/packet/start_game.go @@ -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 @@ -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) diff --git a/minecraft/protocol/packet/update_sub_chunk_blocks.go b/minecraft/protocol/packet/update_sub_chunk_blocks.go index 8099c742..16680a20 100644 --- a/minecraft/protocol/packet/update_sub_chunk_blocks.go +++ b/minecraft/protocol/packet/update_sub_chunk_blocks.go @@ -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. @@ -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) } diff --git a/minecraft/protocol/player.go b/minecraft/protocol/player.go index e645f992..a70715cc 100644 --- a/minecraft/protocol/player.go +++ b/minecraft/protocol/player.go @@ -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) } diff --git a/minecraft/protocol/reader.go b/minecraft/protocol/reader.go index c4e0de47..cf1931b4 100644 --- a/minecraft/protocol/reader.go +++ b/minecraft/protocol/reader.go @@ -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) diff --git a/minecraft/protocol/writer.go b/minecraft/protocol/writer.go index 727aa0db..42e30673 100644 --- a/minecraft/protocol/writer.go +++ b/minecraft/protocol/writer.go @@ -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)