updates for 1.21.100 support

This commit is contained in:
ethaniccc
2025-08-08 00:29:41 -04:00
parent d3fae5d3be
commit 6479ff677e
16 changed files with 9433 additions and 68 deletions

View File

@@ -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),

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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.

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -21,6 +21,7 @@ type CorrectPlayerMovePrediction struct {
Delta mgl32.Vec3
// Rotation is the rotation of the player at the tick written in the field below. It is only included if
// PredictionType is PredictionTypeVehicle.
// NOTE: As of 1.21.100, this field is also used for player rotations, and is not only set for vehicles.
Rotation mgl32.Vec2
// VehicleAngularVelocity is the angular velocity of the vehicle that the rider is riding.
VehicleAngularVelocity protocol.Optional[float32]
@@ -41,12 +42,12 @@ func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO) {
}
io.Vec3(&pk.Position)
io.Vec3(&pk.Delta)
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)
}
if (proto.IsProtoGTE(io, proto.ID671) && proto.IsProtoLT(io, proto.ID827) && pk.PredictionType == packet.PredictionTypeVehicle) ||
proto.IsProtoGTE(io, proto.ID827) {
io.Vec2(&pk.Rotation)
if proto.IsProtoGTE(io, proto.ID712) {
protocol.OptionalFunc(io, &pk.VehicleAngularVelocity, io.Float32)
}
}
io.Bool(&pk.OnGround)

View File

@@ -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)
}

92
legacyver/proto/biome.go Normal file
View File

@@ -0,0 +1,92 @@
package proto
import (
"unsafe"
_ "unsafe"
"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.
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]
}
// TODO: This will be required to be changed when the structs are modified in future MC updates.
func DowngradeBiomeDefinitions(bd []protocol.BiomeDefinition) []BiomeDefinition {
converted := make([]BiomeDefinition, len(bd))
for i, b := range bd {
ptr := unsafe.Pointer(&b)
converted[i] = *(*BiomeDefinition)(ptr)
}
return converted
}
// TODO: This will be required to be changed when the structs are modified in future MC updates.
func UpgradeBiomeDefinitions(bd []BiomeDefinition) []protocol.BiomeDefinition {
converted := make([]protocol.BiomeDefinition, len(bd))
for i, b := range bd {
ptr := unsafe.Pointer(&b)
converted[i] = *(*protocol.BiomeDefinition)(ptr)
}
return converted
}
func (x *BiomeDefinition) Marshal(r protocol.IO) {
r.Int16(&x.NameIndex)
if IsProtoGTE(r, ID827) {
r.Int16(&x.BiomeID)
} else {
var opt protocol.Optional[int16]
if x.BiomeID != -1 {
opt = protocol.Option(x.BiomeID)
}
protocol.OptionalFunc(r, &opt, r.Int16)
x.BiomeID, _ = opt.Value()
}
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)
}

View File

@@ -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

View File

@@ -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 (
@@ -722,7 +723,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
}
case *packet.BiomeDefinitionList:
pks[pkIndex] = &legacypacket.BiomeDefinitionList{
BiomeDefinitions: pk.BiomeDefinitions,
BiomeDefinitions: proto.DowngradeBiomeDefinitions(pk.BiomeDefinitions),
StringList: pk.StringList,
}
case *packet.PlayerList:
@@ -1258,7 +1259,7 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
}
case *legacypacket.BiomeDefinitionList:
pks[pkIndex] = &packet.BiomeDefinitionList{
BiomeDefinitions: pk.BiomeDefinitions,
BiomeDefinitions: proto.UpgradeBiomeDefinitions(pk.BiomeDefinitions),
StringList: pk.StringList,
}
case *legacypacket.PlayerList:

View File

@@ -2,6 +2,9 @@ package legacyver
import (
_ "embed"
"github.com/akmalfairuz/legacy-version/internal/chunk"
"github.com/akmalfairuz/legacy-version/legacyver/proto"
"github.com/akmalfairuz/legacy-version/mapping"
)
@@ -9,25 +12,24 @@ const (
// ItemVersion819 ...
ItemVersion819 = 271
// BlockVersion819 ...
BlockVersion819 int32 = (1 << 24) | (21 << 16) | (90 << 8)
BlockVersion819 int32 = (1 << 24) | (21 << 16) | (93 << 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.93",
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
}

35
legacyver/v827.go Normal file
View File

@@ -0,0 +1,35 @@
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
}