Add 1.20.70 & 1.20.60 support + Fix crafting issue (#9)
This commit is contained in:
@@ -13,5 +13,7 @@ func All() []minecraft.Protocol {
|
||||
New686(),
|
||||
New685(),
|
||||
New671(),
|
||||
New662(),
|
||||
New649(),
|
||||
}
|
||||
}
|
||||
|
||||
BIN
legacyver/data/block_states_649.nbt
Normal file
BIN
legacyver/data/block_states_649.nbt
Normal file
Binary file not shown.
BIN
legacyver/data/block_states_662.nbt
Normal file
BIN
legacyver/data/block_states_662.nbt
Normal file
Binary file not shown.
5998
legacyver/data/required_item_list_649.json
Normal file
5998
legacyver/data/required_item_list_649.json
Normal file
File diff suppressed because it is too large
Load Diff
6126
legacyver/data/required_item_list_662.json
Normal file
6126
legacyver/data/required_item_list_662.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ const (
|
||||
ID686 = 686 // v1.21.2
|
||||
ID685 = 685 // v1.21.0
|
||||
ID671 = 671 // v1.20.80
|
||||
ID662 = 662 // v1.20.70
|
||||
ID649 = 649 // v1.20.60
|
||||
)
|
||||
|
||||
func IsProtoGTE(io protocol.IO, proto int32) bool {
|
||||
|
||||
@@ -808,9 +808,13 @@ func (a *CraftRecipeStackRequestAction) FromLatest(y *protocol.CraftRecipeStackR
|
||||
}
|
||||
|
||||
func (a *CraftRecipeStackRequestAction) ToLatest() *protocol.CraftRecipeStackRequestAction {
|
||||
numberOfCrafts := a.NumberOfCrafts
|
||||
if numberOfCrafts == 0 {
|
||||
numberOfCrafts = 1
|
||||
}
|
||||
return &protocol.CraftRecipeStackRequestAction{
|
||||
RecipeNetworkID: a.RecipeNetworkID,
|
||||
NumberOfCrafts: a.NumberOfCrafts,
|
||||
NumberOfCrafts: numberOfCrafts,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -677,7 +677,9 @@ func marshalShaped(r protocol.IO, recipe *ShapedRecipe) {
|
||||
r.UUID(&recipe.UUID)
|
||||
r.String(&recipe.Block)
|
||||
r.Varint32(&recipe.Priority)
|
||||
r.Bool(&recipe.AssumeSymmetry)
|
||||
if IsProtoGTE(r, ID671) {
|
||||
r.Bool(&recipe.AssumeSymmetry)
|
||||
}
|
||||
if IsProtoGTE(r, ID685) {
|
||||
protocol.Single(r, &recipe.UnlockRequirement)
|
||||
}
|
||||
|
||||
@@ -132,5 +132,7 @@ func (x *BehaviourPackInfo) Marshal(r protocol.IO) {
|
||||
r.String(&x.SubPackName)
|
||||
r.String(&x.ContentIdentity)
|
||||
r.Bool(&x.HasScripts)
|
||||
r.Bool(&x.AddonPack)
|
||||
if IsProtoGTE(r, ID712) {
|
||||
r.Bool(&x.AddonPack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,12 @@ func convertPacketFunc(pid uint32, cur func() packet.Packet) func() packet.Packe
|
||||
return func() packet.Packet { return &legacypacket.LevelSoundEvent{} }
|
||||
case packet.IDSetHud:
|
||||
return func() packet.Packet { return &legacypacket.SetHud{} }
|
||||
case packet.IDResourcePackStack:
|
||||
return func() packet.Packet { return &legacypacket.ResourcePackStack{} }
|
||||
case packet.IDUpdatePlayerGameType:
|
||||
return func() packet.Packet { return &legacypacket.UpdatePlayerGameType{} }
|
||||
case packet.IDSetActorMotion:
|
||||
return func() packet.Packet { return &legacypacket.SetActorMotion{} }
|
||||
default:
|
||||
return cur
|
||||
}
|
||||
@@ -167,6 +173,28 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
switch pk := pk.(type) {
|
||||
case *packet.ClientCacheStatus:
|
||||
pk.Enabled = false // TODO: enable when chunk translation is not broken
|
||||
case *packet.SetActorMotion:
|
||||
pks[pkIndex] = &legacypacket.SetActorMotion{
|
||||
EntityRuntimeID: pk.EntityRuntimeID,
|
||||
Velocity: pk.Velocity,
|
||||
Tick: pk.Tick,
|
||||
}
|
||||
case *packet.ResourcePackStack:
|
||||
pks[pkIndex] = &legacypacket.ResourcePackStack{
|
||||
TexturePackRequired: pk.TexturePackRequired,
|
||||
BehaviourPacks: pk.BehaviourPacks,
|
||||
TexturePacks: pk.TexturePacks,
|
||||
BaseGameVersion: pk.BaseGameVersion,
|
||||
Experiments: pk.Experiments,
|
||||
ExperimentsPreviouslyToggled: pk.ExperimentsPreviouslyToggled,
|
||||
IncludeEditorPacks: pk.IncludeEditorPacks,
|
||||
}
|
||||
case *packet.UpdatePlayerGameType:
|
||||
pks[pkIndex] = &legacypacket.UpdatePlayerGameType{
|
||||
GameType: pk.GameType,
|
||||
PlayerUniqueID: pk.PlayerUniqueID,
|
||||
Tick: pk.Tick,
|
||||
}
|
||||
case *packet.CameraPresets:
|
||||
presets := make([]proto.CameraPreset, len(pk.Presets))
|
||||
for i, p := range pk.Presets {
|
||||
@@ -691,6 +719,28 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
switch pk := pk.(type) {
|
||||
case *packet.ClientCacheStatus:
|
||||
pk.Enabled = false // TODO: enable when chunk translation is not broken
|
||||
case *legacypacket.SetActorMotion:
|
||||
pks[pkIndex] = &packet.SetActorMotion{
|
||||
EntityRuntimeID: pk.EntityRuntimeID,
|
||||
Velocity: pk.Velocity,
|
||||
Tick: pk.Tick,
|
||||
}
|
||||
case *legacypacket.ResourcePackStack:
|
||||
pks[pkIndex] = &packet.ResourcePackStack{
|
||||
TexturePackRequired: pk.TexturePackRequired,
|
||||
BehaviourPacks: pk.BehaviourPacks,
|
||||
TexturePacks: pk.TexturePacks,
|
||||
BaseGameVersion: pk.BaseGameVersion,
|
||||
Experiments: pk.Experiments,
|
||||
ExperimentsPreviouslyToggled: pk.ExperimentsPreviouslyToggled,
|
||||
IncludeEditorPacks: pk.IncludeEditorPacks,
|
||||
}
|
||||
case *legacypacket.UpdatePlayerGameType:
|
||||
pks[pkIndex] = &packet.UpdatePlayerGameType{
|
||||
GameType: pk.GameType,
|
||||
PlayerUniqueID: pk.PlayerUniqueID,
|
||||
Tick: pk.Tick,
|
||||
}
|
||||
case *legacypacket.CameraPresets:
|
||||
presets := make([]protocol.CameraPreset, len(pk.Presets))
|
||||
for i, p := range pk.Presets {
|
||||
|
||||
35
legacyver/v649.go
Normal file
35
legacyver/v649.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
)
|
||||
|
||||
const (
|
||||
// ItemVersion649 ...
|
||||
ItemVersion649 = 161
|
||||
// BlockVersion649 ...
|
||||
BlockVersion649 int32 = (1 << 24) | (20 << 16) | (60 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/required_item_list_649.json
|
||||
requiredItemList649 []byte
|
||||
//go:embed data/block_states_649.nbt
|
||||
blockStateData649 []byte
|
||||
)
|
||||
|
||||
// New649 ...
|
||||
func New649() *Protocol {
|
||||
itemMapping := mapping.NewItemMapping(requiredItemList649, ItemVersion649)
|
||||
blockMapping := mapping.NewBlockMapping(blockStateData649)
|
||||
|
||||
return &Protocol{
|
||||
ver: "1.20.60",
|
||||
id: proto.ID649,
|
||||
blockTranslator: NewBlockTranslator(blockMapping, blockMappingLatest, chunk.NewNetworkPersistentEncoding(blockMapping, BlockVersion649), chunk.NewBlockPaletteEncoding(blockMapping, BlockVersion649), false),
|
||||
itemTranslator: NewItemTranslator(itemMapping, itemMappingLatest, blockMapping, blockMappingLatest),
|
||||
}
|
||||
}
|
||||
35
legacyver/v662.go
Normal file
35
legacyver/v662.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
)
|
||||
|
||||
const (
|
||||
// ItemVersion662 ...
|
||||
ItemVersion662 = 171
|
||||
// BlockVersion662 ...
|
||||
BlockVersion662 int32 = (1 << 24) | (20 << 16) | (70 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/required_item_list_662.json
|
||||
requiredItemList662 []byte
|
||||
//go:embed data/block_states_662.nbt
|
||||
blockStateData662 []byte
|
||||
)
|
||||
|
||||
// New662 ...
|
||||
func New662() *Protocol {
|
||||
itemMapping := mapping.NewItemMapping(requiredItemList662, ItemVersion662)
|
||||
blockMapping := mapping.NewBlockMapping(blockStateData662)
|
||||
|
||||
return &Protocol{
|
||||
ver: "1.20.70",
|
||||
id: proto.ID662,
|
||||
blockTranslator: NewBlockTranslator(blockMapping, blockMappingLatest, chunk.NewNetworkPersistentEncoding(blockMapping, BlockVersion662), chunk.NewBlockPaletteEncoding(blockMapping, BlockVersion662), false),
|
||||
itemTranslator: NewItemTranslator(itemMapping, itemMappingLatest, blockMapping, blockMappingLatest),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user