Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.18.30 support #126

Merged
merged 15 commits into from Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = 486
CurrentProtocol = 503
// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
CurrentVersion = "1.18.10"
CurrentVersion = "1.18.30"
)
3 changes: 3 additions & 0 deletions minecraft/protocol/packet/actor_event.go
Expand Up @@ -48,6 +48,8 @@ const (

const (
ActorEventFeed = iota + 57
_
_
ActorEventBabyEat
ActorEventInstantDeath
ActorEventNotifyTrade
Expand All @@ -65,6 +67,7 @@ const (
ActorEventFinishedChargingCrossbow
ActorEventLandedOnGround
ActorEventActorGrowUp
ActorEventVibrationDetected
)

// ActorEvent is sent by the server when a particular event happens that has to do with an entity. Some of
Expand Down
6 changes: 5 additions & 1 deletion minecraft/protocol/packet/add_player.go
Expand Up @@ -45,11 +45,13 @@ type AddPlayer struct {
// itself shows up. Needless to say that this field is rather pointless, as additional packets still must
// be sent for armour to show up.
HeldItem protocol.ItemInstance
// GameType is the game type of the player. If set to GameTypeSpectator, the player will not be shown to viewers.
GameType int32
// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
// 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]interface{}
// Flags is a set of flags that specify certain properties of the player, such as whether or not it can
// Flags is a set of flags that specify certain properties of the player, such as whether it can
// fly and/or move through blocks.
Flags uint32
// CommandPermissionLevel is a set of permissions that specify what commands a player is allowed to execute.
Expand Down Expand Up @@ -95,6 +97,7 @@ func (pk *AddPlayer) Marshal(w *protocol.Writer) {
w.Float32(&pk.Yaw)
w.Float32(&pk.HeadYaw)
w.ItemInstance(&pk.HeldItem)
w.Varint32(&pk.GameType)
w.EntityMetadata(&pk.EntityMetadata)
w.Varuint32(&pk.Flags)
w.Varuint32(&pk.CommandPermissionLevel)
Expand All @@ -120,6 +123,7 @@ func (pk *AddPlayer) Unmarshal(r *protocol.Reader) {
r.Float32(&pk.Yaw)
r.Float32(&pk.HeadYaw)
r.ItemInstance(&pk.HeldItem)
r.Varint32(&pk.GameType)
r.EntityMetadata(&pk.EntityMetadata)
r.Varuint32(&pk.Flags)
r.Varuint32(&pk.CommandPermissionLevel)
Expand Down
11 changes: 11 additions & 0 deletions minecraft/protocol/packet/add_volume_entity.go
Expand Up @@ -18,6 +18,11 @@ type AddVolumeEntity struct {
EncodingIdentifier string
// InstanceIdentifier is the identifier of a fog definition.
InstanceIdentifier string
// Bounds represent the volume's bounds. The first value is the minimum bounds, and the second value is the
// maximum bounds.
Bounds [2]protocol.BlockPos
// Dimension is the dimension in which the volume exists.
Dimension int32
// EngineVersion is the engine version the entity is using, for example, '1.17.0'.
EngineVersion string
}
Expand All @@ -33,6 +38,9 @@ func (pk *AddVolumeEntity) Marshal(w *protocol.Writer) {
w.NBT(&pk.EntityMetadata, nbt.NetworkLittleEndian)
w.String(&pk.EncodingIdentifier)
w.String(&pk.InstanceIdentifier)
w.UBlockPos(&pk.Bounds[0])
w.UBlockPos(&pk.Bounds[1])
w.Varint32(&pk.Dimension)
w.String(&pk.EngineVersion)
}

Expand All @@ -42,5 +50,8 @@ func (pk *AddVolumeEntity) Unmarshal(r *protocol.Reader) {
r.NBT(&pk.EntityMetadata, nbt.NetworkLittleEndian)
r.String(&pk.EncodingIdentifier)
r.String(&pk.InstanceIdentifier)
r.UBlockPos(&pk.Bounds[0])
r.UBlockPos(&pk.Bounds[1])
r.Varint32(&pk.Dimension)
r.String(&pk.EngineVersion)
}
56 changes: 56 additions & 0 deletions minecraft/protocol/packet/agent_action.go
@@ -0,0 +1,56 @@
package packet

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

const (
AgentActionTypeAttack = iota + 1
AgentActionTypeCollect
AgentActionTypeDestroy
AgentActionTypeDetectRedstone
AgentActionTypeDetectObstacle
AgentActionTypeDrop
AgentActionTypeDropAll
AgentActionTypeInspect
AgentActionTypeInspectData
AgentActionTypeInspectItemCount
AgentActionTypeInspectItemDetail
AgentActionTypeInspectItemSpace
AgentActionTypeInteract
AgentActionTypeMove
AgentActionTypePlaceBlock
AgentActionTypeTill
AgentActionTypeTransferItemTo
AgentActionTypeTurn
)

// AgentAction is an Education Edition packet sent from the server to the client to return a response to a
// previously requested action.
type AgentAction struct {
// Identifier is a JSON identifier referenced in the initial action.
Identifier string
// Action represents the action type that was requested. It is one of the constants defined above.
Action int32
// Response is a JSON string containing the response to the action.
Response []byte
}

// ID ...
func (*AgentAction) ID() uint32 {
return IDAgentAction
}

// Marshal ...
func (pk *AgentAction) Marshal(w *protocol.Writer) {
w.String(&pk.Identifier)
w.Varint32(&pk.Action)
w.ByteSlice(&pk.Response)
}

// Unmarshal ...
func (pk *AgentAction) Unmarshal(r *protocol.Reader) {
r.String(&pk.Identifier)
r.Varint32(&pk.Action)
r.ByteSlice(&pk.Response)
}
46 changes: 46 additions & 0 deletions minecraft/protocol/packet/change_mob_property.go
@@ -0,0 +1,46 @@
package packet

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

// 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
// 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.
BoolValue bool
// StringValue is set if the property value is a string type. If the type is not a string, this field is ignored.
StringValue string
// IntValue is set if the property value is an int type. If the type is not an int, this field is ignored.
IntValue int32
// FloatValue is set if the property value is a float type. If the type is not a float, this field is ignored.
FloatValue float32
}

// ID ...
func (*ChangeMobProperty) ID() uint32 {
return IDChangeMobProperty
}

// Marshal ...
func (pk *ChangeMobProperty) Marshal(w *protocol.Writer) {
w.Uint64(&pk.EntityUniqueID)
w.String(&pk.Property)
w.Bool(&pk.BoolValue)
w.String(&pk.StringValue)
w.Varint32(&pk.IntValue)
w.Float32(&pk.FloatValue)
}

// Unmarshal ...
func (pk *ChangeMobProperty) Unmarshal(r *protocol.Reader) {
r.Uint64(&pk.EntityUniqueID)
r.String(&pk.Property)
r.Bool(&pk.BoolValue)
r.String(&pk.StringValue)
r.Varint32(&pk.IntValue)
r.Float32(&pk.FloatValue)
}
Expand Up @@ -9,7 +9,7 @@ import (
// is set to AuthoritativeMovementModeServerWithRewind. The packet is used to correct movement at a specific
// point in time.
type CorrectPlayerMovePrediction struct {
// Position is the position that the player is supposed to be at at the tick written in the field below.
// Position is the position that the player is supposed to be at the tick written in the field below.
// The client will change its current position based on movement after that tick starting from the
// Position.
Position mgl32.Vec3
Expand Down
37 changes: 37 additions & 0 deletions minecraft/protocol/packet/dimension_data.go
@@ -0,0 +1,37 @@
package packet

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

// DimensionData is a packet sent from the server to the client containing information about data-driven dimensions
// that the server may have registered.
type DimensionData struct {
// Definitions contain a list of data-driven dimension definitions registered on the server.
Definitions []protocol.DimensionDefinition
}

// ID ...
func (*DimensionData) ID() uint32 {
return IDDimensionData
}

// Marshal ...
func (pk *DimensionData) Marshal(w *protocol.Writer) {
definitionsLen := uint32(len(pk.Definitions))
w.Varuint32(&definitionsLen)
for _, definition := range pk.Definitions {
protocol.DimensionDef(w, &definition)
}
}

// Unmarshal ...
func (pk *DimensionData) Unmarshal(r *protocol.Reader) {
var definitionsLen uint32
r.Varuint32(&definitionsLen)

pk.Definitions = make([]protocol.DimensionDefinition, definitionsLen)
for i := uint32(0); i < definitionsLen; i++ {
protocol.DimensionDef(r, &pk.Definitions[i])
}
}
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/id.go
Expand Up @@ -179,4 +179,8 @@ const (
IDClientStartItemCooldown
IDScriptMessage
IDCodeBuilderSource
IDTickingAreasLoadStatus
IDDimensionData
IDAgentAction
IDChangeMobProperty
)
2 changes: 2 additions & 0 deletions minecraft/protocol/packet/level_event.go
Expand Up @@ -83,6 +83,8 @@ const (
LevelEventParticleTurtleEgg = 2034
LevelEventParticleSculkShriek = 2035
LevelEventSculkCatalystBloom = 2036
LevelEventSculkCharge = 2037
LevelEventSculkChargePop = 2038
LevelEventStartRaining = 3001
LevelEventStartThunderstorm = 3002
LevelEventStopRaining = 3003
Expand Down
48 changes: 48 additions & 0 deletions minecraft/protocol/packet/level_sound_event.go
Expand Up @@ -382,6 +382,54 @@ const (
SoundEventTongue
SoundEventCrackIronGolem
SoundEventRepairIronGolem
SoundEventListening
SoundEventHeartbeat
SoundEventHornBreak
SoundEventSculkPlace
SoundEventSculkSpread
SoundEventSculkCharge
SoundEventSculkSensorPlace
SoundEventSculkShriekerPlace
SoundEventGoatCall0
SoundEventGoatCall1
SoundEventGoatCall2
SoundEventGoatCall3
SoundEventGoatCall4
SoundEventGoatCall5
SoundEventGoatCall6
SoundEventGoatCall7
SoundEventGoatCall8
SoundEventGoatCall9
SoundEventGoatHarmony0
SoundEventGoatHarmony1
SoundEventGoatHarmony2
SoundEventGoatHarmony3
SoundEventGoatHarmony4
SoundEventGoatHarmony5
SoundEventGoatHarmony6
SoundEventGoatHarmony7
SoundEventGoatHarmony8
SoundEventGoatHarmony9
SoundEventGoatMelody0
SoundEventGoatMelody1
SoundEventGoatMelody2
SoundEventGoatMelody3
SoundEventGoatMelody4
SoundEventGoatMelody5
SoundEventGoatMelody6
SoundEventGoatMelody7
SoundEventGoatMelody8
SoundEventGoatMelody9
SoundEventGoatBass0
SoundEventGoatBass1
SoundEventGoatBass2
SoundEventGoatBass3
SoundEventGoatBass4
SoundEventGoatBass5
SoundEventGoatBass6
SoundEventGoatBass7
SoundEventGoatBass8
SoundEventGoatBass9
SoundEventUndefined
)

Expand Down
8 changes: 4 additions & 4 deletions minecraft/protocol/packet/npc_dialogue.go
Expand Up @@ -9,8 +9,8 @@ const (

// NPCDialogue is a packet that allows the client to display dialog boxes for interacting with NPCs.
type NPCDialogue struct {
// ActorUniqueID is the ID of the NPC being requested.
ActorUniqueID uint64
// EntityUniqueID is the unique ID of the NPC being requested.
EntityUniqueID uint64
// ActionType is the type of action for the packet.
ActionType int32
// Dialogue is the text that the client should see.
Expand All @@ -31,7 +31,7 @@ func (*NPCDialogue) ID() uint32 {

// Marshal ...
func (pk *NPCDialogue) Marshal(w *protocol.Writer) {
w.Uint64(&pk.ActorUniqueID)
w.Uint64(&pk.EntityUniqueID)
w.Varint32(&pk.ActionType)
w.String(&pk.Dialogue)
w.String(&pk.SceneName)
Expand All @@ -41,7 +41,7 @@ func (pk *NPCDialogue) Marshal(w *protocol.Writer) {

// Unmarshal ...
func (pk *NPCDialogue) Unmarshal(r *protocol.Reader) {
r.Uint64(&pk.ActorUniqueID)
r.Uint64(&pk.EntityUniqueID)
r.Varint32(&pk.ActionType)
r.String(&pk.Dialogue)
r.String(&pk.SceneName)
Expand Down
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/pool.go
Expand Up @@ -202,6 +202,10 @@ func init() {
IDClientStartItemCooldown: func() Packet { return &ClientStartItemCooldown{} },
IDScriptMessage: func() Packet { return &ScriptMessage{} },
IDCodeBuilderSource: func() Packet { return &CodeBuilderSource{} },
IDTickingAreasLoadStatus: func() Packet { return &TickingAreasLoadStatus{} },
IDDimensionData: func() Packet { return &DimensionData{} },
IDAgentAction: func() Packet { return &AgentAction{} },
IDChangeMobProperty: func() Packet { return &ChangeMobProperty{} },
}
for id, pk := range packets {
Register(id, pk)
Expand Down
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/remove_volume_entity.go
Expand Up @@ -8,6 +8,8 @@ import (
type RemoveVolumeEntity struct {
// EntityRuntimeID ...
EntityRuntimeID uint64
// Dimension ...
Dimension int32
}

// ID ...
Expand All @@ -18,9 +20,11 @@ func (*RemoveVolumeEntity) ID() uint32 {
// Marshal ...
func (pk *RemoveVolumeEntity) Marshal(w *protocol.Writer) {
w.Uint64(&pk.EntityRuntimeID)
w.Varint32(&pk.Dimension)
}

// Unmarshal ...
func (pk *RemoveVolumeEntity) Unmarshal(r *protocol.Reader) {
r.Uint64(&pk.EntityRuntimeID)
r.Varint32(&pk.Dimension)
}
2 changes: 2 additions & 0 deletions minecraft/protocol/packet/set_player_game_type.go
Expand Up @@ -10,6 +10,8 @@ const (
GameTypeAdventure
GameTypeSurvivalSpectator
GameTypeCreativeSpectator
GameTypeDefault
GameTypeSpectator
)

// SetPlayerGameType is sent by the server to update the game type, which is otherwise known as the game mode,
Expand Down