1.20.80 support (#1)
This commit is contained in:
32
legacyver/legacypacket/code_builder_source.go
Normal file
32
legacyver/legacypacket/code_builder_source.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// CodeBuilderSource is an Education Edition packet sent by the client to the server to run an operation with a
|
||||
// code builder.
|
||||
type CodeBuilderSource struct {
|
||||
// Operation is used to distinguish the operation performed. It is always one of the constants listed above.
|
||||
Operation byte
|
||||
// Category is used to distinguish the category of the operation performed. It is always one of the constants
|
||||
// listed above.
|
||||
Category byte
|
||||
// CodeStatus is the status of the code builder. It is always one of the constants listed above.
|
||||
CodeStatus byte
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (pk *CodeBuilderSource) ID() uint32 {
|
||||
return packet.IDCodeBuilderSource
|
||||
}
|
||||
|
||||
func (pk *CodeBuilderSource) Marshal(io protocol.IO) {
|
||||
io.Uint8(&pk.Operation)
|
||||
io.Uint8(&pk.Category)
|
||||
if proto.IsProtoGTE(io, proto.ID685) {
|
||||
io.Uint8(&pk.CodeStatus)
|
||||
}
|
||||
}
|
||||
35
legacyver/legacypacket/container_close.go
Normal file
35
legacyver/legacypacket/container_close.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// ContainerClose is sent by the server to close a container the player currently has opened, which was opened
|
||||
// using the ContainerOpen packet, or by the client to tell the server it closed a particular container, such
|
||||
// as the crafting grid.
|
||||
type ContainerClose struct {
|
||||
// WindowID is the ID representing the window of the container that should be closed. It must be equal to
|
||||
// the one sent in the ContainerOpen packet to close the designated window.
|
||||
WindowID byte
|
||||
// ContainerType is the type of container that the server is trying to close. This is used to validate on
|
||||
// the client side whether or not the server's close request is valid.
|
||||
ContainerType byte
|
||||
// ServerSide determines whether or not the container was force-closed by the server. If this value is
|
||||
// not set correctly, the client may ignore the packet and respond with a PacketViolationWarning.
|
||||
ServerSide bool
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*ContainerClose) ID() uint32 {
|
||||
return packet.IDContainerClose
|
||||
}
|
||||
|
||||
func (pk *ContainerClose) Marshal(io protocol.IO) {
|
||||
io.Uint8(&pk.WindowID)
|
||||
if proto.IsProtoGTE(io, proto.ID685) {
|
||||
io.Uint8(&pk.ContainerType)
|
||||
}
|
||||
io.Bool(&pk.ServerSide)
|
||||
}
|
||||
42
legacyver/legacypacket/crafting_data.go
Normal file
42
legacyver/legacypacket/crafting_data.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// CraftingData is sent by the server to let the client know all crafting data that the server maintains. This
|
||||
// includes shapeless crafting, crafting table recipes, furnace recipes etc. Each crafting station's recipes
|
||||
// are included in it.
|
||||
type CraftingData struct {
|
||||
// Recipes is a list of all recipes available on the server. It includes among others shapeless, shaped
|
||||
// and furnace recipes. The client will only be able to craft these recipes.
|
||||
Recipes []proto.Recipe
|
||||
// PotionRecipes is a list of all potion mixing recipes which may be used in the brewing stand.
|
||||
PotionRecipes []protocol.PotionRecipe
|
||||
// PotionContainerChangeRecipes is a list of all recipes to convert a potion from one type to another,
|
||||
// such as from a drinkable potion to a splash potion, or from a splash potion to a lingering potion.
|
||||
PotionContainerChangeRecipes []protocol.PotionContainerChangeRecipe
|
||||
// MaterialReducers is a list of all material reducers which is used in education edition chemistry.
|
||||
MaterialReducers []protocol.MaterialReducer
|
||||
// ClearRecipes indicates if all recipes currently active on the client should be cleaned. Doing this
|
||||
// means that the client will have no recipes active by itself: Any CraftingData packets previously sent
|
||||
// will also be discarded, and only the recipes in this CraftingData packet will be used.
|
||||
ClearRecipes bool
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*CraftingData) ID() uint32 {
|
||||
return packet.IDCraftingData
|
||||
}
|
||||
|
||||
func (pk *CraftingData) Marshal(io protocol.IO) {
|
||||
protocol.FuncSlice(io, &pk.Recipes, func(p *proto.Recipe) {
|
||||
proto.IORecipe(io, p)
|
||||
})
|
||||
protocol.Slice(io, &pk.PotionRecipes)
|
||||
protocol.Slice(io, &pk.PotionContainerChangeRecipes)
|
||||
protocol.FuncSlice(io, &pk.MaterialReducers, io.MaterialReducer)
|
||||
io.Bool(&pk.ClearRecipes)
|
||||
}
|
||||
329
legacyver/legacypacket/start_game.go
Normal file
329
legacyver/legacypacket/start_game.go
Normal file
@@ -0,0 +1,329 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/go-gl/mathgl/mgl32"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sandertv/gophertunnel/minecraft/nbt"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// StartGame is sent by the server to send information about the world the player will be spawned in. It
|
||||
// contains information about the position the player spawns in, and information about the world in general
|
||||
// such as its game rules.
|
||||
type StartGame struct {
|
||||
// EntityUniqueID is the unique ID of the player. The unique ID is a value that remains consistent across
|
||||
// different sessions of the same world, but most servers simply fill the runtime ID of the entity out for
|
||||
// this field.
|
||||
EntityUniqueID int64
|
||||
// EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and
|
||||
// entities are generally identified in packets using this runtime ID.
|
||||
EntityRuntimeID uint64
|
||||
// PlayerGameMode is the game mode the player currently has. It is a value from 0-4, with 0 being
|
||||
// survival mode, 1 being creative mode, 2 being adventure mode, 3 being survival spectator and 4 being
|
||||
// creative spectator.
|
||||
// This field may be set to 5 to make the client fall back to the game mode set in the WorldGameMode
|
||||
// field.
|
||||
PlayerGameMode int32
|
||||
// PlayerPosition is the spawn position of the player in the world. In servers this is often the same as
|
||||
// the world's spawn position found below.
|
||||
PlayerPosition mgl32.Vec3
|
||||
// Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is
|
||||
// measured in degrees.
|
||||
Pitch float32
|
||||
// Yaw is the horizontal rotation of the player. Yaw is also measured in degrees.
|
||||
Yaw float32
|
||||
// WorldSeed is the seed used to generate the world. Unlike in PC edition, the seed is a 32bit integer
|
||||
// here.
|
||||
WorldSeed int64
|
||||
// SpawnBiomeType specifies if the biome that the player spawns in is user defined (through behaviour
|
||||
// packs) or builtin. See the constants above.
|
||||
SpawnBiomeType int16
|
||||
// UserDefinedBiomeName is a readable name of the biome that the player spawned in, such as 'plains'. This
|
||||
// might be a custom biome name if any custom biomes are present through behaviour packs.
|
||||
UserDefinedBiomeName string
|
||||
// Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2, with 0 being
|
||||
// the overworld, 1 being the nether and 2 being the end.
|
||||
Dimension int32
|
||||
// Generator is the generator used for the world. It is a value from 0-4, with 0 being old limited worlds,
|
||||
// 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and 4 being end worlds. A value of
|
||||
// 0 will actually make the client stop rendering chunks you send beyond the world limit.
|
||||
Generator int32
|
||||
// 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
|
||||
// Hardcore is if the world is in hardcore mode. In hardcore mode, the player cannot respawn after dying.
|
||||
Hardcore bool
|
||||
// Difficulty is the difficulty of the world. It is a value from 0-3, with 0 being peaceful, 1 being easy,
|
||||
// 2 being normal and 3 being hard.
|
||||
Difficulty int32
|
||||
// WorldSpawn is the block on which the world spawn of the world. This coordinate has no effect on the
|
||||
// place that the client spawns, but it does have an effect on the direction that a compass points.
|
||||
WorldSpawn protocol.BlockPos
|
||||
// AchievementsDisabled defines if achievements are disabled in the world. The client crashes if this
|
||||
// value is set to true while the player's or the world's game mode is creative, and it's recommended to
|
||||
// simply always set this to false as a server.
|
||||
AchievementsDisabled bool
|
||||
// EditorWorldType is a value to dictate the type of editor mode, a special mode recently introduced adding
|
||||
// "powerful tools for editing worlds, intended for experienced creators." It is one of the constants above.
|
||||
EditorWorldType int32
|
||||
// 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
|
||||
// EducationEditionOffer is some Minecraft: Education Edition field that specifies what 'region' the world
|
||||
// was from, with 0 being None, 1 being RestOfWorld, and 2 being China.
|
||||
// The actual use of this field is unknown.
|
||||
EducationEditionOffer int32
|
||||
// EducationFeaturesEnabled specifies if the world has education edition features enabled, such as the
|
||||
// blocks or entities specific to education edition.
|
||||
EducationFeaturesEnabled bool
|
||||
// EducationProductID is a UUID used to identify the education edition server instance. It is generally
|
||||
// unique for education edition servers.
|
||||
EducationProductID string
|
||||
// RainLevel is the level specifying the intensity of the rain falling. When set to 0, no rain falls at
|
||||
// all.
|
||||
RainLevel float32
|
||||
// LightningLevel is the level specifying the intensity of the thunder. This may actually be set
|
||||
// independently from the RainLevel, meaning dark clouds can be produced without rain.
|
||||
LightningLevel float32
|
||||
// ConfirmedPlatformLockedContent ...
|
||||
ConfirmedPlatformLockedContent bool
|
||||
// MultiPlayerGame specifies if the world is a multi-player game. This should always be set to true for
|
||||
// servers.
|
||||
MultiPlayerGame bool
|
||||
// LANBroadcastEnabled specifies if LAN broadcast was intended to be enabled for the world.
|
||||
LANBroadcastEnabled bool
|
||||
// XBLBroadcastMode is the mode used to broadcast the joined game across XBOX Live.
|
||||
XBLBroadcastMode int32
|
||||
// PlatformBroadcastMode is the mode used to broadcast the joined game across the platform.
|
||||
PlatformBroadcastMode int32
|
||||
// CommandsEnabled specifies if commands are enabled for the player. It is recommended to always set this
|
||||
// to true on the server, as setting it to false means the player cannot, under any circumstance, use a
|
||||
// command.
|
||||
CommandsEnabled bool
|
||||
// TexturePackRequired specifies if the texture pack the world might hold is required, meaning the client
|
||||
// was forced to download it before joining.
|
||||
TexturePackRequired bool
|
||||
// GameRules defines game rules currently active with their respective values. The value of these game
|
||||
// rules may be either 'bool', 'int32' or 'float32'. Some game rules are server side only, and don't
|
||||
// necessarily need to be sent to the client.
|
||||
GameRules []protocol.GameRule
|
||||
// Experiments holds a list of experiments that are either enabled or disabled in the world that the
|
||||
// player spawns in.
|
||||
Experiments []protocol.ExperimentData
|
||||
// ExperimentsPreviouslyToggled specifies if any experiments were previously toggled in this world. It is
|
||||
// probably used for some kind of metrics.
|
||||
ExperimentsPreviouslyToggled bool
|
||||
// BonusChestEnabled specifies if the world had the bonus map setting enabled when generating it. It does
|
||||
// not have any effect client-side.
|
||||
BonusChestEnabled bool
|
||||
// StartWithMapEnabled specifies if the world has the start with map setting enabled, meaning each joining
|
||||
// player obtains a map. This should always be set to false, because the client obtains a map all on its
|
||||
// own accord if this is set to true.
|
||||
StartWithMapEnabled bool
|
||||
// PlayerPermissions is the permission level of the player. It is a value from 0-3, with 0 being visitor,
|
||||
// 1 being member, 2 being operator and 3 being custom.
|
||||
PlayerPermissions int32
|
||||
// ServerChunkTickRadius is the radius around the player in which chunks are ticked. Most servers set this
|
||||
// value to a fixed number, as it does not necessarily affect anything client-side.
|
||||
ServerChunkTickRadius int32
|
||||
// HasLockedBehaviourPack specifies if the behaviour pack of the world is locked, meaning it cannot be
|
||||
// disabled from the world. This is typically set for worlds on the marketplace that have a dedicated
|
||||
// behaviour pack.
|
||||
HasLockedBehaviourPack bool
|
||||
// HasLockedTexturePack specifies if the texture pack of the world is locked, meaning it cannot be
|
||||
// disabled from the world. This is typically set for worlds on the marketplace that have a dedicated
|
||||
// texture pack.
|
||||
HasLockedTexturePack bool
|
||||
// FromLockedWorldTemplate specifies if the world from the server was from a locked world template. For
|
||||
// servers this should always be set to false.
|
||||
FromLockedWorldTemplate bool
|
||||
// MSAGamerTagsOnly ..
|
||||
MSAGamerTagsOnly bool
|
||||
// FromWorldTemplate specifies if the world from the server was from a world template. For servers this
|
||||
// should always be set to false.
|
||||
FromWorldTemplate bool
|
||||
// WorldTemplateSettingsLocked specifies if the world was a template that locks all settings that change
|
||||
// properties above in the settings GUI. It is recommended to set this to true for servers that do not
|
||||
// allow things such as setting game rules through the GUI.
|
||||
WorldTemplateSettingsLocked bool
|
||||
// OnlySpawnV1Villagers is a hack that Mojang put in place to preserve backwards compatibility with old
|
||||
// villagers. The bool is never actually read though, so it has no functionality.
|
||||
OnlySpawnV1Villagers bool
|
||||
// PersonaDisabled is true if persona skins are disabled for the current game session.
|
||||
PersonaDisabled bool
|
||||
// CustomSkinsDisabled is true if custom skins are disabled for the current game session.
|
||||
CustomSkinsDisabled bool
|
||||
// EmoteChatMuted specifies if players will be sent a chat message when using certain emotes.
|
||||
EmoteChatMuted bool
|
||||
// BaseGameVersion is the version of the game from which Vanilla features will be used. The exact function
|
||||
// of this field isn't clear.
|
||||
BaseGameVersion string
|
||||
// LimitedWorldWidth and LimitedWorldDepth are the dimensions of the world if the world is a limited
|
||||
// world. For unlimited worlds, these may simply be left as 0.
|
||||
LimitedWorldWidth, LimitedWorldDepth int32
|
||||
// NewNether specifies if the server runs with the new nether introduced in the 1.16 update.
|
||||
NewNether bool
|
||||
// EducationSharedResourceURI is an education edition feature that transmits education resource settings to clients.
|
||||
EducationSharedResourceURI protocol.EducationSharedResourceURI
|
||||
// ForceExperimentalGameplay specifies if experimental gameplay should be force enabled. For servers this
|
||||
// should always be set to false.
|
||||
ForceExperimentalGameplay protocol.Optional[bool]
|
||||
// LevelID is a base64 encoded world ID that is used to identify the world.
|
||||
LevelID string
|
||||
// WorldName is the name of the world that the player is joining. Note that this field shows up above the
|
||||
// player list for the rest of the game session, and cannot be changed. Setting the server name to this
|
||||
// field is recommended.
|
||||
WorldName string
|
||||
// TemplateContentIdentity is a UUID specific to the premium world template that might have been used to
|
||||
// generate the world. Servers should always fill out an empty string for this.
|
||||
TemplateContentIdentity string
|
||||
// Trial specifies if the world was a trial world, meaning features are limited and there is a time limit
|
||||
// on the world.
|
||||
Trial bool
|
||||
// PlayerMovementSettings ...
|
||||
PlayerMovementSettings protocol.PlayerMovementSettings
|
||||
// Time is the total time that has elapsed since the start of the world.
|
||||
Time int64
|
||||
// EnchantmentSeed is the seed used to seed the random used to produce enchantments in the enchantment
|
||||
// table. Note that the exact correct random implementation must be used to produce the correct results
|
||||
// both client- and server-side.
|
||||
EnchantmentSeed int32
|
||||
// Blocks is a list of all custom blocks registered on the server.
|
||||
Blocks []protocol.BlockEntry
|
||||
// Items is a list of all items with their legacy IDs which are available in the game. Failing to send any
|
||||
// of the items that are in the game will crash mobile clients.
|
||||
Items []protocol.ItemEntry
|
||||
// MultiPlayerCorrelationID is a unique ID specifying the multi-player session of the player. A random
|
||||
// UUID should be filled out for this field.
|
||||
MultiPlayerCorrelationID string
|
||||
// ServerAuthoritativeInventory specifies if the server authoritative inventory system is enabled. This
|
||||
// is a new system introduced in 1.16. Backwards compatibility with the inventory transactions has to
|
||||
// some extent been preserved, but will eventually be removed.
|
||||
ServerAuthoritativeInventory bool
|
||||
// GameVersion is the version of the game the server is running. The exact function of this field isn't clear.
|
||||
GameVersion string
|
||||
// PropertyData contains properties that should be applied on the player. These properties are the same as the
|
||||
// ones that are sent in the SyncActorProperty packet.
|
||||
PropertyData map[string]any
|
||||
// ServerBlockStateChecksum is a checksum to ensure block states between the server and client match.
|
||||
// This can simply be left empty, and the client will avoid trying to verify it.
|
||||
ServerBlockStateChecksum uint64
|
||||
// ClientSideGeneration is true if the client should use the features registered in the FeatureRegistry packet to
|
||||
// generate terrain client-side to save on bandwidth.
|
||||
ClientSideGeneration bool
|
||||
// WorldTemplateID is a UUID that identifies the template that was used to generate the world. Servers that do not
|
||||
// use a world based off of a template can set this to an empty UUID.
|
||||
WorldTemplateID uuid.UUID
|
||||
// ChatRestrictionLevel specifies the level of restriction on in-game chat. It is one of the constants above.
|
||||
ChatRestrictionLevel uint8
|
||||
// DisablePlayerInteractions is true if the client should ignore other players when interacting with the world.
|
||||
DisablePlayerInteractions bool
|
||||
// ServerID is always empty in vanilla and its usage is currently unknown.
|
||||
ServerID string
|
||||
// WorldID is always empty in vanilla and its usage is currently unknown.
|
||||
WorldID string
|
||||
// ScenarioID is always empty in vanilla and its usage is currently unknown.
|
||||
ScenarioID string
|
||||
// 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 ...
|
||||
func (*StartGame) ID() uint32 {
|
||||
return packet.IDStartGame
|
||||
}
|
||||
|
||||
func (pk *StartGame) Marshal(io protocol.IO) {
|
||||
io.Varint64(&pk.EntityUniqueID)
|
||||
io.Varuint64(&pk.EntityRuntimeID)
|
||||
io.Varint32(&pk.PlayerGameMode)
|
||||
io.Vec3(&pk.PlayerPosition)
|
||||
io.Float32(&pk.Pitch)
|
||||
io.Float32(&pk.Yaw)
|
||||
io.Int64(&pk.WorldSeed)
|
||||
io.Int16(&pk.SpawnBiomeType)
|
||||
io.String(&pk.UserDefinedBiomeName)
|
||||
io.Varint32(&pk.Dimension)
|
||||
io.Varint32(&pk.Generator)
|
||||
io.Varint32(&pk.WorldGameMode)
|
||||
io.Bool(&pk.Hardcore)
|
||||
io.Varint32(&pk.Difficulty)
|
||||
io.UBlockPos(&pk.WorldSpawn)
|
||||
io.Bool(&pk.AchievementsDisabled)
|
||||
io.Varint32(&pk.EditorWorldType)
|
||||
io.Bool(&pk.CreatedInEditor)
|
||||
io.Bool(&pk.ExportedFromEditor)
|
||||
io.Varint32(&pk.DayCycleLockTime)
|
||||
io.Varint32(&pk.EducationEditionOffer)
|
||||
io.Bool(&pk.EducationFeaturesEnabled)
|
||||
io.String(&pk.EducationProductID)
|
||||
io.Float32(&pk.RainLevel)
|
||||
io.Float32(&pk.LightningLevel)
|
||||
io.Bool(&pk.ConfirmedPlatformLockedContent)
|
||||
io.Bool(&pk.MultiPlayerGame)
|
||||
io.Bool(&pk.LANBroadcastEnabled)
|
||||
io.Varint32(&pk.XBLBroadcastMode)
|
||||
io.Varint32(&pk.PlatformBroadcastMode)
|
||||
io.Bool(&pk.CommandsEnabled)
|
||||
io.Bool(&pk.TexturePackRequired)
|
||||
protocol.FuncSlice(io, &pk.GameRules, io.GameRule)
|
||||
protocol.SliceUint32Length(io, &pk.Experiments)
|
||||
io.Bool(&pk.ExperimentsPreviouslyToggled)
|
||||
io.Bool(&pk.BonusChestEnabled)
|
||||
io.Bool(&pk.StartWithMapEnabled)
|
||||
io.Varint32(&pk.PlayerPermissions)
|
||||
io.Int32(&pk.ServerChunkTickRadius)
|
||||
io.Bool(&pk.HasLockedBehaviourPack)
|
||||
io.Bool(&pk.HasLockedTexturePack)
|
||||
io.Bool(&pk.FromLockedWorldTemplate)
|
||||
io.Bool(&pk.MSAGamerTagsOnly)
|
||||
io.Bool(&pk.FromWorldTemplate)
|
||||
io.Bool(&pk.WorldTemplateSettingsLocked)
|
||||
io.Bool(&pk.OnlySpawnV1Villagers)
|
||||
io.Bool(&pk.PersonaDisabled)
|
||||
io.Bool(&pk.CustomSkinsDisabled)
|
||||
io.Bool(&pk.EmoteChatMuted)
|
||||
io.String(&pk.BaseGameVersion)
|
||||
io.Int32(&pk.LimitedWorldWidth)
|
||||
io.Int32(&pk.LimitedWorldDepth)
|
||||
io.Bool(&pk.NewNether)
|
||||
protocol.Single(io, &pk.EducationSharedResourceURI)
|
||||
protocol.OptionalFunc(io, &pk.ForceExperimentalGameplay, io.Bool)
|
||||
io.Uint8(&pk.ChatRestrictionLevel)
|
||||
io.Bool(&pk.DisablePlayerInteractions)
|
||||
if proto.IsProtoGTE(io, proto.ID685) {
|
||||
io.String(&pk.ServerID)
|
||||
io.String(&pk.WorldID)
|
||||
io.String(&pk.ScenarioID)
|
||||
}
|
||||
io.String(&pk.LevelID)
|
||||
io.String(&pk.WorldName)
|
||||
io.String(&pk.TemplateContentIdentity)
|
||||
io.Bool(&pk.Trial)
|
||||
protocol.PlayerMoveSettings(io, &pk.PlayerMovementSettings)
|
||||
io.Int64(&pk.Time)
|
||||
io.Varint32(&pk.EnchantmentSeed)
|
||||
protocol.Slice(io, &pk.Blocks)
|
||||
protocol.Slice(io, &pk.Items)
|
||||
io.String(&pk.MultiPlayerCorrelationID)
|
||||
io.Bool(&pk.ServerAuthoritativeInventory)
|
||||
io.String(&pk.GameVersion)
|
||||
io.NBT(&pk.PropertyData, nbt.NetworkLittleEndian)
|
||||
io.Uint64(&pk.ServerBlockStateChecksum)
|
||||
io.UUID(&pk.WorldTemplateID)
|
||||
io.Bool(&pk.ClientSideGeneration)
|
||||
io.Bool(&pk.UseBlockNetworkIDHashes)
|
||||
io.Bool(&pk.ServerAuthoritativeSound)
|
||||
}
|
||||
79
legacyver/legacypacket/text.go
Normal file
79
legacyver/legacypacket/text.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package legacypacket
|
||||
|
||||
import (
|
||||
"github.com/akmalfairuz/legacy-version/legacyver/proto"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
const (
|
||||
TextTypeRaw = iota
|
||||
TextTypeChat
|
||||
TextTypeTranslation
|
||||
TextTypePopup
|
||||
TextTypeJukeboxPopup
|
||||
TextTypeTip
|
||||
TextTypeSystem
|
||||
TextTypeWhisper
|
||||
TextTypeAnnouncement
|
||||
TextTypeObjectWhisper
|
||||
TextTypeObject
|
||||
TextTypeObjectAnnouncement
|
||||
)
|
||||
|
||||
// Text is sent by the client to the server to send chat messages, and by the server to the client to forward
|
||||
// or send messages, which may be chat, popups, tips etc.
|
||||
type Text struct {
|
||||
// TextType is the type of the text sent. When a client sends this to the server, it should always be
|
||||
// TextTypeChat. If the server sends it, it may be one of the other text types above.
|
||||
TextType byte
|
||||
// NeedsTranslation specifies if any of the messages need to be translated. It seems that where % is found
|
||||
// in translatable text types, these are translated regardless of this bool. Translatable text types
|
||||
// include TextTypeTranslation, TextTypeTip, TextTypePopup and TextTypeJukeboxPopup.
|
||||
NeedsTranslation bool
|
||||
// SourceName is the name of the source of the messages. This source is displayed in text types such as
|
||||
// the TextTypeChat and TextTypeWhisper, where typically the username is shown.
|
||||
SourceName string
|
||||
// Message is the message of the packet. This field is set for each TextType and is the main component of
|
||||
// the packet.
|
||||
Message string
|
||||
// Parameters is a list of parameters that should be filled into the message. These parameters are only
|
||||
// written if the type of the packet is TextTypeTranslation, TextTypeTip, TextTypePopup or TextTypeJukeboxPopup.
|
||||
Parameters []string
|
||||
// XUID is the XBOX Live user ID of the player that sent the message. It is only set for packets of
|
||||
// TextTypeChat. When sent to a player, the player will only be shown the chat message if a player with
|
||||
// this XUID is present in the player list and not muted, or if the XUID is empty.
|
||||
XUID string
|
||||
// PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for
|
||||
// Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to
|
||||
// chat with each other.
|
||||
PlatformChatID string
|
||||
// FilteredMessage is a filtered version of Message with all the profanity removed. The client will use
|
||||
// this over Message if this field is not empty and they have the "Filter Profanity" setting enabled.
|
||||
FilteredMessage string
|
||||
}
|
||||
|
||||
// ID ...
|
||||
func (*Text) ID() uint32 {
|
||||
return packet.IDText
|
||||
}
|
||||
|
||||
func (pk *Text) Marshal(io protocol.IO) {
|
||||
io.Uint8(&pk.TextType)
|
||||
io.Bool(&pk.NeedsTranslation)
|
||||
switch pk.TextType {
|
||||
case TextTypeChat, TextTypeWhisper, TextTypeAnnouncement:
|
||||
io.String(&pk.SourceName)
|
||||
io.String(&pk.Message)
|
||||
case TextTypeRaw, TextTypeTip, TextTypeSystem, TextTypeObject, TextTypeObjectWhisper, TextTypeObjectAnnouncement:
|
||||
io.String(&pk.Message)
|
||||
case TextTypeTranslation, TextTypePopup, TextTypeJukeboxPopup:
|
||||
io.String(&pk.Message)
|
||||
protocol.FuncSlice(io, &pk.Parameters, io.String)
|
||||
}
|
||||
io.String(&pk.XUID)
|
||||
io.String(&pk.PlatformChatID)
|
||||
if proto.IsProtoGTE(io, proto.ID685) {
|
||||
io.String(&pk.FilteredMessage)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user