Skip to content

Commit

Permalink
protocol: Support 1.19.80
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Apr 23, 2023
1 parent 50fa7f6 commit 9890e57
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 4 deletions.
4 changes: 4 additions & 0 deletions minecraft/conn.go
Expand Up @@ -1009,6 +1009,8 @@ func (conn *Conn) startGame() {
Dimension: data.Dimension,
WorldSpawn: data.WorldSpawn,
EditorWorld: data.EditorWorld,
CreatedInEditor: data.CreatedInEditor,
ExportedFromEditor: data.ExportedFromEditor,
PersonaDisabled: data.PersonaDisabled,
CustomSkinsDisabled: data.CustomSkinsDisabled,
GameRules: data.GameRules,
Expand Down Expand Up @@ -1205,6 +1207,8 @@ func (conn *Conn) handleStartGame(pk *packet.StartGame) error {
Dimension: pk.Dimension,
WorldSpawn: pk.WorldSpawn,
EditorWorld: pk.EditorWorld,
CreatedInEditor: pk.CreatedInEditor,
ExportedFromEditor: pk.ExportedFromEditor,
PersonaDisabled: pk.PersonaDisabled,
CustomSkinsDisabled: pk.CustomSkinsDisabled,
GameRules: pk.GameRules,
Expand Down
6 changes: 6 additions & 0 deletions minecraft/game_data.go
Expand Up @@ -56,6 +56,12 @@ type GameData struct {
// EditorWorld is a value to dictate if the world is in editor mode, a special mode recently introduced adding
// "powerful tools for editing worlds, intended for experienced creators."
EditorWorld bool
// CreatedInEditor is a value to dictate if the world was created as a project in the editor mode. The functionality
// of this field is currently unknown.
CreatedInEditor bool
// ExportedFromEditor is a value to dictate if the world was exported from editor mode. The functionality of this
// field is currently unknown.
ExportedFromEditor bool
// WorldGameMode is the game mode that a player gets when it first spawns in the world. It is shown in the
// settings and is used if the PlayerGameMode is set to 5.
WorldGameMode int32
Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/info.go
Expand Up @@ -2,7 +2,7 @@ package protocol

const (
// CurrentProtocol is the current protocol version for the version below.
CurrentProtocol = 575
CurrentProtocol = 582
// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
CurrentVersion = "1.19.70"
CurrentVersion = "1.19.80"
)
18 changes: 18 additions & 0 deletions minecraft/protocol/packet/compressed_biome_definition_list .go
@@ -0,0 +1,18 @@
package packet

import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

type CompressedBiomeDefinitionList struct {
SerialisedBiomeDefinitions []byte
}

// ID ...
func (*CompressedBiomeDefinitionList) ID() uint32 {
return IDCompressedBiomeDefinitionList
}

func (pk *CompressedBiomeDefinitionList) Marshal(io protocol.IO) {
io.Bytes(&pk.SerialisedBiomeDefinitions)
}
3 changes: 3 additions & 0 deletions minecraft/protocol/packet/id.go
Expand Up @@ -201,4 +201,7 @@ const (
IDCameraPresets
IDUnlockedRecipes
IDCameraInstruction = iota + 101
IDCompressedBiomeDefinitionList
IDTrimData
IDOpenSign
)
7 changes: 7 additions & 0 deletions minecraft/protocol/packet/level_event.go
Expand Up @@ -41,6 +41,7 @@ const (
LevelEventSoundPointedDripstoneLand = 1064
LevelEventSoundDyeUsed = 1065
LevelEventSoundInkSacUsed = 1066
LevelEventSoundAmethystResonate = 1067
LevelEventQueueCustomMusic = 1900
LevelEventPlayCustomMusic = 1901
LevelEventStopCustomMusic = 1902
Expand Down Expand Up @@ -111,6 +112,12 @@ const (
LevelEventStartBlockCracking = 3600
LevelEventStopBlockCracking = 3601
LevelEventUpdateBlockCracking = 3602
LevelEventParticlesCrackBlockDown = 3603
LevelEventParticlesCrackBlockUp = 3604
LevelEventParticlesCrackBlockNorth = 3605
LevelEventParticlesCrackBlockSouth = 3606
LevelEventParticlesCrackBlockWest = 3607
LevelEventParticlesCrackBlockEast = 3608
LevelEventAllPlayersSleeping = 9800
LevelEventSleepingPlayers = 9801
LevelEventJumpPrevented = 9810
Expand Down
27 changes: 27 additions & 0 deletions minecraft/protocol/packet/open_sign.go
@@ -0,0 +1,27 @@
package packet

import (
"github.com/go-gl/mathgl/mgl32"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

// OpenSign is sent by the server to open a sign for editing. As of 1.19.80, the player can interact with a sign to edit
// either the text on either side instead of just the front.

This comment has been minimized.

Copy link
@AndreasHGK

AndreasHGK Apr 27, 2023

"the player can interact with a sign to edit either the text on either side instead of just the front."

type OpenSign struct {
// Position is the position of the sign to edit. The client uses this position to get the data of the sign, including
// the existing text and formatting etc.
Position mgl32.Vec3
// FrontSide dictates whether the front side of the sign should be opened for editing. If false, the back side is
// assumed to be edited.
FrontSide bool
}

// ID ...
func (*OpenSign) ID() uint32 {
return IDOpenSign
}

func (pk *OpenSign) Marshal(io protocol.IO) {
io.Vec3(&pk.Position)

This comment has been minimized.

This comment has been minimized.

Copy link
@xKaOz

xKaOz Apr 27, 2023

No, I don’t think so.

BlockPos should be used it looks like.

io.Bool(&pk.FrontSide)
}
2 changes: 1 addition & 1 deletion minecraft/protocol/packet/photo_info_request.go
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

// PhotoInfoRequest is sent by the client to request photo information from the server.
// PhotoInfoRequest is sent by the client to request photo information from the server. This packet was deprecated in 1.19.80.
type PhotoInfoRequest struct {
// PhotoID is the ID of the photo.
PhotoID int64
Expand Down
5 changes: 4 additions & 1 deletion minecraft/protocol/packet/pool.go
Expand Up @@ -224,7 +224,10 @@ func init() {
IDCameraPresets: func() Packet { return &CameraPresets{} },
IDUnlockedRecipes: func() Packet { return &UnlockedRecipes{} },
// ---
IDCameraInstruction: func() Packet { return &CameraInstruction{} },
IDCameraInstruction: func() Packet { return &CameraInstruction{} },
IDCompressedBiomeDefinitionList: func() Packet { return &CompressedBiomeDefinitionList{} },
IDTrimData: func() Packet { return &TrimData{} },
IDOpenSign: func() Packet { return &OpenSign{} },
}
for id, pk := range packets {
Register(id, pk)
Expand Down
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/request_chunk_radius.go
Expand Up @@ -11,6 +11,9 @@ type RequestChunkRadius struct {
// ChunkRadius is the requested chunk radius. This value is always the value set in the settings of the
// player.
ChunkRadius int32
// MaxChunkRadius is the maximum chunk radius that the player wants to receive. The reason for the client sending this
// is currently unknown.
MaxChunkRadius int32
}

// ID ...
Expand All @@ -20,4 +23,5 @@ func (*RequestChunkRadius) ID() uint32 {

func (pk *RequestChunkRadius) Marshal(io protocol.IO) {
io.Varint32(&pk.ChunkRadius)
io.Varint32(&pk.MaxChunkRadius)
}
10 changes: 10 additions & 0 deletions minecraft/protocol/packet/start_game.go
Expand Up @@ -75,6 +75,12 @@ type StartGame struct {
// EditorWorld is a value to dictate if the world is in editor mode, a special mode recently introduced adding
// "powerful tools for editing worlds, intended for experienced creators."
EditorWorld bool
// CreatedInEditor is a value to dictate if the world was created as a project in the editor mode. The functionality
// of this field is currently unknown.
CreatedInEditor bool
// ExportedFromEditor is a value to dictate if the world was exported from editor mode. The functionality of this
// field is currently unknown.
ExportedFromEditor bool
// DayCycleLockTime is the time at which the day cycle was locked if the day cycle is disabled using the
// respective game rule. The client will maintain this time as long as the day cycle is disabled.
DayCycleLockTime int32
Expand Down Expand Up @@ -227,6 +233,7 @@ type StartGame struct {
ChatRestrictionLevel uint8
// DisablePlayerInteractions is true if the client should ignore other players when interacting with the world.
DisablePlayerInteractions bool
UseBlockNetworkIDHashes bool
}

// ID ...
Expand All @@ -251,6 +258,8 @@ func (pk *StartGame) Marshal(io protocol.IO) {
io.UBlockPos(&pk.WorldSpawn)
io.Bool(&pk.AchievementsDisabled)
io.Bool(&pk.EditorWorld)
io.Bool(&pk.CreatedInEditor)
io.Bool(&pk.ExportedFromEditor)
io.Varint32(&pk.DayCycleLockTime)
io.Varint32(&pk.EducationEditionOffer)
io.Bool(&pk.EducationFeaturesEnabled)
Expand Down Expand Up @@ -305,4 +314,5 @@ func (pk *StartGame) Marshal(io protocol.IO) {
io.Uint64(&pk.ServerBlockStateChecksum)
io.UUID(&pk.WorldTemplateID)
io.Bool(&pk.ClientSideGeneration)
io.Bool(&pk.UseBlockNetworkIDHashes)
}
20 changes: 20 additions & 0 deletions minecraft/protocol/packet/trim_data.go
@@ -0,0 +1,20 @@
package packet

import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

type TrimData struct {
Patterns []protocol.TrimPattern
Materials []protocol.TrimMaterial
}

// ID ...
func (*TrimData) ID() uint32 {
return IDTrimData
}

func (pk *TrimData) Marshal(io protocol.IO) {
protocol.Slice(io, &pk.Patterns)
protocol.Slice(io, &pk.Materials)
}
23 changes: 23 additions & 0 deletions minecraft/protocol/recipe.go
Expand Up @@ -66,6 +66,7 @@ const (
RecipeShapelessChemistry
RecipeShapedChemistry
RecipeSmithingTransform
RecipeSmithingTrim
)

// Recipe represents a recipe that may be sent in a CraftingData packet to let the client know what recipes
Expand Down Expand Up @@ -99,6 +100,8 @@ func lookupRecipe(recipeType int32, x *Recipe) bool {
*x = &ShapedChemistryRecipe{}
case RecipeSmithingTransform:
*x = &SmithingTransformRecipe{}
case RecipeSmithingTrim:
*x = &SmithingTrimRecipe{}
default:
return false
}
Expand Down Expand Up @@ -127,6 +130,8 @@ func lookupRecipeType(x Recipe, recipeType *int32) bool {
*recipeType = RecipeShapedChemistry
case *SmithingTransformRecipe:
*recipeType = RecipeSmithingTransform
case *SmithingTrimRecipe:
*recipeType = RecipeSmithingTrim
default:
return false
}
Expand Down Expand Up @@ -254,6 +259,8 @@ type SmithingTransformRecipe struct {
// RecipeID is a unique ID of the recipe. This ID must be unique amongst all other types of recipes too,
// but its functionality is not exactly known.
RecipeID string
// Template is the item that is used to shape the Base item based on the Addition being applied.
Template ItemDescriptorCount
// Base is the item that the Addition is being applied to in the smithing table.
Base ItemDescriptorCount
// Addition is the item that is being added to the Base item to result in a modified item.
Expand All @@ -265,6 +272,10 @@ type SmithingTransformRecipe struct {
Block string
}

type SmithingTrimRecipe struct {
ShapelessRecipe
}

// Marshal ...
func (recipe *ShapelessRecipe) Marshal(w *Writer) {
marshalShapeless(w, recipe)
Expand Down Expand Up @@ -363,6 +374,7 @@ func (recipe *MultiRecipe) Unmarshal(r *Reader) {
// Marshal ...
func (recipe *SmithingTransformRecipe) Marshal(w *Writer) {
w.String(&recipe.RecipeID)
w.ItemDescriptorCount(&recipe.Template)
w.ItemDescriptorCount(&recipe.Base)
w.ItemDescriptorCount(&recipe.Addition)
w.Item(&recipe.Result)
Expand All @@ -373,13 +385,24 @@ func (recipe *SmithingTransformRecipe) Marshal(w *Writer) {
// Unmarshal ...
func (recipe *SmithingTransformRecipe) Unmarshal(r *Reader) {
r.String(&recipe.RecipeID)
r.ItemDescriptorCount(&recipe.Template)
r.ItemDescriptorCount(&recipe.Base)
r.ItemDescriptorCount(&recipe.Addition)
r.Item(&recipe.Result)
r.String(&recipe.Block)
r.Varuint32(&recipe.RecipeNetworkID)
}

// Marshal ...
func (recipe *SmithingTrimRecipe) Marshal(w *Writer) {
marshalShapeless(w, &recipe.ShapelessRecipe)
}

// Unmarshal ...
func (recipe *SmithingTrimRecipe) Unmarshal(r *Reader) {
marshalShapeless(r, &recipe.ShapelessRecipe)
}

// marshalShaped ...
func marshalShaped(r IO, recipe *ShapedRecipe) {
r.String(&recipe.RecipeID)
Expand Down
25 changes: 25 additions & 0 deletions minecraft/protocol/trim.go
@@ -0,0 +1,25 @@
package protocol

type TrimPattern struct {
ItemName string
PatternID string
}

// Marshal ...
func (x *TrimPattern) Marshal(r IO) {
r.String(&x.ItemName)
r.String(&x.PatternID)
}

type TrimMaterial struct {
MaterialID string
Colour string
ItemName string
}

// Marshal ...
func (x *TrimMaterial) Marshal(r IO) {
r.String(&x.MaterialID)
r.String(&x.Colour)
r.String(&x.ItemName)
}

0 comments on commit 9890e57

Please sign in to comment.