1.21.120 support
This commit is contained in:
@@ -21,6 +21,7 @@ var (
|
||||
// must be set to true if you're using Dragonfly.
|
||||
func All(dragonflyMapping bool) []minecraft.Protocol {
|
||||
return []minecraft.Protocol{
|
||||
New844(dragonflyMapping),
|
||||
New827(dragonflyMapping),
|
||||
New819(dragonflyMapping),
|
||||
New818(dragonflyMapping),
|
||||
|
||||
BIN
legacyver/data/block_states_859.nbt
Normal file
BIN
legacyver/data/block_states_859.nbt
Normal file
Binary file not shown.
9516
legacyver/data/required_item_list_859.json
Normal file
9516
legacyver/data/required_item_list_859.json
Normal file
File diff suppressed because it is too large
Load Diff
43
legacyver/legacypacket/animate.go
Normal file
43
legacyver/legacypacket/animate.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// Animate is sent by the server to send a player animation from one player to all viewers of that player. It
|
||||
// is used for a couple of actions, such as arm swimming and critical hits.
|
||||
type Animate struct {
|
||||
// ActionType is the ID of the animation action to execute. It is one of the action type constants that
|
||||
// may be found above.
|
||||
ActionType int32
|
||||
// EntityRuntimeID is the runtime ID of the player that the animation should be played upon. The runtime
|
||||
// ID is unique for each world session, and entities are generally identified in packets using this
|
||||
// runtime ID.
|
||||
EntityRuntimeID uint64
|
||||
// Data ...
|
||||
Data float32
|
||||
// RowingTime is the time for rowing actions.
|
||||
RowingTime float32
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*Animate) ID() uint32 {
|
||||
return packet.IDAnimate
|
||||
}
|
||||
|
||||
func (pk *Animate) Marshal(io protocol.IO) {
|
||||
io.Varint32(&pk.ActionType)
|
||||
io.Varuint64(&pk.EntityRuntimeID)
|
||||
if proto.IsProtoGTE(io, proto.ID859) {
|
||||
io.Float32(&pk.Data)
|
||||
if pk.ActionType == packet.AnimateActionRowLeft || pk.ActionType == packet.AnimateActionRowRight {
|
||||
io.Float32(&pk.RowingTime)
|
||||
}
|
||||
} else {
|
||||
if pk.ActionType&0x80 != 0 {
|
||||
io.Float32(&pk.RowingTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,12 @@ type CameraInstruction struct {
|
||||
RemoveTarget protocol.Optional[bool]
|
||||
// FieldOfView is a camera instruction that updates the field of view for the camera.
|
||||
FieldOfView protocol.Optional[protocol.CameraInstructionFieldOfView]
|
||||
// Spline is a camera instruction that creates a spline path for the camera to follow.
|
||||
Spline protocol.Optional[protocol.CameraSplineInstruction]
|
||||
// AttachToEntity is the entity ID to attach the camera to.
|
||||
AttachToEntity protocol.Optional[int64]
|
||||
// DetachFromEntity can be set to true to detach the camera from the current entity.
|
||||
DetachFromEntity protocol.Optional[bool]
|
||||
}
|
||||
|
||||
// ID ...
|
||||
@@ -38,4 +44,9 @@ func (pk *CameraInstruction) Marshal(io protocol.IO) {
|
||||
if proto.IsProtoGTE(io, proto.ID827) {
|
||||
protocol.OptionalMarshaler(io, &pk.FieldOfView)
|
||||
}
|
||||
if proto.IsProtoGTE(io, proto.ID859) {
|
||||
protocol.OptionalMarshaler(io, &pk.Spline)
|
||||
protocol.OptionalFunc(io, &pk.AttachToEntity, io.Int64)
|
||||
protocol.OptionalFunc(io, &pk.DetachFromEntity, io.Bool)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ type CommandBlockUpdate struct {
|
||||
ShouldTrackOutput bool
|
||||
// TickDelay is the delay in ticks between executions of a command block, if it is a repeating command
|
||||
// block.
|
||||
TickDelay int32
|
||||
TickDelay uint32
|
||||
// ExecuteOnFirstTick specifies if the command block should execute on the first tick, AKA as soon as the
|
||||
// command block is enabled.
|
||||
ExecuteOnFirstTick bool
|
||||
@@ -83,6 +83,6 @@ func (pk *CommandBlockUpdate) Marshal(io protocol.IO) {
|
||||
io.String(&pk.FilteredName)
|
||||
}
|
||||
io.Bool(&pk.ShouldTrackOutput)
|
||||
io.Int32(&pk.TickDelay)
|
||||
io.Uint32(&pk.TickDelay)
|
||||
io.Bool(&pk.ExecuteOnFirstTick)
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ type StartGame struct {
|
||||
EducationSharedResourceURI protocol.EducationSharedResourceURI
|
||||
// ForceExperimentalGameplay specifies if experimental gameplay should be force enabled. For servers this
|
||||
// should always be set to false.
|
||||
ForceExperimentalGameplay protocol.Optional[bool]
|
||||
ForceExperimentalGameplay bool
|
||||
// LevelID is a base64 encoded world ID that is used to identify the world.
|
||||
LevelID string
|
||||
// WorldName is the name of the world that the player is joining. Note that this field shows up above the
|
||||
@@ -306,7 +306,7 @@ func (pk *StartGame) Marshal(io protocol.IO) {
|
||||
io.Int32(&pk.LimitedWorldDepth)
|
||||
io.Bool(&pk.NewNether)
|
||||
protocol.Single(io, &pk.EducationSharedResourceURI)
|
||||
protocol.OptionalFunc(io, &pk.ForceExperimentalGameplay, io.Bool)
|
||||
io.Bool(&pk.ForceExperimentalGameplay)
|
||||
io.Uint8(&pk.ChatRestrictionLevel)
|
||||
io.Bool(&pk.DisablePlayerInteractions)
|
||||
if proto.IsProtoGTE(io, proto.ID685) {
|
||||
|
||||
@@ -37,7 +37,7 @@ type BiomeDefinition struct {
|
||||
// ChunkGeneration is optional information to assist in client-side chunk generation. Almost all servers
|
||||
// can and should leave this empty to greatly reduce the size of this packet. Only BDS and servers which
|
||||
// *exactly* match the vanilla chunk generation can benefit from this.
|
||||
ChunkGeneration protocol.Optional[protocol.BiomeChunkGeneration]
|
||||
ChunkGeneration protocol.Optional[BiomeChunkGeneration]
|
||||
}
|
||||
|
||||
func (x *BiomeDefinition) Marshal(r protocol.IO) {
|
||||
@@ -88,12 +88,14 @@ func (x *BiomeDefinition) FromLatest(bd protocol.BiomeDefinition) BiomeDefinitio
|
||||
x.MapWaterColour = bd.MapWaterColour
|
||||
x.Rain = bd.Rain
|
||||
x.Tags = bd.Tags
|
||||
x.ChunkGeneration = bd.ChunkGeneration
|
||||
if v, ok := bd.ChunkGeneration.Value(); ok {
|
||||
x.ChunkGeneration = protocol.Option((&BiomeChunkGeneration{}).FromLatest(v))
|
||||
}
|
||||
return *x
|
||||
}
|
||||
|
||||
func (x *BiomeDefinition) ToLatest() protocol.BiomeDefinition {
|
||||
return protocol.BiomeDefinition{
|
||||
ret := protocol.BiomeDefinition{
|
||||
NameIndex: x.NameIndex,
|
||||
BiomeID: x.BiomeID,
|
||||
Temperature: x.Temperature,
|
||||
@@ -102,12 +104,118 @@ func (x *BiomeDefinition) ToLatest() protocol.BiomeDefinition {
|
||||
//BlueSporeDensity: x.BlueSporeDensity,
|
||||
//AshDensity: x.AshDensity,
|
||||
//WhiteAshDensity: x.WhiteAshDensity,
|
||||
FoliageSnow: x.FoliageSnow,
|
||||
Depth: x.Depth,
|
||||
Scale: x.Scale,
|
||||
MapWaterColour: x.MapWaterColour,
|
||||
Rain: x.Rain,
|
||||
Tags: x.Tags,
|
||||
ChunkGeneration: x.ChunkGeneration,
|
||||
FoliageSnow: x.FoliageSnow,
|
||||
Depth: x.Depth,
|
||||
Scale: x.Scale,
|
||||
MapWaterColour: x.MapWaterColour,
|
||||
Rain: x.Rain,
|
||||
Tags: x.Tags,
|
||||
}
|
||||
if v, ok := x.ChunkGeneration.Value(); ok {
|
||||
ret.ChunkGeneration = protocol.Option(v.ToLatest())
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// BiomeChunkGeneration represents the information required for the client to generate chunks itself
|
||||
// to create the illusion of a larger render distance.
|
||||
type BiomeChunkGeneration struct {
|
||||
// Climate is optional information to specify the biome's climate.
|
||||
Climate protocol.Optional[protocol.BiomeClimate]
|
||||
// ConsolidatedFeatures is a list of features that are consolidated into a single feature.
|
||||
ConsolidatedFeatures protocol.Optional[[]protocol.BiomeConsolidatedFeature]
|
||||
// MountainParameters is optional information to specify the biome's mountain parameters.
|
||||
MountainParameters protocol.Optional[protocol.BiomeMountainParameters]
|
||||
// SurfaceMaterialAdjustments is a list of surface material adjustments.
|
||||
SurfaceMaterialAdjustments protocol.Optional[[]protocol.BiomeElementData]
|
||||
// SurfaceMaterials is a set of materials to use for the surface layers of the biome.
|
||||
SurfaceMaterials protocol.Optional[protocol.BiomeSurfaceMaterial]
|
||||
// HasDefaultOverworldSurface is true if the biome has a default overworld surface.
|
||||
HasDefaultOverworldSurface bool
|
||||
// HasSwampSurface is true if the biome has a swamp surface.
|
||||
HasSwampSurface bool
|
||||
// HasFrozenOceanSurface is true if the biome has a frozen ocean surface.
|
||||
HasFrozenOceanSurface bool
|
||||
// HasEndSurface is true if the biome has an end surface.
|
||||
HasEndSurface bool
|
||||
// MesaSurface is optional information to specify the biome's mesa surface.
|
||||
MesaSurface protocol.Optional[protocol.BiomeMesaSurface]
|
||||
// CappedSurface is optional information to specify the biome's capped surface, i.e. in the Nether.
|
||||
CappedSurface protocol.Optional[protocol.BiomeCappedSurface]
|
||||
// OverworldRules is optional information to specify the biome's overworld rules, such as rivers and hills.
|
||||
OverworldRules protocol.Optional[protocol.BiomeOverworldRules]
|
||||
// MultiNoiseRules is optional information to specify the biome's multi-noise rules.
|
||||
MultiNoiseRules protocol.Optional[protocol.BiomeMultiNoiseRules]
|
||||
// LegacyRules is a list of legacy rules for the biomes using an older format, which is just a list of
|
||||
// weighted biomes.
|
||||
LegacyRules protocol.Optional[[]protocol.BiomeConditionalTransformation]
|
||||
// ReplacementsData is a list of biome replacement data.
|
||||
ReplacementsData protocol.Optional[[]protocol.BiomeReplacementData]
|
||||
}
|
||||
|
||||
func (x *BiomeChunkGeneration) Marshal(r protocol.IO) {
|
||||
protocol.OptionalMarshaler(r, &x.Climate)
|
||||
protocol.OptionalFunc(r, &x.ConsolidatedFeatures, func(s *[]protocol.BiomeConsolidatedFeature) {
|
||||
protocol.Slice(r, s)
|
||||
})
|
||||
protocol.OptionalMarshaler(r, &x.MountainParameters)
|
||||
protocol.OptionalFunc(r, &x.SurfaceMaterialAdjustments, func(s *[]protocol.BiomeElementData) {
|
||||
protocol.Slice(r, s)
|
||||
})
|
||||
protocol.OptionalMarshaler(r, &x.SurfaceMaterials)
|
||||
r.Bool(&x.HasDefaultOverworldSurface)
|
||||
r.Bool(&x.HasSwampSurface)
|
||||
r.Bool(&x.HasFrozenOceanSurface)
|
||||
r.Bool(&x.HasEndSurface)
|
||||
protocol.OptionalMarshaler(r, &x.MesaSurface)
|
||||
protocol.OptionalMarshaler(r, &x.CappedSurface)
|
||||
protocol.OptionalMarshaler(r, &x.OverworldRules)
|
||||
protocol.OptionalMarshaler(r, &x.MultiNoiseRules)
|
||||
protocol.OptionalFunc(r, &x.LegacyRules, func(s *[]protocol.BiomeConditionalTransformation) {
|
||||
protocol.Slice(r, s)
|
||||
})
|
||||
if IsProtoGTE(r, ID859) {
|
||||
protocol.OptionalFunc(r, &x.ReplacementsData, func(s *[]protocol.BiomeReplacementData) {
|
||||
protocol.Slice(r, s)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (x *BiomeChunkGeneration) FromLatest(bcg protocol.BiomeChunkGeneration) BiomeChunkGeneration {
|
||||
x.Climate = bcg.Climate
|
||||
x.ConsolidatedFeatures = bcg.ConsolidatedFeatures
|
||||
x.MountainParameters = bcg.MountainParameters
|
||||
x.SurfaceMaterialAdjustments = bcg.SurfaceMaterialAdjustments
|
||||
x.SurfaceMaterials = bcg.SurfaceMaterials
|
||||
x.HasDefaultOverworldSurface = bcg.HasDefaultOverworldSurface
|
||||
x.HasSwampSurface = bcg.HasSwampSurface
|
||||
x.HasFrozenOceanSurface = bcg.HasFrozenOceanSurface
|
||||
x.HasEndSurface = bcg.HasEndSurface
|
||||
x.MesaSurface = bcg.MesaSurface
|
||||
x.CappedSurface = bcg.CappedSurface
|
||||
x.OverworldRules = bcg.OverworldRules
|
||||
x.MultiNoiseRules = bcg.MultiNoiseRules
|
||||
x.LegacyRules = bcg.LegacyRules
|
||||
x.ReplacementsData = bcg.ReplacementsData
|
||||
return *x
|
||||
}
|
||||
|
||||
func (x *BiomeChunkGeneration) ToLatest() protocol.BiomeChunkGeneration {
|
||||
return protocol.BiomeChunkGeneration{
|
||||
Climate: x.Climate,
|
||||
ConsolidatedFeatures: x.ConsolidatedFeatures,
|
||||
MountainParameters: x.MountainParameters,
|
||||
SurfaceMaterialAdjustments: x.SurfaceMaterialAdjustments,
|
||||
SurfaceMaterials: x.SurfaceMaterials,
|
||||
HasDefaultOverworldSurface: x.HasDefaultOverworldSurface,
|
||||
HasSwampSurface: x.HasSwampSurface,
|
||||
HasFrozenOceanSurface: x.HasFrozenOceanSurface,
|
||||
HasEndSurface: x.HasEndSurface,
|
||||
MesaSurface: x.MesaSurface,
|
||||
CappedSurface: x.CappedSurface,
|
||||
OverworldRules: x.OverworldRules,
|
||||
MultiNoiseRules: x.MultiNoiseRules,
|
||||
LegacyRules: x.LegacyRules,
|
||||
ReplacementsData: x.ReplacementsData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package proto
|
||||
import "github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
|
||||
const (
|
||||
ID859 = 859 // v1.21.120
|
||||
ID844 = 844 // v1.21.110
|
||||
ID827 = 827 // v1.21.100
|
||||
ID819 = 819 // v1.21.93
|
||||
|
||||
@@ -129,6 +129,8 @@ func convertPacketFunc(pid uint32, cur func() packet.Packet) func() packet.Packe
|
||||
return func() packet.Packet { return &legacypacket.SubChunk{} }
|
||||
case packet.IDGameRulesChanged:
|
||||
return func() packet.Packet { return &legacypacket.GameRulesChanged{} }
|
||||
case packet.IDAnimate:
|
||||
return func() packet.Packet { return &legacypacket.Animate{} }
|
||||
default:
|
||||
return cur
|
||||
}
|
||||
@@ -391,12 +393,15 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
iSet = protocol.Option((&proto.CameraInstructionSet{}).FromLatest(v))
|
||||
}
|
||||
pks[pkIndex] = &legacypacket.CameraInstruction{
|
||||
Set: iSet,
|
||||
Clear: pk.Clear,
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
Set: iSet,
|
||||
Clear: pk.Clear,
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
Spline: pk.Spline,
|
||||
AttachToEntity: pk.AttachToEntity,
|
||||
DetachFromEntity: pk.DetachFromEntity,
|
||||
}
|
||||
case *packet.ChangeDimension:
|
||||
pks[pkIndex] = &legacypacket.ChangeDimension{
|
||||
@@ -754,6 +759,13 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
pks[pkIndex] = &legacypacket.GameRulesChanged{
|
||||
GameRules: pk.GameRules,
|
||||
}
|
||||
case *packet.Animate:
|
||||
pks[pkIndex] = &legacypacket.Animate{
|
||||
ActionType: pk.ActionType,
|
||||
EntityRuntimeID: pk.EntityRuntimeID,
|
||||
Data: pk.Data,
|
||||
RowingTime: pk.RowingTime,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,12 +983,15 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
iSet = protocol.Option(v.ToLatest())
|
||||
}
|
||||
pks[pkIndex] = &packet.CameraInstruction{
|
||||
Set: iSet,
|
||||
Clear: pk.Clear,
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
Set: iSet,
|
||||
Clear: pk.Clear,
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
Spline: pk.Spline,
|
||||
AttachToEntity: pk.AttachToEntity,
|
||||
DetachFromEntity: pk.DetachFromEntity,
|
||||
}
|
||||
case *legacypacket.ChangeDimension:
|
||||
pks[pkIndex] = &packet.ChangeDimension{
|
||||
@@ -1296,6 +1311,13 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
pks[pkIndex] = &packet.GameRulesChanged{
|
||||
GameRules: pk.GameRules,
|
||||
}
|
||||
case *legacypacket.Animate:
|
||||
pks[pkIndex] = &packet.Animate{
|
||||
ActionType: pk.ActionType,
|
||||
EntityRuntimeID: pk.EntityRuntimeID,
|
||||
Data: pk.Data,
|
||||
RowingTime: pk.RowingTime,
|
||||
}
|
||||
}
|
||||
}
|
||||
return pks
|
||||
|
||||
@@ -3,6 +3,7 @@ package legacyver
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
)
|
||||
|
||||
@@ -10,25 +11,23 @@ const (
|
||||
// ItemVersion844 ...
|
||||
ItemVersion844 = 241
|
||||
// BlockVersion844 ...
|
||||
BlockVersion844 int32 = (1 << 24) | (21 << 16) | (110 << 8)
|
||||
BlockVersion844 int32 = (1 << 24) | (21 << 16) | (111 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/dragonfly_items.json
|
||||
dragonflyLatestItemList []byte
|
||||
//go:embed data/required_item_list_844.json
|
||||
requiredItemList844 []byte
|
||||
//go:embed data/block_states_844.nbt
|
||||
blockStateData844 []byte
|
||||
|
||||
itemMappingLatestPocketMine = mapping.NewItemMapping(requiredItemList844, ItemVersion844)
|
||||
itemMappingLatestDragonfly = mapping.NewItemMapping(dragonflyLatestItemList, ItemVersion844)
|
||||
blockMappingLatest = mapping.NewBlockMapping(blockStateData844)
|
||||
)
|
||||
|
||||
func itemMappingLatest(dragonflyMapping bool) mapping.Item {
|
||||
if dragonflyMapping {
|
||||
return itemMappingLatestDragonfly
|
||||
func New844(dragonflyMapping bool) *Protocol {
|
||||
itemMapping := mapping.NewItemMapping(requiredItemList844, ItemVersion844)
|
||||
blockTranslator := lookupOrCreateBlockTranslator(844, BlockVersion844, blockStateData844)
|
||||
return &Protocol{
|
||||
ver: "1.21.111",
|
||||
id: proto.ID844,
|
||||
blockTranslator: blockTranslator,
|
||||
itemTranslator: NewItemTranslator(itemMapping, itemMappingLatest(dragonflyMapping), blockTranslator.BlockMapping(), blockMappingLatest),
|
||||
}
|
||||
return itemMappingLatestPocketMine
|
||||
}
|
||||
|
||||
34
legacyver/v859.go
Normal file
34
legacyver/v859.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
)
|
||||
|
||||
const (
|
||||
// ItemVersion859 ...
|
||||
ItemVersion859 = 241
|
||||
// BlockVersion859 ...
|
||||
BlockVersion859 int32 = (1 << 24) | (21 << 16) | (120 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/dragonfly_items.json
|
||||
dragonflyLatestItemList []byte
|
||||
//go:embed data/required_item_list_859.json
|
||||
requiredItemList859 []byte
|
||||
//go:embed data/block_states_859.nbt
|
||||
blockStateData859 []byte
|
||||
|
||||
itemMappingLatestPocketMine = mapping.NewItemMapping(requiredItemList859, ItemVersion859)
|
||||
itemMappingLatestDragonfly = mapping.NewItemMapping(dragonflyLatestItemList, ItemVersion859)
|
||||
blockMappingLatest = mapping.NewBlockMapping(blockStateData859)
|
||||
)
|
||||
|
||||
func itemMappingLatest(dragonflyMapping bool) mapping.Item {
|
||||
if dragonflyMapping {
|
||||
return itemMappingLatestDragonfly
|
||||
}
|
||||
return itemMappingLatestPocketMine
|
||||
}
|
||||
Reference in New Issue
Block a user