Merge pull request #74 from nugget/nugget/minecraft-1.16.2
Support for Minecraft 1.16.2
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
# Go-MC
|
# Go-MC
|
||||||

|

|
||||||

|

|
||||||
[](https://godoc.org/github.com/Tnze/go-mc)
|
[](https://godoc.org/github.com/Tnze/go-mc)
|
||||||
[](https://goreportcard.com/report/github.com/Tnze/go-mc)
|
[](https://goreportcard.com/report/github.com/Tnze/go-mc)
|
||||||
[](https://travis-ci.org/Tnze/go-mc)
|
[](https://travis-ci.org/Tnze/go-mc)
|
||||||
|
@ -4,9 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"github.com/Tnze/go-mc/bot/world"
|
"github.com/Tnze/go-mc/bot/world"
|
||||||
"github.com/Tnze/go-mc/bot/world/entity"
|
"github.com/Tnze/go-mc/bot/world/entity"
|
||||||
"github.com/Tnze/go-mc/chat"
|
"github.com/Tnze/go-mc/chat"
|
||||||
@ -331,6 +332,7 @@ func handleUpdateHealthPacket(c *Client, p pk.Packet) (err error) {
|
|||||||
func handleJoinGamePacket(c *Client, p pk.Packet) error {
|
func handleJoinGamePacket(c *Client, p pk.Packet) error {
|
||||||
var (
|
var (
|
||||||
eid pk.Int
|
eid pk.Int
|
||||||
|
hardcore pk.Boolean
|
||||||
gamemode pk.UnsignedByte
|
gamemode pk.UnsignedByte
|
||||||
previousGm pk.UnsignedByte
|
previousGm pk.UnsignedByte
|
||||||
worldCount pk.VarInt
|
worldCount pk.VarInt
|
||||||
@ -340,14 +342,14 @@ func handleJoinGamePacket(c *Client, p pk.Packet) error {
|
|||||||
dimension pk.Int
|
dimension pk.Int
|
||||||
worldName pk.Identifier
|
worldName pk.Identifier
|
||||||
hashedSeed pk.Long
|
hashedSeed pk.Long
|
||||||
maxPlayers pk.UnsignedByte
|
maxPlayers pk.VarInt
|
||||||
viewDistance pk.VarInt
|
viewDistance pk.VarInt
|
||||||
rdi pk.Boolean // Reduced Debug Info
|
rdi pk.Boolean // Reduced Debug Info
|
||||||
ers pk.Boolean // Enable respawn screen
|
ers pk.Boolean // Enable respawn screen
|
||||||
isDebug pk.Boolean
|
isDebug pk.Boolean
|
||||||
isFlat pk.Boolean
|
isFlat pk.Boolean
|
||||||
)
|
)
|
||||||
err := p.Scan(&eid, &gamemode, &previousGm, &worldCount, &worldNames, &dimension, &worldName,
|
err := p.Scan(&eid, &hardcore, &gamemode, &previousGm, &worldCount, &worldNames, &dimension, &worldName,
|
||||||
&hashedSeed, &maxPlayers, &rdi, &ers, &isDebug, &isFlat)
|
&hashedSeed, &maxPlayers, &rdi, &ers, &isDebug, &isFlat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -453,17 +455,17 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
|
|||||||
if !c.settings.ReceiveMap {
|
if !c.settings.ReceiveMap {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
X, Z pk.Int
|
X, Z pk.Int
|
||||||
FullChunk pk.Boolean
|
FullChunk pk.Boolean
|
||||||
IgnoreOldData pk.Boolean
|
|
||||||
PrimaryBitMask pk.VarInt
|
PrimaryBitMask pk.VarInt
|
||||||
Heightmaps struct{}
|
Heightmaps struct{}
|
||||||
Biomes = biomesData{fullChunk: (*bool)(&FullChunk)}
|
Biomes = biomesData{fullChunk: (*bool)(&FullChunk)}
|
||||||
Data chunkData
|
Data chunkData
|
||||||
BlockEntities blockEntities
|
BlockEntities blockEntities
|
||||||
)
|
)
|
||||||
if err := p.Scan(&X, &Z, &FullChunk, &IgnoreOldData, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Biomes, &Data, &BlockEntities); err != nil {
|
if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Biomes, &Data, &BlockEntities); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
chunk, err := world.DecodeChunkColumn(int32(PrimaryBitMask), Data)
|
chunk, err := world.DecodeChunkColumn(int32(PrimaryBitMask), Data)
|
||||||
@ -478,19 +480,29 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
|
|||||||
|
|
||||||
type biomesData struct {
|
type biomesData struct {
|
||||||
fullChunk *bool
|
fullChunk *bool
|
||||||
data [1024]int32
|
data []pk.VarInt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *biomesData) Decode(r pk.DecodeReader) error {
|
func (b *biomesData) Decode(r pk.DecodeReader) error {
|
||||||
if b.fullChunk == nil || !*b.fullChunk {
|
if b.fullChunk == nil || !*b.fullChunk {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for i := range b.data {
|
|
||||||
err := (*pk.Int)(&b.data[i]).Decode(r)
|
var nobd pk.VarInt // Number of Biome Datums
|
||||||
if err != nil {
|
if err := nobd.Decode(r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
b.data = make([]pk.VarInt, nobd)
|
||||||
|
|
||||||
|
for i := 0; i < int(nobd); i++ {
|
||||||
|
var d pk.VarInt
|
||||||
|
if err := d.Decode(r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
b.data[i] = d
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ProtocolVersion , the protocol version number of minecraft net protocol
|
// ProtocolVersion , the protocol version number of minecraft net protocol
|
||||||
const ProtocolVersion = 736
|
const ProtocolVersion = 751
|
||||||
|
|
||||||
// JoinServer connect a Minecraft server for playing the game.
|
// JoinServer connect a Minecraft server for playing the game.
|
||||||
func (c *Client) JoinServer(addr string, port int) (err error) {
|
func (c *Client) JoinServer(addr string, port int) (err error) {
|
||||||
|
@ -17,10 +17,9 @@ const (
|
|||||||
BossBar
|
BossBar
|
||||||
ServerDifficulty
|
ServerDifficulty
|
||||||
ChatMessageClientbound
|
ChatMessageClientbound
|
||||||
MultiBlockChange
|
TabComplete
|
||||||
|
|
||||||
TabComplete //0x10
|
DeclareCommands //0x10
|
||||||
DeclareCommands
|
|
||||||
WindowConfirmationClientbound
|
WindowConfirmationClientbound
|
||||||
CloseWindowClientbound
|
CloseWindowClientbound
|
||||||
WindowItems
|
WindowItems
|
||||||
@ -35,9 +34,9 @@ const (
|
|||||||
UnloadChunk
|
UnloadChunk
|
||||||
ChangeGameState
|
ChangeGameState
|
||||||
OpenHorseWindow
|
OpenHorseWindow
|
||||||
|
KeepAliveClientbound
|
||||||
|
|
||||||
KeepAliveClientbound //0x20
|
ChunkData //0x20
|
||||||
ChunkData
|
|
||||||
Effect
|
Effect
|
||||||
Particle
|
Particle
|
||||||
UpdateLight
|
UpdateLight
|
||||||
@ -52,9 +51,9 @@ const (
|
|||||||
OpenBook
|
OpenBook
|
||||||
OpenWindow
|
OpenWindow
|
||||||
OpenSignEditor
|
OpenSignEditor
|
||||||
|
CraftRecipeResponse
|
||||||
|
|
||||||
CraftRecipeResponse //0x30
|
PlayerAbilitiesClientbound //0x30
|
||||||
PlayerAbilitiesClientbound
|
|
||||||
CombatEvent
|
CombatEvent
|
||||||
PlayerInfo
|
PlayerInfo
|
||||||
FacePlayer
|
FacePlayer
|
||||||
@ -65,6 +64,7 @@ const (
|
|||||||
ResourcePackSend
|
ResourcePackSend
|
||||||
Respawn
|
Respawn
|
||||||
EntityHeadLook
|
EntityHeadLook
|
||||||
|
MultiBlockChange
|
||||||
SelectAdvancementTab
|
SelectAdvancementTab
|
||||||
WorldBorder
|
WorldBorder
|
||||||
Camera
|
Camera
|
||||||
@ -134,10 +134,11 @@ const (
|
|||||||
PlayerDigging
|
PlayerDigging
|
||||||
EntityAction
|
EntityAction
|
||||||
SteerVehicle
|
SteerVehicle
|
||||||
|
DisplayedRecipe
|
||||||
RecipeBookData
|
RecipeBookData
|
||||||
NameItem
|
|
||||||
|
|
||||||
ResourcePackStatus //0x20
|
NameItem //0x20
|
||||||
|
ResourcePackStatus
|
||||||
AdvancementTab
|
AdvancementTab
|
||||||
SelectTrade
|
SelectTrade
|
||||||
SetBeaconEffect
|
SetBeaconEffect
|
||||||
@ -151,5 +152,5 @@ const (
|
|||||||
AnimationServerbound
|
AnimationServerbound
|
||||||
Spectate
|
Spectate
|
||||||
PlayerBlockPlacement
|
PlayerBlockPlacement
|
||||||
UseItem //0x2E
|
UseItem //0x2F
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user