update 1.21.111
This commit is contained in:
@@ -50,6 +50,10 @@ func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO) {
|
||||
protocol.OptionalFunc(io, &pk.VehicleAngularVelocity, io.Float32)
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
31
legacyver/legacypacket/game_rules_changed.go
Normal file
31
legacyver/legacypacket/game_rules_changed.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// GameRulesChanged is sent by the server to the client to update client-side game rules, such as game rules
|
||||
// like the 'showCoordinates' game rule.
|
||||
type GameRulesChanged struct {
|
||||
// GameRules defines game rules changed with their respective values. The value of these game rules may be
|
||||
// either 'bool', 'int32' or 'float32'.
|
||||
// Note that some game rules are server side only, and don't necessarily need to be sent to the client.
|
||||
// Only changed game rules need to be sent in this packet. Game rules that were not changed do not need to
|
||||
// be sent if the client is already updated on them.
|
||||
GameRules []protocol.GameRule
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*GameRulesChanged) ID() uint32 {
|
||||
return packet.IDGameRulesChanged
|
||||
}
|
||||
|
||||
func (pk *GameRulesChanged) Marshal(io protocol.IO) {
|
||||
if proto.IsProtoGTE(io, proto.ID844) {
|
||||
protocol.FuncSlice(io, &pk.GameRules, io.GameRule)
|
||||
} else {
|
||||
protocol.FuncSlice(io, &pk.GameRules, io.GameRuleLegacy)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package legacypacket
|
||||
@@ -9,20 +9,8 @@ import (
|
||||
// PlayerArmourDamage is sent by the server to damage the armour of a player. It is a very efficient packet,
|
||||
// but generally it's much easier to just send a slot update for the damaged armour.
|
||||
type PlayerArmourDamage struct {
|
||||
// Bitset holds a bitset of 4 bits that indicate which pieces of armour need to have damage dealt to them.
|
||||
// The first bit, when toggled, is for a helmet, the second for the chestplate, the third for the leggings
|
||||
// and the fourth for boots.
|
||||
Bitset uint8
|
||||
// HelmetDamage is the amount of damage that should be dealt to the helmet.
|
||||
HelmetDamage int32
|
||||
// ChestplateDamage is the amount of damage that should be dealt to the chestplate.
|
||||
ChestplateDamage int32
|
||||
// LeggingsDamage is the amount of damage that should be dealt to the leggings.
|
||||
LeggingsDamage int32
|
||||
// BootsDamage is the amount of damage that should be dealt to the boots.
|
||||
BootsDamage int32
|
||||
// BodyDamage is the amount of damage that should be dealt to the body.
|
||||
BodyDamage int32
|
||||
// List ...
|
||||
List []protocol.PlayerArmourDamageEntry
|
||||
}
|
||||
|
||||
// ID ...
|
||||
@@ -31,33 +19,49 @@ func (pk *PlayerArmourDamage) ID() uint32 {
|
||||
}
|
||||
|
||||
func (pk *PlayerArmourDamage) Marshal(io protocol.IO) {
|
||||
io.Uint8(&pk.Bitset)
|
||||
if pk.Bitset&packet.PlayerArmourDamageFlagHelmet != 0 {
|
||||
io.Varint32(&pk.HelmetDamage)
|
||||
} else {
|
||||
pk.HelmetDamage = 0
|
||||
}
|
||||
if pk.Bitset&packet.PlayerArmourDamageFlagChestplate != 0 {
|
||||
io.Varint32(&pk.ChestplateDamage)
|
||||
} else {
|
||||
pk.ChestplateDamage = 0
|
||||
}
|
||||
if pk.Bitset&packet.PlayerArmourDamageFlagLeggings != 0 {
|
||||
io.Varint32(&pk.LeggingsDamage)
|
||||
} else {
|
||||
pk.LeggingsDamage = 0
|
||||
}
|
||||
if pk.Bitset&packet.PlayerArmourDamageFlagBoots != 0 {
|
||||
io.Varint32(&pk.BootsDamage)
|
||||
} else {
|
||||
pk.BootsDamage = 0
|
||||
}
|
||||
|
||||
if proto.IsProtoGTE(io, proto.ID712) {
|
||||
if pk.Bitset&packet.PlayerArmourDamageFlagBody != 0 {
|
||||
io.Varint32(&pk.BodyDamage)
|
||||
} else {
|
||||
pk.BodyDamage = 0
|
||||
if proto.IsProtoLT(io, proto.ID844) {
|
||||
var bitset uint8
|
||||
flags := []uint8{packet.PlayerArmourDamageFlagHelmet, packet.PlayerArmourDamageFlagChestplate, packet.PlayerArmourDamageFlagLeggings, packet.PlayerArmourDamageFlagBoots}
|
||||
if proto.IsProtoGTE(io, proto.ID712) {
|
||||
flags = append(flags, packet.PlayerArmourDamageFlagBody)
|
||||
}
|
||||
if proto.IsReader(io) {
|
||||
io.Uint8(&bitset)
|
||||
pk.List = make([]protocol.PlayerArmourDamageEntry, 0, len(flags))
|
||||
for _, flag := range flags {
|
||||
if bitset&flag != 0 {
|
||||
v := protocol.PlayerArmourDamageEntry{
|
||||
ArmourSlot: flag,
|
||||
}
|
||||
v2 := int32(0)
|
||||
io.Varint32(&v2)
|
||||
v.Damage = int16(v2)
|
||||
pk.List = append(pk.List, v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range pk.List {
|
||||
if entry.ArmourSlot == packet.PlayerArmourDamageFlagBody && !proto.IsProtoGTE(io, proto.ID712) {
|
||||
continue
|
||||
}
|
||||
bitset |= 1 << entry.ArmourSlot
|
||||
}
|
||||
io.Uint8(&bitset)
|
||||
for _, flag := range flags {
|
||||
if bitset&flag != 0 {
|
||||
damage := int32(0)
|
||||
for _, entry := range pk.List {
|
||||
if entry.ArmourSlot == flag {
|
||||
damage = int32(entry.Damage)
|
||||
break
|
||||
}
|
||||
}
|
||||
io.Varint32(&damage)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
protocol.SliceVarint32Length(io, &pk.List)
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func (pk *StartGame) Marshal(io protocol.IO) {
|
||||
io.Varint32(&pk.PlatformBroadcastMode)
|
||||
io.Bool(&pk.CommandsEnabled)
|
||||
io.Bool(&pk.TexturePackRequired)
|
||||
protocol.FuncSlice(io, &pk.GameRules, io.GameRule)
|
||||
protocol.FuncSlice(io, &pk.GameRules, io.GameRuleLegacy)
|
||||
protocol.SliceUint32Length(io, &pk.Experiments)
|
||||
io.Bool(&pk.ExperimentsPreviouslyToggled)
|
||||
io.Bool(&pk.BonusChestEnabled)
|
||||
|
||||
Reference in New Issue
Block a user