Skip to content

Commit

Permalink
protocol: Implement support for 1.20.0 (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Jun 7, 2023
1 parent f10711f commit fa4fd39
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions minecraft/protocol/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
EventTypeCodeBuilderScoreboard
EventTypeStriderRiddenInLavaInOverworld
EventTypeSneakCloseToSculkSensor
EventTypeCarefulRestoration
)

// lookupEvent looks up an Event matching the event type passed. False is
Expand Down
4 changes: 2 additions & 2 deletions minecraft/protocol/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package protocol

const (
// CurrentProtocol is the current protocol version for the version below.
CurrentProtocol = 582
CurrentProtocol = 589
// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
CurrentVersion = "1.19.80"
CurrentVersion = "1.20.0"
)
4 changes: 3 additions & 1 deletion minecraft/protocol/item_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const (
FilterCauseLeaveEventText
FilterCauseSlashCommandChat
FilterCauseCartographyText
FilterCauseSlashCommandNonChat
FilterCauseKickCommand
FilterCauseTitleCommand
FilterCauseSummonCommand
)

// ItemStackRequest represents a single request present in an ItemStackRequest packet sent by the client to
Expand Down
8 changes: 8 additions & 0 deletions minecraft/protocol/packet/emote.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ type Emote struct {
EntityRuntimeID uint64
// EmoteID is the ID of the emote to send.
EmoteID string
// XUID is the Xbox User ID of the player that sent the emote. It is only set when the emote is used by a player that
// is authenticated with Xbox Live.
XUID string
// PlatformID is an identifier only set for particular platforms when using an emote (presumably only for Nintendo
// Switch). It is otherwise an empty string, and is used to decide which players are able to emote with each other.
PlatformID string
// Flags is a combination of flags that change the way the Emote packet operates. When the server sends
// this packet to other players, EmoteFlagServerSide must be present.
Flags byte
Expand All @@ -30,5 +36,7 @@ func (*Emote) ID() uint32 {
func (pk *Emote) Marshal(io protocol.IO) {
io.Varuint64(&pk.EntityRuntimeID)
io.String(&pk.EmoteID)
io.String(&pk.XUID)
io.String(&pk.PlatformID)
io.Uint8(&pk.Flags)
}
4 changes: 4 additions & 0 deletions minecraft/protocol/packet/level_sound_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ const (
SoundEventBrushCompleted
SoundEventShatterDecoratedPot
SoundEventBreakDecoratedPot
SoundEventSnifferEggCrack
SoundEventSnifferEggHatched
SoundEventWaxedSignInteractFail
SoundEventRecordRelic
)

// LevelSoundEvent is sent by the server to make any kind of built-in sound heard to a player. It is sent to,
Expand Down
8 changes: 7 additions & 1 deletion minecraft/protocol/packet/start_game.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ type StartGame struct {
ChatRestrictionLevel uint8
// DisablePlayerInteractions is true if the client should ignore other players when interacting with the world.
DisablePlayerInteractions bool
UseBlockNetworkIDHashes bool
// UseBlockNetworkIDHashes is true if the client should use the hash of a block's name as its network ID rather than
// its index in the expected block palette. This is useful for servers that wish to support multiple protocol versions
// and custom blocks, but it will result in extra bytes being written for every block in a sub chunk palette.
UseBlockNetworkIDHashes bool
// ServerAuthoritativeSound is currently unknown as to what it does.
ServerAuthoritativeSound bool
}

// ID ...
Expand Down Expand Up @@ -315,4 +320,5 @@ func (pk *StartGame) Marshal(io protocol.IO) {
io.UUID(&pk.WorldTemplateID)
io.Bool(&pk.ClientSideGeneration)
io.Bool(&pk.UseBlockNetworkIDHashes)
io.Bool(&pk.ServerAuthoritativeSound)
}
15 changes: 12 additions & 3 deletions minecraft/protocol/packet/unlocked_recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)

const (
UnlockedRecipesTypeEmpty = iota
UnlockedRecipesTypeInitiallyUnlocked
UnlockedRecipesTypeNewlyUnlocked
UnlockedRecipesTypeRemoveUnlocked
UnlockedRecipesTypeRemoveAllUnlocked
)

// UnlockedRecipes gives the client a list of recipes that have been unlocked, restricting the recipes that appear in
// the recipe book.
type UnlockedRecipes struct {
// NewUnlocks determines if new recipes have been unlocked since the packet was last sent.
NewUnlocks bool
// UnlockType is the type of unlock that the packet represents, and can either be adding or removing a list of recipes.
// It is one of the constants listed above.
UnlockType uint32
// Recipes is a list of recipe names that have been unlocked.
Recipes []string
}
Expand All @@ -19,6 +28,6 @@ func (*UnlockedRecipes) ID() uint32 {
}

func (pk *UnlockedRecipes) Marshal(io protocol.IO) {
io.Bool(&pk.NewUnlocks)
io.Uint32(&pk.UnlockType)
protocol.FuncSlice(io, &pk.Recipes, io.String)
}

0 comments on commit fa4fd39

Please sign in to comment.