更新1.15协议部分

This commit is contained in:
Tnze
2019-12-11 11:07:47 +08:00
parent 9576aa2823
commit e8bb060cc4
5 changed files with 22 additions and 20 deletions

View File

@ -1,6 +1,6 @@
# Go-MC # Go-MC
![Version](https://img.shields.io/badge/Minecraft-1.14.4-blue.svg) ![Version](https://img.shields.io/badge/Minecraft-1.15-blue.svg)
![Protocol](https://img.shields.io/badge/Protocol-498-blue.svg) ![Protocol](https://img.shields.io/badge/Protocol-573-blue.svg)
[![GoDoc](https://godoc.org/github.com/Tnze/go-mc?status.svg)](https://godoc.org/github.com/Tnze/go-mc) [![GoDoc](https://godoc.org/github.com/Tnze/go-mc?status.svg)](https://godoc.org/github.com/Tnze/go-mc)
[![Go Report Card](https://goreportcard.com/badge/github.com/Tnze/go-mc)](https://goreportcard.com/report/github.com/Tnze/go-mc) [![Go Report Card](https://goreportcard.com/badge/github.com/Tnze/go-mc)](https://goreportcard.com/report/github.com/Tnze/go-mc)
[![Build Status](https://travis-ci.org/Tnze/go-mc.svg?branch=master)](https://travis-ci.org/Tnze/go-mc) [![Build Status](https://travis-ci.org/Tnze/go-mc.svg?branch=master)](https://travis-ci.org/Tnze/go-mc)

View File

@ -328,12 +328,14 @@ func handleJoinGamePacket(c *Client, p pk.Packet) error {
eid pk.Int eid pk.Int
gamemode pk.UnsignedByte gamemode pk.UnsignedByte
dimension pk.Int dimension pk.Int
hashedSeed pk.Long
maxPlayers pk.UnsignedByte maxPlayers pk.UnsignedByte
levelType pk.String levelType pk.String
viewDistance pk.VarInt viewDistance pk.VarInt
rdi pk.Boolean rdi pk.Boolean // Reduced Debug Info
ers pk.Boolean // Enable respawn screen
) )
err := p.Scan(&eid, &gamemode, &dimension, &maxPlayers, &levelType, &rdi) err := p.Scan(&eid, &gamemode, &dimension, &hashedSeed, &maxPlayers, &levelType, &rdi, &ers)
if err != nil { if err != nil {
return err return err
} }
@ -443,7 +445,7 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
Data chunkData Data chunkData
BlockEntities blockEntities BlockEntities blockEntities
) )
// TODO: Biomes data in this packet
if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Data, &BlockEntities); err != nil { if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Data, &BlockEntities); err != nil {
return err return err
} }

View File

@ -11,7 +11,7 @@ import (
) )
// ProtocolVersion , the protocol version number of minecraft net protocol // ProtocolVersion , the protocol version number of minecraft net protocol
const ProtocolVersion = 498 const ProtocolVersion = 573
// 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) {

View File

@ -10,6 +10,7 @@ const (
SpawnPlayer SpawnPlayer
AnimationClientbound AnimationClientbound
Statistics Statistics
AcknowledgePlayerDigging
BlockBreakAnimation BlockBreakAnimation
UpdateBlockEntity UpdateBlockEntity
BlockAction BlockAction
@ -17,9 +18,9 @@ const (
BossBar BossBar
ServerDifficulty ServerDifficulty
ChatMessageClientbound ChatMessageClientbound
MultiBlockChange
TabComplete //0x10 MultiBlockChange //0x10
TabComplete
DeclareCommands DeclareCommands
ConfirmTransaction ConfirmTransaction
CloseWindow CloseWindow
@ -34,9 +35,9 @@ const (
Explosion Explosion
UnloadChunk UnloadChunk
ChangeGameState ChangeGameState
OpenHorseWindow
KeepAliveClientbound //0x20 OpenHorseWindow //0x20
KeepAliveClientbound
ChunkData ChunkData
Effect Effect
Particle Particle
@ -51,9 +52,9 @@ const (
VehicleMoveClientbound VehicleMoveClientbound
OpenBook OpenBook
OpenWindow OpenWindow
OpenSignEditor
CraftRecipeResponse //0x30 OpenSignEditor //0x30
CraftRecipeResponse
PlayerAbilitiesClientbound PlayerAbilitiesClientbound
CombatEvent CombatEvent
PlayerInfo PlayerInfo
@ -68,9 +69,9 @@ const (
SelectAdvancementTab SelectAdvancementTab
WorldBorder WorldBorder
Camera Camera
HeldItemChangeClientbound
UpdateViewPosition //0x40 HeldItemChangeClientbound //0x40
UpdateViewPosition
UpdateViewDistance UpdateViewDistance
DisplayScoreboard DisplayScoreboard
EntityMetadata EntityMetadata
@ -85,9 +86,9 @@ const (
UpdateScore UpdateScore
SpawnPosition SpawnPosition
TimeUpdate TimeUpdate
Title
EntitySoundEffect //0x50 Title //0x50
EntitySoundEffect
SoundEffect SoundEffect
StopSound StopSound
PlayerListHeaderAndFooter PlayerListHeaderAndFooter
@ -98,8 +99,7 @@ const (
EntityProperties EntityProperties
EntityEffect EntityEffect
DeclareRecipes DeclareRecipes
Tags Tags //0x5C
AcknowledgePlayerDigging //0x5C
) )
// Serverbound packet IDs // Serverbound packet IDs

View File

@ -63,7 +63,7 @@ func (p *Packet) Pack(threshold int) (pack []byte) {
return return
} }
// RecvPacket recive a packet from server // RecvPacket receive a packet from server
func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error) { func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error) {
var len int var len int
for i := 0; i < 5; i++ { //读数据前的长度标记 for i := 0; i < 5; i++ { //读数据前的长度标记
@ -71,7 +71,7 @@ func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("read len of packet fail: %v", err) return nil, fmt.Errorf("read len of packet fail: %v", err)
} }
len |= (int(b&0x7F) << uint(7*i)) len |= int(b&0x7F) << uint(7*i)
if b&0x80 == 0 { if b&0x80 == 0 {
break break
} }