Skip to content

Commit

Permalink
Initial v1.19.40 support (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustTalDevelops committed Oct 25, 2022
1 parent 0de533a commit 748203e
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 6 deletions.
1 change: 1 addition & 0 deletions minecraft/protocol/ability.go
Expand Up @@ -27,6 +27,7 @@ const (
AbilityLayerTypeBase
AbilityLayerTypeSpectator
AbilityLayerTypeCommands
AbilityLayerTypeEditor
)

const (
Expand Down
44 changes: 44 additions & 0 deletions minecraft/protocol/entity_properties.go
@@ -0,0 +1,44 @@
package protocol

// EntityProperties holds lists of entity properties that define specific attributes of an entity. As of v1.19.40, the
// vanilla server does not use these properties, however they are still supported by the protocol.
type EntityProperties struct {
// IntegerProperties is a list of entity properties that contain integer values.
IntegerProperties []IntegerEntityProperty
// FloatProperties is a list of entity properties that contain float values.
FloatProperties []FloatEntityProperty
}

// Marshal ...
func (e EntityProperties) Marshal(r IO) {
Slice(r, &e.IntegerProperties)
Slice(r, &e.FloatProperties)
}

// IntegerEntityProperty is an entity property that contains an integer value.
type IntegerEntityProperty struct {
// Index represents the index of the property. It is unclear what the exact purpose of this is.
Index uint32
// Value is the value of the property.
Value int32
}

// Marshal ...
func (i IntegerEntityProperty) Marshal(r IO) {
r.Varuint32(&i.Index)
r.Varint32(&i.Value)
}

// FloatEntityProperty is an entity property that contains a float value.
type FloatEntityProperty struct {
// Index represents the index of the property. It is unclear what the exact purpose of this is.
Index uint32
// Value is the value of the property.
Value float32
}

// Marshal ...
func (f FloatEntityProperty) Marshal(r IO) {
r.Varuint32(&f.Index)
r.Float32(&f.Value)
}
4 changes: 2 additions & 2 deletions minecraft/protocol/info.go
Expand Up @@ -2,7 +2,7 @@ package protocol

const (
// CurrentProtocol is the current protocol version for the version below.
CurrentProtocol = 554
CurrentProtocol = 557
// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
CurrentVersion = "1.19.30"
CurrentVersion = "1.19.40"
)
1 change: 1 addition & 0 deletions minecraft/protocol/item_stack.go
Expand Up @@ -16,6 +16,7 @@ const (
FilterCauseLeaveEventText
FilterCauseSlashCommandChat
FilterCauseCartographyText
FilterCauseSlashCommandNonChat
)

// ItemStackRequest represents a single request present in an ItemStackRequest packet sent by the client to
Expand Down
5 changes: 2 additions & 3 deletions minecraft/protocol/login/data.go
Expand Up @@ -321,10 +321,9 @@ func (data ClientData) Validate() error {
if data.SkinID == "" {
return fmt.Errorf("SkinID must not be an empty string")
}
if data.UIProfile != 0 && data.UIProfile != 1 {
return fmt.Errorf("UIProfile must be either 0 or 1, but got %v", data.UIProfile)
if data.UIProfile < 0 || data.UIProfile > 2 {
return fmt.Errorf("UIProfile must be between 0-2, but got %v", data.UIProfile)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions minecraft/protocol/packet/add_actor.go
Expand Up @@ -43,6 +43,9 @@ type AddActor struct {
// particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'.
// The metadata values are indexed by their property key.
EntityMetadata map[uint32]any
// EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific
// attributes of the entity.
EntityProperties protocol.EntityProperties
// EntityLinks is a list of entity links that are currently active on the entity. These links alter the
// way the entity shows up when first spawned in terms of it shown as riding an entity. Setting these
// links is important for new viewers to see the entity is riding another entity.
Expand All @@ -67,6 +70,7 @@ func (pk *AddActor) Marshal(w *protocol.Writer) {
w.Float32(&pk.BodyYaw)
protocol.Slice(w, &pk.Attributes)
w.EntityMetadata(&pk.EntityMetadata)
protocol.Single(w, &pk.EntityProperties)
protocol.Slice(w, &pk.EntityLinks)
}

Expand All @@ -83,5 +87,6 @@ func (pk *AddActor) Unmarshal(r *protocol.Reader) {
r.Float32(&pk.BodyYaw)
protocol.Slice(r, &pk.Attributes)
r.EntityMetadata(&pk.EntityMetadata)
protocol.Single(r, &pk.EntityProperties)
protocol.Slice(r, &pk.EntityLinks)
}
5 changes: 5 additions & 0 deletions minecraft/protocol/packet/add_player.go
Expand Up @@ -47,6 +47,9 @@ type AddPlayer struct {
// particular the way the player looks. Flags include ones such as 'on fire' and 'sprinting'.
// The metadata values are indexed by their property key.
EntityMetadata map[uint32]any
// EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific
// attributes of the entity.
EntityProperties protocol.EntityProperties
// AbilityData represents various data about the abilities of a player, such as ability layers or permissions.
AbilityData protocol.AbilityData
// EntityLinks is a list of entity links that are currently active on the player. These links alter the
Expand Down Expand Up @@ -80,6 +83,7 @@ func (pk *AddPlayer) Marshal(w *protocol.Writer) {
w.ItemInstance(&pk.HeldItem)
w.Varint32(&pk.GameType)
w.EntityMetadata(&pk.EntityMetadata)
protocol.Single(w, &pk.EntityProperties)
protocol.Single(w, &pk.AbilityData)
protocol.Slice(w, &pk.EntityLinks)
w.String(&pk.DeviceID)
Expand All @@ -100,6 +104,7 @@ func (pk *AddPlayer) Unmarshal(r *protocol.Reader) {
r.ItemInstance(&pk.HeldItem)
r.Varint32(&pk.GameType)
r.EntityMetadata(&pk.EntityMetadata)
protocol.Single(r, &pk.EntityProperties)
protocol.Single(r, &pk.AbilityData)
protocol.Slice(r, &pk.EntityLinks)
r.String(&pk.DeviceID)
Expand Down
7 changes: 6 additions & 1 deletion minecraft/protocol/packet/level_sound_event.go
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

//noinspection SpellCheckingInspection
// noinspection SpellCheckingInspection
const (
SoundEventItemUseOn = iota
SoundEventHit
Expand Down Expand Up @@ -450,6 +450,11 @@ const (
SoundEventConvertToFrog
SoundEventRecordPlaying
SoundEventEnchantingTableUse
_
_
SoundEventBundleDropContents
SoundEventBundleInsert
SoundEventBundleRemoveOne
)

// LevelSoundEvent is sent by the server to make any kind of built-in sound heard to a player. It is sent to,
Expand Down
5 changes: 5 additions & 0 deletions minecraft/protocol/packet/set_actor_data.go
Expand Up @@ -14,6 +14,9 @@ type SetActorData struct {
// particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'.
// The metadata values are indexed by their property key.
EntityMetadata map[uint32]any
// EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific
// attributes of the entity.
EntityProperties protocol.EntityProperties
// Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction.
Tick uint64
}
Expand All @@ -27,12 +30,14 @@ func (*SetActorData) ID() uint32 {
func (pk *SetActorData) Marshal(w *protocol.Writer) {
w.Varuint64(&pk.EntityRuntimeID)
w.EntityMetadata(&pk.EntityMetadata)
protocol.Single(w, &pk.EntityProperties)
w.Varuint64(&pk.Tick)
}

// Unmarshal ...
func (pk *SetActorData) Unmarshal(r *protocol.Reader) {
r.Varuint64(&pk.EntityRuntimeID)
r.EntityMetadata(&pk.EntityMetadata)
protocol.Single(r, &pk.EntityProperties)
r.Varuint64(&pk.Tick)
}

0 comments on commit 748203e

Please sign in to comment.