更新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
![Version](https://img.shields.io/badge/Minecraft-1.14.4-blue.svg)
![Protocol](https://img.shields.io/badge/Protocol-498-blue.svg)
![Version](https://img.shields.io/badge/Minecraft-1.15-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)
[![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)

View File

@ -328,12 +328,14 @@ func handleJoinGamePacket(c *Client, p pk.Packet) error {
eid pk.Int
gamemode pk.UnsignedByte
dimension pk.Int
hashedSeed pk.Long
maxPlayers pk.UnsignedByte
levelType pk.String
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 {
return err
}
@ -443,7 +445,7 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
Data chunkData
BlockEntities blockEntities
)
// TODO: Biomes data in this packet
if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Data, &BlockEntities); err != nil {
return err
}

View File

@ -11,7 +11,7 @@ import (
)
// ProtocolVersion , the protocol version number of minecraft net protocol
const ProtocolVersion = 498
const ProtocolVersion = 573
// JoinServer connect a Minecraft server for playing the game.
func (c *Client) JoinServer(addr string, port int) (err error) {

View File

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

View File

@ -63,7 +63,7 @@ func (p *Packet) Pack(threshold int) (pack []byte) {
return
}
// RecvPacket recive a packet from server
// RecvPacket receive a packet from server
func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error) {
var len int
for i := 0; i < 5; i++ { //读数据前的长度标记
@ -71,7 +71,7 @@ func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error) {
if err != nil {
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 {
break
}