more changes for latest gophertunnel support
This commit is contained in:
@@ -72,7 +72,7 @@ func (pk *Text) Marshal(io protocol.IO) {
|
|||||||
} else {
|
} else {
|
||||||
categoryType = packet.TextCategoryMessageWithParameters
|
categoryType = packet.TextCategoryMessageWithParameters
|
||||||
}
|
}
|
||||||
io.TextCategory(&categoryType)
|
io.Uint8(&categoryType)
|
||||||
io.Uint8(&pk.TextType)
|
io.Uint8(&pk.TextType)
|
||||||
}
|
}
|
||||||
switch pk.TextType {
|
switch pk.TextType {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import "github.com/sandertv/gophertunnel/minecraft/protocol"
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ID898 = 898 // v1.21.130
|
ID898 = 898 // v1.21.130
|
||||||
|
ID860 = 860 // v1.21.124
|
||||||
ID859 = 859 // v1.21.120
|
ID859 = 859 // v1.21.120
|
||||||
ID844 = 844 // v1.21.110
|
ID844 = 844 // v1.21.110
|
||||||
ID827 = 827 // v1.21.100
|
ID827 = 827 // v1.21.100
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
|||||||
OnGround: pk.OnGround,
|
OnGround: pk.OnGround,
|
||||||
Tick: pk.Tick,
|
Tick: pk.Tick,
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
case *packet.Disconnect:
|
case *packet.Disconnect:
|
||||||
pks[pkIndex] = &legacypacket.Disconnect{
|
pks[pkIndex] = &legacypacket.Disconnect{
|
||||||
Reason: pk.Reason,
|
Reason: pk.Reason,
|
||||||
@@ -622,7 +623,6 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
|||||||
for i, it := range pk.Items {
|
for i, it := range pk.Items {
|
||||||
items[i] = (&proto.ItemEntry{}).FromLatest(it)
|
items[i] = (&proto.ItemEntry{}).FromLatest(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
items = p.itemTranslator.DowngradeItemEntries(items)
|
items = p.itemTranslator.DowngradeItemEntries(items)
|
||||||
|
|
||||||
if p.ID() < proto.ID776 {
|
if p.ID() < proto.ID776 {
|
||||||
@@ -634,10 +634,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
|||||||
return []packet.Packet{}
|
return []packet.Packet{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pks[pkIndex] = &legacypacket.ItemRegistry{Items: items}
|
||||||
pks[pkIndex] = &legacypacket.ItemRegistry{
|
|
||||||
Items: items,
|
|
||||||
}
|
|
||||||
case *packet.StructureBlockUpdate:
|
case *packet.StructureBlockUpdate:
|
||||||
pks[pkIndex] = &legacypacket.StructureBlockUpdate{
|
pks[pkIndex] = &legacypacket.StructureBlockUpdate{
|
||||||
Position: pk.Position,
|
Position: pk.Position,
|
||||||
@@ -770,7 +767,7 @@ func (p *Protocol) downgradePackets(pks []packet.Packet, conn *minecraft.Conn) [
|
|||||||
ActionType: pk.ActionType,
|
ActionType: pk.ActionType,
|
||||||
EntityRuntimeID: pk.EntityRuntimeID,
|
EntityRuntimeID: pk.EntityRuntimeID,
|
||||||
Data: pk.Data,
|
Data: pk.Data,
|
||||||
SwingSource: pk.SwingSource,
|
SwingSource: protocol.Option(swingSourceToString(pk.SwingSource)),
|
||||||
}
|
}
|
||||||
case *packet.AvailableCommands:
|
case *packet.AvailableCommands:
|
||||||
commands := make([]proto.Command, len(pk.Commands))
|
commands := make([]proto.Command, len(pk.Commands))
|
||||||
@@ -1371,11 +1368,31 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
|||||||
GameRules: pk.GameRules,
|
GameRules: pk.GameRules,
|
||||||
}
|
}
|
||||||
case *legacypacket.Animate:
|
case *legacypacket.Animate:
|
||||||
|
newSwingSource := packet.AnimateSwingSourceNone
|
||||||
|
source, _ := pk.SwingSource.Value()
|
||||||
|
switch source {
|
||||||
|
case "build":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceBuild
|
||||||
|
case "mine":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceMine
|
||||||
|
case "interact":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceInteract
|
||||||
|
case "attack":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceAttack
|
||||||
|
case "useitem":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceUseItem
|
||||||
|
case "throwitem":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceThrowItem
|
||||||
|
case "dropitem":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceDropItem
|
||||||
|
case "event":
|
||||||
|
newSwingSource = packet.AnimateSwingSourceEvent
|
||||||
|
}
|
||||||
pks[pkIndex] = &packet.Animate{
|
pks[pkIndex] = &packet.Animate{
|
||||||
ActionType: pk.ActionType,
|
ActionType: pk.ActionType,
|
||||||
EntityRuntimeID: pk.EntityRuntimeID,
|
EntityRuntimeID: pk.EntityRuntimeID,
|
||||||
Data: pk.Data,
|
Data: pk.Data,
|
||||||
SwingSource: pk.SwingSource,
|
SwingSource: uint8(newSwingSource),
|
||||||
}
|
}
|
||||||
case *legacypacket.AvailableCommands:
|
case *legacypacket.AvailableCommands:
|
||||||
enums := make([]protocol.CommandEnum, len(pk.Enums))
|
enums := make([]protocol.CommandEnum, len(pk.Enums))
|
||||||
@@ -1435,3 +1452,28 @@ func (p *Protocol) upgradePackets(pks []packet.Packet, conn *minecraft.Conn) []p
|
|||||||
}
|
}
|
||||||
return pks
|
return pks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func swingSourceToString(x uint8) string {
|
||||||
|
switch x {
|
||||||
|
case packet.AnimateSwingSourceNone:
|
||||||
|
return "none"
|
||||||
|
case packet.AnimateSwingSourceBuild:
|
||||||
|
return "build"
|
||||||
|
case packet.AnimateSwingSourceMine:
|
||||||
|
return "mine"
|
||||||
|
case packet.AnimateSwingSourceInteract:
|
||||||
|
return "interact"
|
||||||
|
case packet.AnimateSwingSourceAttack:
|
||||||
|
return "attack"
|
||||||
|
case packet.AnimateSwingSourceUseItem:
|
||||||
|
return "useitem"
|
||||||
|
case packet.AnimateSwingSourceThrowItem:
|
||||||
|
return "throwitem"
|
||||||
|
case packet.AnimateSwingSourceDropItem:
|
||||||
|
return "dropitem"
|
||||||
|
case packet.AnimateSwingSourceEvent:
|
||||||
|
return "event"
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user