Add 1.20.70 & 1.20.60 support + Fix crafting issue (#9)
This commit is contained in:
@@ -36,13 +36,17 @@ func (*CorrectPlayerMovePrediction) ID() uint32 {
|
||||
}
|
||||
|
||||
func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO) {
|
||||
io.Uint8(&pk.PredictionType)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
io.Uint8(&pk.PredictionType)
|
||||
}
|
||||
io.Vec3(&pk.Position)
|
||||
io.Vec3(&pk.Delta)
|
||||
if pk.PredictionType == packet.PredictionTypeVehicle {
|
||||
io.Vec2(&pk.Rotation)
|
||||
if proto.IsProtoGTE(io, proto.ID712) {
|
||||
protocol.OptionalFunc(io, &pk.VehicleAngularVelocity, io.Float32)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
if pk.PredictionType == packet.PredictionTypeVehicle {
|
||||
io.Vec2(&pk.Rotation)
|
||||
if proto.IsProtoGTE(io, proto.ID712) {
|
||||
protocol.OptionalFunc(io, &pk.VehicleAngularVelocity, io.Float32)
|
||||
}
|
||||
}
|
||||
}
|
||||
io.Bool(&pk.OnGround)
|
||||
|
||||
@@ -44,9 +44,11 @@ func (pk *MobEffect) Marshal(io protocol.IO) {
|
||||
io.Varint32(&pk.Amplifier)
|
||||
io.Bool(&pk.Particles)
|
||||
io.Varint32(&pk.Duration)
|
||||
if proto.IsProtoGTE(io, proto.ID748) {
|
||||
io.Varuint64(&pk.Tick)
|
||||
} else {
|
||||
io.Uint64(&pk.Tick)
|
||||
if proto.IsProtoGTE(io, proto.ID662) {
|
||||
if proto.IsProtoGTE(io, proto.ID748) {
|
||||
io.Varuint64(&pk.Tick)
|
||||
} else {
|
||||
io.Uint64(&pk.Tick)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ func (pk *PlayerAuthInput) Marshal(io protocol.IO) {
|
||||
}
|
||||
|
||||
if pk.InputData.Load(packet.InputFlagClientPredictedVehicle) {
|
||||
io.Vec2(&pk.VehicleRotation)
|
||||
if proto.IsProtoGTE(io, proto.ID662) {
|
||||
io.Vec2(&pk.VehicleRotation)
|
||||
}
|
||||
io.Varint64(&pk.ClientPredictedVehicle)
|
||||
}
|
||||
|
||||
|
||||
52
legacyver/legacypacket/resource_pack_stack.go
Normal file
52
legacyver/legacypacket/resource_pack_stack.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs
|
||||
// should be applied (and downloaded) by the client.
|
||||
type ResourcePackStack struct {
|
||||
// TexturePackRequired specifies if the client must accept the texture packs the server has in order to
|
||||
// join the server. If set to true, the client gets the option to either download the resource packs and
|
||||
// join, or quit entirely. Behaviour packs never have to be downloaded.
|
||||
TexturePackRequired bool
|
||||
// BehaviourPack is a list of behaviour packs that the client needs to download before joining the server.
|
||||
// All of these behaviour packs will be applied together, and the order does not necessarily matter.
|
||||
BehaviourPacks []protocol.StackResourcePack
|
||||
// TexturePacks is a list of texture packs that the client needs to download before joining the server.
|
||||
// The order of these texture packs specifies the order that they are applied in on the client side. The
|
||||
// first in the list will be applied first.
|
||||
TexturePacks []protocol.StackResourcePack
|
||||
// BaseGameVersion is the vanilla version that the client should set its resource pack stack to.
|
||||
BaseGameVersion string
|
||||
// Experiments holds a list of experiments that are either enabled or disabled in the world that the
|
||||
// player spawns in.
|
||||
// It is not clear why experiments are sent both here and in the StartGame packet.
|
||||
Experiments []protocol.ExperimentData
|
||||
// ExperimentsPreviouslyToggled specifies if any experiments were previously toggled in this world. It is
|
||||
// probably used for some kind of metrics.
|
||||
ExperimentsPreviouslyToggled bool
|
||||
// IncludeEditorPacks specifies if vanilla editor packs should be included in the resource pack stack when
|
||||
// connecting to an editor world.
|
||||
IncludeEditorPacks bool
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*ResourcePackStack) ID() uint32 {
|
||||
return packet.IDResourcePackStack
|
||||
}
|
||||
|
||||
func (pk *ResourcePackStack) Marshal(io protocol.IO) {
|
||||
io.Bool(&pk.TexturePackRequired)
|
||||
protocol.Slice(io, &pk.BehaviourPacks)
|
||||
protocol.Slice(io, &pk.TexturePacks)
|
||||
io.String(&pk.BaseGameVersion)
|
||||
protocol.SliceUint32Length(io, &pk.Experiments)
|
||||
io.Bool(&pk.ExperimentsPreviouslyToggled)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
io.Bool(&pk.IncludeEditorPacks)
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,9 @@ func (*ResourcePacksInfo) ID() uint32 {
|
||||
|
||||
func (pk *ResourcePacksInfo) Marshal(io protocol.IO) {
|
||||
io.Bool(&pk.TexturePackRequired)
|
||||
io.Bool(&pk.HasAddons)
|
||||
if proto.IsProtoGTE(io, proto.ID662) {
|
||||
io.Bool(&pk.HasAddons)
|
||||
}
|
||||
io.Bool(&pk.HasScripts)
|
||||
if proto.IsProtoGTE(io, proto.ID766) {
|
||||
io.UUID(&pk.WorldTemplateUUID)
|
||||
|
||||
34
legacyver/legacypacket/set_actor_motion.go
Normal file
34
legacyver/legacypacket/set_actor_motion.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// SetActorMotion is sent by the server to change the client-side velocity of an entity. It is usually used
|
||||
// in combination with server-side movement calculation.
|
||||
type SetActorMotion struct {
|
||||
// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
|
||||
// entities are generally identified in packets using this runtime ID.
|
||||
EntityRuntimeID uint64
|
||||
// Velocity is the new velocity the entity gets. This velocity will initiate the client-side movement of
|
||||
// the entity.
|
||||
Velocity mgl32.Vec3
|
||||
// Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction.
|
||||
Tick uint64
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*SetActorMotion) ID() uint32 {
|
||||
return packet.IDSetActorMotion
|
||||
}
|
||||
|
||||
func (pk *SetActorMotion) Marshal(io protocol.IO) {
|
||||
io.Varuint64(&pk.EntityRuntimeID)
|
||||
io.Vec3(&pk.Velocity)
|
||||
if proto.IsProtoGTE(io, proto.ID662) {
|
||||
io.Varuint64(&pk.Tick)
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,9 @@ func (pk *StartGame) Marshal(io protocol.IO) {
|
||||
io.Varint32(&pk.Dimension)
|
||||
io.Varint32(&pk.Generator)
|
||||
io.Varint32(&pk.WorldGameMode)
|
||||
io.Bool(&pk.Hardcore)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
io.Bool(&pk.Hardcore)
|
||||
}
|
||||
io.Varint32(&pk.Difficulty)
|
||||
io.UBlockPos(&pk.WorldSpawn)
|
||||
io.Bool(&pk.AchievementsDisabled)
|
||||
|
||||
34
legacyver/legacypacket/update_player_game_type.go
Normal file
34
legacyver/legacypacket/update_player_game_type.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// UpdatePlayerGameType is sent by the server to change the game mode of a player. It is functionally
|
||||
// identical to the SetPlayerGameType packet.
|
||||
type UpdatePlayerGameType struct {
|
||||
// GameType is the new game type of the player. It is one of the constants that can be found in
|
||||
// set_player_game_type.go. Some of these game types require additional flags to be set in an
|
||||
// UpdateAbilities packet for the game mode to obtain its full functionality.
|
||||
GameType int32
|
||||
// PlayerUniqueID is the entity unique ID of the player that should have its game mode updated. If this
|
||||
// packet is sent to other clients with the player unique ID of another player, nothing happens.
|
||||
PlayerUniqueID int64
|
||||
// Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction.
|
||||
Tick uint64
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*UpdatePlayerGameType) ID() uint32 {
|
||||
return packet.IDUpdatePlayerGameType
|
||||
}
|
||||
|
||||
func (pk *UpdatePlayerGameType) Marshal(io protocol.IO) {
|
||||
io.Varint32(&pk.GameType)
|
||||
io.Varint64(&pk.PlayerUniqueID)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
io.Varuint64(&pk.Tick)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user