Add support for protocol version 1.21.100 (#12)
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
// must be set to true if you're using Dragonfly.
|
||||
func All(dragonflyMapping bool) []minecraft.Protocol {
|
||||
return []minecraft.Protocol{
|
||||
New819(dragonflyMapping),
|
||||
New818(dragonflyMapping),
|
||||
New800(dragonflyMapping),
|
||||
New786(dragonflyMapping),
|
||||
|
||||
@@ -3,6 +3,8 @@ package legacyver
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal"
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
"github.com/df-mc/dragonfly/server/block/cube"
|
||||
@@ -43,62 +45,69 @@ func NewBlockTranslator(mapping mapping.Block, latestMapping mapping.Block, pse
|
||||
return &DefaultBlockTranslator{mapping: mapping, latest: latestMapping, pse: pse, pe: pe, oldFormat: oldFormat}
|
||||
}
|
||||
|
||||
func (t *DefaultBlockTranslator) downgradeLevelChunkPacket(pk *packet.LevelChunk) error {
|
||||
count := int(pk.SubChunkCount)
|
||||
if count == protocol.SubChunkRequestModeLimitless || count == protocol.SubChunkRequestModeLimited {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(pk.RawPayload)
|
||||
writeBuf := internal.BufferPool.Get().(*bytes.Buffer)
|
||||
defer func() {
|
||||
writeBuf.Reset()
|
||||
internal.BufferPool.Put(writeBuf)
|
||||
}()
|
||||
if !pk.CacheEnabled {
|
||||
c, err := chunk.NetworkDecode(t.latest.Air(), buf, count, false, world.Overworld.Range(), LatestNetworkPersistentEncoding, LatestBlockPaletteEncoding)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c = t.DowngradeChunk(c)
|
||||
|
||||
payload, err := chunk.NetworkEncode(t.mapping.Air(), c, t.oldFormat, t.pe)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
writeBuf.Write(payload)
|
||||
pk.SubChunkCount = uint32(len(c.Sub()))
|
||||
}
|
||||
safeBytes := buf.Bytes()
|
||||
|
||||
countBorder, err := buf.ReadByte()
|
||||
if err != nil {
|
||||
pk.RawPayload = append(writeBuf.Bytes(), safeBytes...)
|
||||
return nil
|
||||
}
|
||||
borderBytes := make([]byte, countBorder)
|
||||
if _, err = buf.Read(borderBytes); err != nil {
|
||||
pk.RawPayload = append(writeBuf.Bytes(), safeBytes...)
|
||||
return nil
|
||||
}
|
||||
writeBuf.WriteByte(countBorder)
|
||||
writeBuf.Write(borderBytes)
|
||||
|
||||
enc := nbt.NewEncoderWithEncoding(writeBuf, nbt.NetworkLittleEndian)
|
||||
dec := nbt.NewDecoderWithEncoding(buf, nbt.NetworkLittleEndian)
|
||||
for {
|
||||
var decNbt map[string]any
|
||||
if err = dec.Decode(&decNbt); err != nil {
|
||||
break
|
||||
}
|
||||
t.mapping.DowngradeBlockActorData(decNbt)
|
||||
|
||||
if err = enc.Encode(decNbt); err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
pk.RawPayload = append(writeBuf.Bytes(), buf.Bytes()...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *DefaultBlockTranslator) DowngradeBlockPackets(pks []packet.Packet, conn *minecraft.Conn) (result []packet.Packet) {
|
||||
for _, pk := range pks {
|
||||
switch pk := pk.(type) {
|
||||
case *packet.LevelChunk:
|
||||
count := int(pk.SubChunkCount)
|
||||
if count == protocol.SubChunkRequestModeLimitless || count == protocol.SubChunkRequestModeLimited {
|
||||
break
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(pk.RawPayload)
|
||||
writeBuf := bytes.NewBuffer(nil)
|
||||
if !pk.CacheEnabled {
|
||||
c, err := chunk.NetworkDecode(t.latest.Air(), buf, count, false, world.Overworld.Range(), LatestNetworkPersistentEncoding, LatestBlockPaletteEncoding)
|
||||
if err != nil {
|
||||
//fmt.Println(err)
|
||||
break
|
||||
}
|
||||
c = t.DowngradeChunk(c)
|
||||
|
||||
payload, err := chunk.NetworkEncode(t.mapping.Air(), c, t.oldFormat, t.pe)
|
||||
if err != nil {
|
||||
//fmt.Println(err)
|
||||
break
|
||||
}
|
||||
writeBuf.Write(payload)
|
||||
pk.SubChunkCount = uint32(len(c.Sub()))
|
||||
}
|
||||
safeBytes := buf.Bytes()
|
||||
|
||||
countBorder, err := buf.ReadByte()
|
||||
if err != nil {
|
||||
pk.RawPayload = append(writeBuf.Bytes(), safeBytes...)
|
||||
break
|
||||
}
|
||||
borderBytes := make([]byte, countBorder)
|
||||
if _, err = buf.Read(borderBytes); err != nil {
|
||||
pk.RawPayload = append(writeBuf.Bytes(), safeBytes...)
|
||||
break
|
||||
}
|
||||
writeBuf.WriteByte(countBorder)
|
||||
writeBuf.Write(borderBytes)
|
||||
|
||||
enc := nbt.NewEncoderWithEncoding(writeBuf, nbt.NetworkLittleEndian)
|
||||
dec := nbt.NewDecoderWithEncoding(buf, nbt.NetworkLittleEndian)
|
||||
for {
|
||||
var decNbt map[string]any
|
||||
if err = dec.Decode(&decNbt); err != nil {
|
||||
break
|
||||
}
|
||||
t.mapping.DowngradeBlockActorData(decNbt)
|
||||
|
||||
if err = enc.Encode(decNbt); err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
pk.RawPayload = append(writeBuf.Bytes(), buf.Bytes()...)
|
||||
_ = t.downgradeLevelChunkPacket(pk)
|
||||
case *packet.SubChunk:
|
||||
r := world.Overworld.Range()
|
||||
if t.oldFormat {
|
||||
@@ -247,11 +256,11 @@ func (t *DefaultBlockTranslator) DowngradeBlockRuntimeID(input uint32) uint32 {
|
||||
}
|
||||
state, ok := t.latest.RuntimeIDToState(input)
|
||||
if !ok {
|
||||
return t.mapping.Air()
|
||||
return t.mapping.InfoUpdate()
|
||||
}
|
||||
runtimeID, ok := t.mapping.StateToRuntimeID(state)
|
||||
if !ok {
|
||||
return t.mapping.Air()
|
||||
return t.mapping.InfoUpdate()
|
||||
}
|
||||
return runtimeID
|
||||
}
|
||||
@@ -315,11 +324,11 @@ func (t *DefaultBlockTranslator) UpgradeBlockRuntimeID(input uint32) uint32 {
|
||||
}
|
||||
state, ok := t.mapping.RuntimeIDToState(input)
|
||||
if !ok {
|
||||
return t.latest.Air()
|
||||
return t.latest.InfoUpdate()
|
||||
}
|
||||
runtimeID, ok := t.latest.StateToRuntimeID(state)
|
||||
if !ok {
|
||||
return t.latest.Air()
|
||||
return t.latest.InfoUpdate()
|
||||
}
|
||||
return runtimeID
|
||||
}
|
||||
|
||||
BIN
legacyver/data/block_states_827.nbt
Normal file
BIN
legacyver/data/block_states_827.nbt
Normal file
Binary file not shown.
9256
legacyver/data/required_item_list_827.json
Normal file
9256
legacyver/data/required_item_list_827.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/item"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacypacket
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/samber/lo"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
// accurately recreate the server-side generation in vanilla worlds/servers for increased performance.
|
||||
type BiomeDefinitionList struct {
|
||||
// BiomeDefinitions is a list of biomes that are available on the server.
|
||||
BiomeDefinitions []protocol.BiomeDefinition
|
||||
BiomeDefinitions []proto.BiomeDefinition
|
||||
// StringList is a makeshift dictionary implementation Mojang created to try and reduce the size of the
|
||||
// overall packet. It is a list of common strings that are used in the biome definitions, such as
|
||||
// biome names, float values or query expressions.
|
||||
|
||||
@@ -22,6 +22,8 @@ type CameraAimAssist struct {
|
||||
TargetMode byte
|
||||
// Action is the action that should be performed with the aim assist. This is one of the constants above.
|
||||
Action byte
|
||||
// ShowDebugRender specifies if debug render should be shown.
|
||||
ShowDebugRender bool
|
||||
}
|
||||
|
||||
// ID ...
|
||||
@@ -37,4 +39,7 @@ func (pk *CameraAimAssist) Marshal(io protocol.IO) {
|
||||
io.Float32(&pk.Distance)
|
||||
io.Uint8(&pk.TargetMode)
|
||||
io.Uint8(&pk.Action)
|
||||
if proto.IsProtoGTE(io, proto.ID827) {
|
||||
io.Bool(&pk.ShowDebugRender)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ type CameraInstruction struct {
|
||||
Target protocol.Optional[protocol.CameraInstructionTarget]
|
||||
// RemoveTarget can be set to true to remove the current aim assist target.
|
||||
RemoveTarget protocol.Optional[bool]
|
||||
// FieldOfView is a camera instruction that updates the field of view for the camera.
|
||||
FieldOfView protocol.Optional[protocol.CameraInstructionFieldOfView]
|
||||
}
|
||||
|
||||
// ID ...
|
||||
@@ -33,4 +35,7 @@ func (pk *CameraInstruction) Marshal(io protocol.IO) {
|
||||
protocol.OptionalMarshaler(io, &pk.Target)
|
||||
protocol.OptionalFunc(io, &pk.RemoveTarget, io.Bool)
|
||||
}
|
||||
if proto.IsProtoGTE(io, proto.ID827) {
|
||||
protocol.OptionalMarshaler(io, &pk.FieldOfView)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO) {
|
||||
}
|
||||
io.Vec3(&pk.Position)
|
||||
io.Vec3(&pk.Delta)
|
||||
if proto.IsProtoGTE(io, proto.ID671) {
|
||||
if proto.IsProtoGTE(io, proto.ID671) && proto.IsProtoLT(io, proto.ID827) {
|
||||
if pk.PredictionType == packet.PredictionTypeVehicle {
|
||||
io.Vec2(&pk.Rotation)
|
||||
if proto.IsProtoGTE(io, proto.ID712) {
|
||||
@@ -49,6 +49,10 @@ func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if proto.IsProtoGTE(io, proto.ID827) {
|
||||
io.Vec2(&pk.Rotation)
|
||||
protocol.OptionalFunc(io, &pk.VehicleAngularVelocity, io.Float32)
|
||||
}
|
||||
io.Bool(&pk.OnGround)
|
||||
io.Varuint64(&pk.Tick)
|
||||
}
|
||||
|
||||
@@ -238,6 +238,8 @@ type StartGame struct {
|
||||
// its index in the expected block palette. This is useful for servers that wish to support multiple protocol versions
|
||||
// and custom blocks, but it will result in extra bytes being written for every block in a sub chunk palette.
|
||||
UseBlockNetworkIDHashes bool
|
||||
// TickDeathSystemsEnabled specifies if the new tick death systems are enabled.
|
||||
TickDeathSystemsEnabled bool
|
||||
// ServerAuthoritativeSound is currently unknown as to what it does.
|
||||
ServerAuthoritativeSound bool
|
||||
}
|
||||
@@ -336,5 +338,8 @@ func (pk *StartGame) Marshal(io protocol.IO) {
|
||||
io.UUID(&pk.WorldTemplateID)
|
||||
io.Bool(&pk.ClientSideGeneration)
|
||||
io.Bool(&pk.UseBlockNetworkIDHashes)
|
||||
if proto.IsProtoGTE(io, proto.ID827) {
|
||||
io.Bool(&pk.TickDeathSystemsEnabled)
|
||||
}
|
||||
io.Bool(&pk.ServerAuthoritativeSound)
|
||||
}
|
||||
|
||||
104
legacyver/proto/biome.go
Normal file
104
legacyver/proto/biome.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package proto
|
||||
|
||||
import "github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
|
||||
// BiomeDefinition represents a biome definition in the game. This can be a vanilla biome or a completely
|
||||
// custom biome.
|
||||
type BiomeDefinition struct {
|
||||
// NameIndex represents the index of the biome name in the string list.
|
||||
NameIndex int16
|
||||
// BiomeID is the biome ID. This is optional and can be empty.
|
||||
BiomeID int16
|
||||
// Temperature is the temperature of the biome, used for weather, biome behaviours and sky colour.
|
||||
Temperature float32
|
||||
// Downfall is the amount that precipitation affects colours and block changes.
|
||||
Downfall float32
|
||||
// RedSporeDensity is the density of red spore precipitation visuals.
|
||||
RedSporeDensity float32
|
||||
// BlueSporeDensity is the density of blue spore precipitation visuals.
|
||||
BlueSporeDensity float32
|
||||
// AshDensity is the density of ash precipitation visuals.
|
||||
AshDensity float32
|
||||
// WhiteAshDensity is the density of white ash precipitation visuals.
|
||||
WhiteAshDensity float32
|
||||
// Depth ...
|
||||
Depth float32
|
||||
// Scale ...
|
||||
Scale float32
|
||||
// MapWaterColour is an ARGB value for the water colour on maps in the biome.
|
||||
MapWaterColour int32
|
||||
// Rain is true if the biome has rain, false if it is a dry biome.
|
||||
Rain bool
|
||||
// Tags are a list of indices of tags in the string list. These are used to group biomes together for
|
||||
// biome generation and other purposes.
|
||||
Tags protocol.Optional[[]uint16]
|
||||
// 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]
|
||||
}
|
||||
|
||||
func (x *BiomeDefinition) Marshal(r protocol.IO) {
|
||||
r.Int16(&x.NameIndex)
|
||||
if IsProtoLT(r, ID827) {
|
||||
var opt protocol.Optional[int16]
|
||||
if x.BiomeID != -1 {
|
||||
opt = protocol.Option(x.BiomeID)
|
||||
}
|
||||
protocol.OptionalFunc(r, &opt, r.Int16)
|
||||
x.BiomeID, _ = opt.Value()
|
||||
} else {
|
||||
r.Int16(&x.BiomeID)
|
||||
}
|
||||
r.Float32(&x.Temperature)
|
||||
r.Float32(&x.Downfall)
|
||||
r.Float32(&x.RedSporeDensity)
|
||||
r.Float32(&x.BlueSporeDensity)
|
||||
r.Float32(&x.AshDensity)
|
||||
r.Float32(&x.WhiteAshDensity)
|
||||
r.Float32(&x.Depth)
|
||||
r.Float32(&x.Scale)
|
||||
r.Int32(&x.MapWaterColour)
|
||||
r.Bool(&x.Rain)
|
||||
protocol.OptionalFunc(r, &x.Tags, func(s *[]uint16) {
|
||||
protocol.FuncSlice(r, s, r.Uint16)
|
||||
})
|
||||
protocol.OptionalMarshaler(r, &x.ChunkGeneration)
|
||||
}
|
||||
|
||||
func (x *BiomeDefinition) FromLatest(bd protocol.BiomeDefinition) BiomeDefinition {
|
||||
x.NameIndex = bd.NameIndex
|
||||
x.BiomeID = bd.BiomeID
|
||||
x.Temperature = bd.Temperature
|
||||
x.Downfall = bd.Downfall
|
||||
x.RedSporeDensity = bd.RedSporeDensity
|
||||
x.BlueSporeDensity = bd.BlueSporeDensity
|
||||
x.AshDensity = bd.AshDensity
|
||||
x.WhiteAshDensity = bd.WhiteAshDensity
|
||||
x.Depth = bd.Depth
|
||||
x.Scale = bd.Scale
|
||||
x.MapWaterColour = bd.MapWaterColour
|
||||
x.Rain = bd.Rain
|
||||
x.Tags = bd.Tags
|
||||
x.ChunkGeneration = bd.ChunkGeneration
|
||||
return *x
|
||||
}
|
||||
|
||||
func (x *BiomeDefinition) ToLatest() protocol.BiomeDefinition {
|
||||
return protocol.BiomeDefinition{
|
||||
NameIndex: x.NameIndex,
|
||||
BiomeID: x.BiomeID,
|
||||
Temperature: x.Temperature,
|
||||
Downfall: x.Downfall,
|
||||
RedSporeDensity: x.RedSporeDensity,
|
||||
BlueSporeDensity: x.BlueSporeDensity,
|
||||
AshDensity: x.AshDensity,
|
||||
WhiteAshDensity: x.WhiteAshDensity,
|
||||
Depth: x.Depth,
|
||||
Scale: x.Scale,
|
||||
MapWaterColour: x.MapWaterColour,
|
||||
Rain: x.Rain,
|
||||
Tags: x.Tags,
|
||||
ChunkGeneration: x.ChunkGeneration,
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package proto
|
||||
import "github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
|
||||
const (
|
||||
ID827 = 827 // v1.21.100
|
||||
ID819 = 819 // v1.21.93
|
||||
ID818 = 818 // v1.21.90
|
||||
ID800 = 800 // v1.21.80
|
||||
|
||||
@@ -2,6 +2,7 @@ package proto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
// PlayerListEntry is an entry found in the PlayerList packet. It represents a single player using the UUID
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package legacyver
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/legacypacket"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/samber/lo"
|
||||
"github.com/sandertv/gophertunnel/minecraft"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -294,11 +295,12 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
}
|
||||
case *packet.CameraAimAssist:
|
||||
pks[pkIndex] = &legacypacket.CameraAimAssist{
|
||||
Preset: pk.Preset,
|
||||
Angle: pk.Angle,
|
||||
Distance: pk.Distance,
|
||||
TargetMode: pk.TargetMode,
|
||||
Action: pk.Action,
|
||||
Preset: pk.Preset,
|
||||
Angle: pk.Angle,
|
||||
Distance: pk.Distance,
|
||||
TargetMode: pk.TargetMode,
|
||||
Action: pk.Action,
|
||||
ShowDebugRender: pk.ShowDebugRender,
|
||||
}
|
||||
case *packet.UpdateAttributes:
|
||||
attributes := make([]proto.Attribute, len(pk.Attributes))
|
||||
@@ -392,6 +394,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
}
|
||||
case *packet.ChangeDimension:
|
||||
pks[pkIndex] = &legacypacket.ChangeDimension{
|
||||
@@ -594,6 +597,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
ScenarioID: pk.ScenarioID,
|
||||
OwnerID: pk.OwnerID,
|
||||
UseBlockNetworkIDHashes: pk.UseBlockNetworkIDHashes,
|
||||
TickDeathSystemsEnabled: pk.TickDeathSystemsEnabled,
|
||||
ServerAuthoritativeSound: pk.ServerAuthoritativeSound,
|
||||
}
|
||||
case *packet.CodeBuilderSource:
|
||||
@@ -721,8 +725,12 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
||||
Visibility: pk.Visibility,
|
||||
}
|
||||
case *packet.BiomeDefinitionList:
|
||||
biomeDefinitions := make([]proto.BiomeDefinition, len(pk.BiomeDefinitions))
|
||||
for i, bd := range pk.BiomeDefinitions {
|
||||
biomeDefinitions[i] = (&proto.BiomeDefinition{}).FromLatest(bd)
|
||||
}
|
||||
pks[pkIndex] = &legacypacket.BiomeDefinitionList{
|
||||
BiomeDefinitions: pk.BiomeDefinitions,
|
||||
BiomeDefinitions: biomeDefinitions,
|
||||
StringList: pk.StringList,
|
||||
}
|
||||
case *packet.PlayerList:
|
||||
@@ -868,11 +876,12 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
}
|
||||
case *legacypacket.CameraAimAssist:
|
||||
pks[pkIndex] = &packet.CameraAimAssist{
|
||||
Preset: pk.Preset,
|
||||
Angle: pk.Angle,
|
||||
Distance: pk.Distance,
|
||||
TargetMode: pk.TargetMode,
|
||||
Action: pk.Action,
|
||||
Preset: pk.Preset,
|
||||
Angle: pk.Angle,
|
||||
Distance: pk.Distance,
|
||||
TargetMode: pk.TargetMode,
|
||||
Action: pk.Action,
|
||||
ShowDebugRender: pk.ShowDebugRender,
|
||||
}
|
||||
case *legacypacket.UpdateAttributes:
|
||||
attributes := make([]protocol.Attribute, len(pk.Attributes))
|
||||
@@ -966,6 +975,7 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
Fade: pk.Fade,
|
||||
Target: pk.Target,
|
||||
RemoveTarget: pk.RemoveTarget,
|
||||
FieldOfView: pk.FieldOfView,
|
||||
}
|
||||
case *legacypacket.ChangeDimension:
|
||||
pks[pkIndex] = &packet.ChangeDimension{
|
||||
@@ -1156,6 +1166,7 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
ScenarioID: pk.ScenarioID,
|
||||
OwnerID: pk.OwnerID,
|
||||
UseBlockNetworkIDHashes: pk.UseBlockNetworkIDHashes,
|
||||
TickDeathSystemsEnabled: pk.TickDeathSystemsEnabled,
|
||||
ServerAuthoritativeSound: pk.ServerAuthoritativeSound,
|
||||
}
|
||||
case *legacypacket.CodeBuilderSource:
|
||||
@@ -1257,8 +1268,12 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
||||
Visibility: pk.Visibility,
|
||||
}
|
||||
case *legacypacket.BiomeDefinitionList:
|
||||
biomeDefinitions := make([]protocol.BiomeDefinition, len(pk.BiomeDefinitions))
|
||||
for i, bd := range pk.BiomeDefinitions {
|
||||
biomeDefinitions[i] = bd.ToLatest()
|
||||
}
|
||||
pks[pkIndex] = &packet.BiomeDefinitionList{
|
||||
BiomeDefinitions: pk.BiomeDefinitions,
|
||||
BiomeDefinitions: biomeDefinitions,
|
||||
StringList: pk.StringList,
|
||||
}
|
||||
case *legacypacket.PlayerList:
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,6 +2,7 @@ package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/internal/chunk"
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
|
||||
@@ -2,32 +2,33 @@ 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 (
|
||||
// ItemVersion819 ...
|
||||
ItemVersion819 = 271
|
||||
ItemVersion819 = 261
|
||||
// BlockVersion819 ...
|
||||
BlockVersion819 int32 = (1 << 24) | (21 << 16) | (90 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/dragonfly_items.json
|
||||
dragonflyLatestItemList []byte
|
||||
//go:embed data/required_item_list_819.json
|
||||
requiredItemList819 []byte
|
||||
//go:embed data/block_states_819.nbt
|
||||
blockStateData819 []byte
|
||||
|
||||
itemMappingLatestPocketMine = mapping.NewItemMapping(requiredItemList819, ItemVersion819)
|
||||
itemMappingLatestDragonfly = mapping.NewItemMapping(dragonflyLatestItemList, ItemVersion819)
|
||||
blockMappingLatest = mapping.NewBlockMapping(blockStateData819)
|
||||
)
|
||||
|
||||
func itemMappingLatest(dragonflyMapping bool) mapping.Item {
|
||||
if dragonflyMapping {
|
||||
return itemMappingLatestDragonfly
|
||||
func New819(dragonflyMapping bool) *Protocol {
|
||||
itemMapping := mapping.NewItemMapping(requiredItemList819, ItemVersion819)
|
||||
blockMapping := mapping.NewBlockMapping(blockStateData819)
|
||||
return &Protocol{
|
||||
ver: "1.21.90",
|
||||
id: proto.ID819,
|
||||
blockTranslator: NewBlockTranslator(blockMapping, blockMappingLatest, chunk.NewNetworkPersistentEncoding(blockMapping, BlockVersion819), chunk.NewBlockPaletteEncoding(blockMapping, BlockVersion819), false),
|
||||
itemTranslator: NewItemTranslator(itemMapping, itemMappingLatest(dragonflyMapping), blockMapping, blockMappingLatest),
|
||||
}
|
||||
return itemMappingLatestPocketMine
|
||||
}
|
||||
|
||||
34
legacyver/v827.go
Normal file
34
legacyver/v827.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package legacyver
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/akmalfairuz/legacy-version/mapping"
|
||||
)
|
||||
|
||||
const (
|
||||
// ItemVersion827 ...
|
||||
ItemVersion827 = 271
|
||||
// BlockVersion827 ...
|
||||
BlockVersion827 int32 = (1 << 24) | (21 << 16) | (100 << 8)
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed data/dragonfly_items.json
|
||||
dragonflyLatestItemList []byte
|
||||
//go:embed data/required_item_list_827.json
|
||||
requiredItemList827 []byte
|
||||
//go:embed data/block_states_827.nbt
|
||||
blockStateData827 []byte
|
||||
|
||||
itemMappingLatestPocketMine = mapping.NewItemMapping(requiredItemList827, ItemVersion827)
|
||||
itemMappingLatestDragonfly = mapping.NewItemMapping(dragonflyLatestItemList, ItemVersion827)
|
||||
blockMappingLatest = mapping.NewBlockMapping(blockStateData827)
|
||||
)
|
||||
|
||||
func itemMappingLatest(dragonflyMapping bool) mapping.Item {
|
||||
if dragonflyMapping {
|
||||
return itemMappingLatestDragonfly
|
||||
}
|
||||
return itemMappingLatestPocketMine
|
||||
}
|
||||
Reference in New Issue
Block a user