Add 1.21.70 support
This commit is contained in:
66
legacyver/legacypacket/client_movement_prediction_sync.go
Normal file
66
legacyver/legacypacket/client_movement_prediction_sync.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
const ClientMovementPredictionSyncBitsetSize = 123
|
||||
|
||||
// ClientMovementPredictionSync is sent by the client to the server periodically if the client has received
|
||||
// movement corrections from the server, containing information about client-predictions that are relevant
|
||||
// to movement.
|
||||
type ClientMovementPredictionSync struct {
|
||||
// ActorFlags is a bitset of all the flags that are currently set for the client.
|
||||
ActorFlags protocol.Bitset
|
||||
// BoundingBoxScale is the scale of the client's bounding box.
|
||||
BoundingBoxScale float32
|
||||
// BoundingBoxWidth is the width of the client's bounding box.
|
||||
BoundingBoxWidth float32
|
||||
// BoundingBoxHeight is the height of the client's bounding box.
|
||||
BoundingBoxHeight float32
|
||||
// MovementSpeed is the movement speed attribute or 0 if not set.
|
||||
MovementSpeed float32
|
||||
// UnderwaterMovementSpeed is the underwater movement speed attribute or 0 if not set.
|
||||
UnderwaterMovementSpeed float32
|
||||
// LavaMovementSpeed is the lava movement speed attribute or 0 if not set.
|
||||
LavaMovementSpeed float32
|
||||
// JumpStrength is the jump strength attribute or 0 if not set.
|
||||
JumpStrength float32
|
||||
// Health is the health attribute or 0 if not set.
|
||||
Health float32
|
||||
// Hunger is the hunger attribute or 0 if not set.
|
||||
Hunger float32
|
||||
// EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across
|
||||
// different sessions of the same world.
|
||||
EntityUniqueID int64
|
||||
// Flying specifies if the client is currently flying.
|
||||
Flying bool
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*ClientMovementPredictionSync) ID() uint32 {
|
||||
return packet.IDClientMovementPredictionSync
|
||||
}
|
||||
|
||||
func (pk *ClientMovementPredictionSync) Marshal(io protocol.IO) {
|
||||
if proto.IsProtoGTE(io, proto.ID786) {
|
||||
io.Bitset(&pk.ActorFlags, ClientMovementPredictionSyncBitsetSize)
|
||||
} else {
|
||||
io.Bitset(&pk.ActorFlags, 120)
|
||||
}
|
||||
io.Float32(&pk.BoundingBoxScale)
|
||||
io.Float32(&pk.BoundingBoxWidth)
|
||||
io.Float32(&pk.BoundingBoxHeight)
|
||||
io.Float32(&pk.MovementSpeed)
|
||||
io.Float32(&pk.UnderwaterMovementSpeed)
|
||||
io.Float32(&pk.LavaMovementSpeed)
|
||||
io.Float32(&pk.JumpStrength)
|
||||
io.Float32(&pk.Health)
|
||||
io.Float32(&pk.Hunger)
|
||||
io.Varint64(&pk.EntityUniqueID)
|
||||
if proto.IsProtoGTE(io, proto.ID786) {
|
||||
io.Bool(&pk.Flying)
|
||||
}
|
||||
}
|
||||
55
legacyver/legacypacket/level_sound_event.go
Normal file
55
legacyver/legacypacket/level_sound_event.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/go-gl/mathgl/mgl32"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// LevelSoundEvent is sent by the server to make any kind of built-in sound heard to a player. It is sent to,
|
||||
// for example, play a stepping sound or a shear sound. The packet is also sent by the client, in which case
|
||||
// it could be forwarded by the server to the other players online. If possible, the packets from the client
|
||||
// should be ignored however, and the server should play them on its own accord.
|
||||
type LevelSoundEvent struct {
|
||||
// SoundType is the type of the sound to play. It is one of the constants above. Some of the sound types
|
||||
// require additional data, which is set in the EventData field.
|
||||
SoundType uint32
|
||||
// Position is the position of the sound event. The player will be able to hear the direction of the sound
|
||||
// based on what position is sent here.
|
||||
Position mgl32.Vec3
|
||||
// ExtraData is a packed integer that some sound types use to provide extra data. An example of this is
|
||||
// the note sound, which is composed of a pitch and an instrument type.
|
||||
ExtraData int32
|
||||
// EntityType is the string entity type of the entity that emitted the sound, for example
|
||||
// 'minecraft:skeleton'. Some sound types use this entity type for additional data.
|
||||
EntityType string
|
||||
// BabyMob specifies if the sound should be that of a baby mob. It is most notably used for parrot
|
||||
// imitations, which will change based on if this field is set to true or not.
|
||||
BabyMob bool
|
||||
// DisableRelativeVolume specifies if the sound should be played relatively or not. If set to true, the
|
||||
// sound will have full volume, regardless of where the Position is, whereas if set to false, the sound's
|
||||
// volume will be based on the distance to Position.
|
||||
DisableRelativeVolume bool
|
||||
// EntityUniqueID is the unique ID of a source entity. The unique ID is a value that remains consistent across
|
||||
// different sessions of the same world, but most servers simply fill the runtime ID of the entity out for
|
||||
// this field.
|
||||
EntityUniqueID int64
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*LevelSoundEvent) ID() uint32 {
|
||||
return packet.IDLevelSoundEvent
|
||||
}
|
||||
|
||||
func (pk *LevelSoundEvent) Marshal(io protocol.IO) {
|
||||
io.Varuint32(&pk.SoundType)
|
||||
io.Vec3(&pk.Position)
|
||||
io.Varint32(&pk.ExtraData)
|
||||
io.String(&pk.EntityType)
|
||||
io.Bool(&pk.BabyMob)
|
||||
io.Bool(&pk.DisableRelativeVolume)
|
||||
if proto.IsProtoGTE(io, proto.ID786) {
|
||||
io.Int64(&pk.EntityUniqueID)
|
||||
}
|
||||
}
|
||||
45
legacyver/legacypacket/set_hud.go
Normal file
45
legacyver/legacypacket/set_hud.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// SetHud is sent by the server to set the visibility of individual HUD elements on the client. It is
|
||||
// important to note that the client does not reset the state of the HUD elements after it leaves a server,
|
||||
// meaning they can leak into sessions on different servers. To be safe, you should reset the visibility of
|
||||
// all HUD elements when a player connects.
|
||||
type SetHud struct {
|
||||
// Elements is a list of HUD elements that are being modified. The values can be any of the HudElement
|
||||
// constants above.
|
||||
Elements []int32
|
||||
// Visibility represents the new visibility of the specified Elements. It can be any of the HudVisibility
|
||||
// constants above.
|
||||
Visibility int32
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*SetHud) ID() uint32 {
|
||||
return packet.IDSetHud
|
||||
}
|
||||
|
||||
func (pk *SetHud) Marshal(io protocol.IO) {
|
||||
if proto.IsProtoGTE(io, proto.ID786) {
|
||||
protocol.FuncSlice(io, &pk.Elements, io.Varint32)
|
||||
io.Varint32(&pk.Visibility)
|
||||
} else {
|
||||
elements := make([]uint8, len(pk.Elements))
|
||||
for i, v := range pk.Elements {
|
||||
elements[i] = uint8(v)
|
||||
}
|
||||
protocol.FuncSlice(io, &elements, io.Uint8)
|
||||
for i, v := range elements {
|
||||
pk.Elements[i] = int32(v)
|
||||
}
|
||||
|
||||
visibility := uint8(pk.Visibility)
|
||||
io.Uint8(&visibility)
|
||||
pk.Visibility = int32(visibility)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user