Skip to content

Commit

Permalink
protocol: Support 1.19.70 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Mar 14, 2023
1 parent 64177de commit d16b15a
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 4 deletions.
1 change: 1 addition & 0 deletions minecraft/protocol/ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
AbilityMuted
AbilityWorldBuilder
AbilityNoClip
AbilityPrivilegedBuilder
AbilityCount
)

Expand Down
4 changes: 4 additions & 0 deletions minecraft/protocol/entity_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ const (
EntityDataFlagSonicBoom
EntityDataFlagHasDashTimeout
EntityDataFlagPushTowardsClosestSpace
EntityDataFlagScenting
EntityDataFlagRising
EntityDataFlagFeelingHappy
EntityDataFlagSearching
)

const (
Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package protocol

const (
// CurrentProtocol is the current protocol version for the version below.
CurrentProtocol = 568
CurrentProtocol = 575
// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
CurrentVersion = "1.19.63"
CurrentVersion = "1.19.70"
)
13 changes: 13 additions & 0 deletions minecraft/protocol/item_descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
ItemDescriptorMoLang
ItemDescriptorItemTag
ItemDescriptorDeferred
ItemDescriptorComplexAlias
)

// InvalidItemDescriptor represents an invalid item descriptor. This is usually sent by the vanilla server for empty
Expand Down Expand Up @@ -89,3 +90,15 @@ func (x *DeferredItemDescriptor) Marshal(r IO) {
r.String(&x.Name)
r.Int16(&x.MetadataValue)
}

// ComplexAliasItemDescriptor represents an item descriptor that uses a single name to identify the item. There is no
// clear benefit of using this item descriptor and only seem to be used for specific recipes.
type ComplexAliasItemDescriptor struct {
// Name is the name of the item, which is a name like 'minecraft:stick'.
Name string
}

// Marshal ...
func (x *ComplexAliasItemDescriptor) Marshal(r IO) {
r.String(&x.Name)
}
2 changes: 0 additions & 2 deletions minecraft/protocol/item_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const (
FilterCauseSlashCommandChat
FilterCauseCartographyText
FilterCauseSlashCommandNonChat
FilterCauseScoreboardText
FilterCauseTickingAreaText
)

// ItemStackRequest represents a single request present in an ItemStackRequest packet sent by the client to
Expand Down
27 changes: 27 additions & 0 deletions minecraft/protocol/packet/camera_instruction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package packet

import (
"github.com/sandertv/gophertunnel/minecraft/nbt"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

// CameraInstruction gives a custom camera specific instructions to operate.
type CameraInstruction struct {
// Data is a compound tag of the instructions to sent. The structure of this tag is currently unknown.
Data map[string]any
}

// ID ...
func (*CameraInstruction) ID() uint32 {
return IDCameraInstruction
}

// Marshal ...
func (pk *CameraInstruction) Marshal(w *protocol.Writer) {
w.NBT(&pk.Data, nbt.NetworkLittleEndian)
}

// Unmarshal ...
func (pk *CameraInstruction) Unmarshal(r *protocol.Reader) {
r.NBT(&pk.Data, nbt.NetworkLittleEndian)
}
27 changes: 27 additions & 0 deletions minecraft/protocol/packet/camera_presets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package packet

import (
"github.com/sandertv/gophertunnel/minecraft/nbt"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

// CameraPresets gives the client a list of custom camera presets.
type CameraPresets struct {
// Data is a compound tag of the presets being set. The structure of this tag is currently unknown.
Data map[string]any
}

// ID ...
func (*CameraPresets) ID() uint32 {
return IDCameraPresets
}

// Marshal ...
func (pk *CameraPresets) Marshal(w *protocol.Writer) {
w.NBT(&pk.Data, nbt.NetworkLittleEndian)
}

// Unmarshal ...
func (pk *CameraPresets) Unmarshal(r *protocol.Reader) {
r.NBT(&pk.Data, nbt.NetworkLittleEndian)
}
3 changes: 3 additions & 0 deletions minecraft/protocol/packet/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,7 @@ const (
IDGameTestResults
IDUpdateClientInputLocks
IDClientCheatAbility
IDCameraPresets
IDUnlockedRecipes
IDCameraInstruction = iota + 101
)
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/level_sound_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ const (
SoundEventPickup
SoundEventInsertEnchanted
SoundEventPickupEnchanted
SoundEventBrush
SoundEventBrushCompleted
SoundEventShatterDecoratedPot
SoundEventBreakDecoratedPot
)

// LevelSoundEvent is sent by the server to make any kind of built-in sound heard to a player. It is sent to,
Expand Down
8 changes: 8 additions & 0 deletions minecraft/protocol/packet/player_auth_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
InputFlagPerformBlockActions
InputFlagPerformItemStackRequest
InputFlagHandledTeleport
InputFlagEmoting
)

const (
Expand Down Expand Up @@ -113,6 +114,9 @@ type PlayerAuthInput struct {
ItemStackRequest protocol.ItemStackRequest
// BlockActions is a slice of block actions that the client has interacted with.
BlockActions []protocol.PlayerBlockAction
// AnalogueMoveVector is a Vec2 that specifies the direction in which the player moved, as a combination of X/Z
// values which are created using an analogue input.
AnalogueMoveVector mgl32.Vec2
}

// ID ...
Expand Down Expand Up @@ -148,6 +152,8 @@ func (pk *PlayerAuthInput) Marshal(w *protocol.Writer) {
if pk.InputData&InputFlagPerformBlockActions != 0 {
protocol.SliceVarint32Length(w, &pk.BlockActions)
}

w.Vec2(&pk.AnalogueMoveVector)
}

// Unmarshal ...
Expand Down Expand Up @@ -178,4 +184,6 @@ func (pk *PlayerAuthInput) Unmarshal(r *protocol.Reader) {
if pk.InputData&InputFlagPerformBlockActions != 0 {
protocol.SliceVarint32Length(r, &pk.BlockActions)
}

r.Vec2(&pk.AnalogueMoveVector)
}
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ func init() {
IDGameTestResults: func() Packet { return &GameTestResults{} },
IDUpdateClientInputLocks: func() Packet { return &UpdateClientInputLocks{} },
IDClientCheatAbility: func() Packet { return &ClientCheatAbility{} },
IDCameraPresets: func() Packet { return &CameraPresets{} },
IDUnlockedRecipes: func() Packet { return &UnlockedRecipes{} },
// ---
IDCameraInstruction: func() Packet { return &CameraInstruction{} },
}
for id, pk := range packets {
Register(id, pk)
Expand Down
31 changes: 31 additions & 0 deletions minecraft/protocol/packet/unlocked_recipes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package packet

import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

// UnlockedRecipes gives the client a list of recipes that have been unlocked, restricting the recipes that appear in
// the recipe book.
type UnlockedRecipes struct {
// NewUnlocks determines if new recipes have been unlocked since the packet was last sent.
NewUnlocks bool
// Recipes is a list of recipe names that have been unlocked.
Recipes []string
}

// ID ...
func (*UnlockedRecipes) ID() uint32 {
return IDUnlockedRecipes
}

// Marshal ...
func (pk *UnlockedRecipes) Marshal(w *protocol.Writer) {
w.Bool(&pk.NewUnlocks)
protocol.FuncSlice(w, &pk.Recipes, w.String)
}

// Unmarshal ...
func (pk *UnlockedRecipes) Unmarshal(r *protocol.Reader) {
r.Bool(&pk.NewUnlocks)
protocol.FuncSlice(r, &pk.Recipes, r.String)
}
2 changes: 2 additions & 0 deletions minecraft/protocol/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ func (r *Reader) ItemDescriptorCount(i *ItemDescriptorCount) {
i.Descriptor = &ItemTagItemDescriptor{}
case ItemDescriptorDeferred:
i.Descriptor = &DeferredItemDescriptor{}
case ItemDescriptorComplexAlias:
i.Descriptor = &ComplexAliasItemDescriptor{}
default:
r.UnknownEnumOption(id, "item descriptor type")
return
Expand Down
2 changes: 2 additions & 0 deletions minecraft/protocol/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ func (w *Writer) ItemDescriptorCount(i *ItemDescriptorCount) {
id = ItemDescriptorItemTag
case *DeferredItemDescriptor:
id = ItemDescriptorDeferred
case *ComplexAliasItemDescriptor:
id = ItemDescriptorComplexAlias
default:
w.UnknownEnumOption(fmt.Sprintf("%T", i.Descriptor), "item descriptor type")
return
Expand Down

0 comments on commit d16b15a

Please sign in to comment.