session

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Nop = &Session{conf: Config{Log: slog.New(slog.DiscardHandler)}}

Functions

func BuildAvailableCommands

func BuildAvailableCommands(
	commands map[string]cmd.Command,
	src cmd.Source,
	softEnums map[string]struct{},
) (*packet.AvailableCommands, map[string]map[int]cmd.Runnable)

Types

type BlockActorDataHandler

type BlockActorDataHandler struct{}

func (BlockActorDataHandler) Handle

type BlockPickRequestHandler

type BlockPickRequestHandler struct{}

func (BlockPickRequestHandler) Handle

type BookEditHandler

type BookEditHandler struct{}

func (BookEditHandler) Handle

func (b BookEditHandler) Handle(p packet.Packet, s *Session, _ *world.Tx, _ Controllable) error

type ClientCacheBlobStatusHandler

type ClientCacheBlobStatusHandler struct {
}

func (*ClientCacheBlobStatusHandler) Handle

type CommandRequestHandler

type CommandRequestHandler struct {
	// contains filtered or unexported fields
}

func (*CommandRequestHandler) Handle

type Config

type Config struct {
	Log *slog.Logger

	MaxChunkRadius int

	EmoteChatMuted bool

	JoinMessage, QuitMessage chat.Translation

	HandleStop func(*world.Tx, Controllable)

	BlockRegistry world.BlockRegistry
}

func (Config) New

func (conf Config) New(conn Conn) *Session

type Conn

type Conn interface {
	io.Closer

	IdentityData() login.IdentityData

	ClientData() login.ClientData

	ClientCacheEnabled() bool

	ChunkRadius() int

	Latency() time.Duration

	Flush() error

	RemoteAddr() net.Addr

	ReadPacket() (pk packet.Packet, err error)

	WritePacket(pk packet.Packet) error

	StartGameContext(ctx context.Context, data minecraft.GameData) error
}

type ContainerCloseHandler

type ContainerCloseHandler struct{}

func (*ContainerCloseHandler) Handle

type Controllable

type Controllable interface {
	Name() string
	world.Entity
	item.User
	dialogue.Submitter
	form.Submitter
	cmd.Source
	chat.Subscriber
	hud.Renderer
	debug.Renderer
	input.Restricter

	Locale() language.Tag

	SetHeldItems(right, left item.Stack)
	SetHeldSlot(slot int) error

	Move(deltaPos mgl64.Vec3, deltaYaw, deltaPitch float64)

	Speed() float64
	FlightSpeed() float64
	VerticalFlightSpeed() float64

	Sleep(pos cube.Pos)
	Wake()

	Chat(msg ...any)
	ExecuteCommand(commandLine string)
	GameMode() world.GameMode
	SetGameMode(mode world.GameMode)
	Effects() []effect.Effect

	UseItem()
	ReleaseItem()
	UseItemOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3)
	UseItemOnEntity(e world.Entity) bool
	BreakBlock(pos cube.Pos)
	PickBlock(pos cube.Pos)
	AttackEntity(e world.Entity) bool
	Drop(s item.Stack) (n int)
	SwingArm()
	PunchAir()

	Health() float64
	MaxHealth() float64
	Absorption() float64
	Food() int

	ExperienceLevel() int
	ExperienceProgress() float64
	SetExperienceLevel(level int)

	EnchantmentSeed() int64
	ResetEnchantmentSeed()

	Respawn() *world.EntityHandle
	Dead() bool

	StartSneaking()
	Sneaking() bool
	StopSneaking()
	StartSprinting()
	Sprinting() bool
	StopSprinting()
	StartSwimming()
	Swimming() bool
	StopSwimming()
	StartCrawling()
	Crawling() bool
	StopCrawling()
	StartFlying()
	Flying() bool
	StopFlying()
	StartGliding()
	Gliding() bool
	StopGliding()
	Jump()

	StartBreaking(pos cube.Pos, face cube.Face)
	ContinueBreaking(face cube.Face)
	FinishBreaking()
	AbortBreaking()

	Exhaust(points float64)

	OpenSign(pos cube.Pos, frontSide bool)
	EditSign(pos cube.Pos, frontText, backText string) error
	TurnLecternPage(pos cube.Pos, page int) error

	EnderChestInventory() *inventory.Inventory
	MoveItemsToInventory()

	UUID() uuid.UUID

	XUID() string

	Skin() skin.Skin
	SetSkin(skin.Skin)

	UpdateDiagnostics(Diagnostics)
}

type Diagnostics

type Diagnostics struct {
	AverageFramesPerSecond float64

	AverageServerSimTickTime float64

	AverageClientSimTickTime float64

	AverageBeginFrameTime float64

	AverageInputTime float64

	AverageRenderTime float64

	AverageEndFrameTime float64

	AverageRemainderTimePercent float64

	AverageUnaccountedTimePercent float64
}

type EmoteHandler

type EmoteHandler struct {
	LastEmote time.Time
}

func (*EmoteHandler) Handle

func (h *EmoteHandler) Handle(p packet.Packet, _ *Session, tx *world.Tx, c Controllable) error

type InteractHandler

type InteractHandler struct{}

func (*InteractHandler) Handle

func (h *InteractHandler) Handle(p packet.Packet, s *Session, _ *world.Tx, c Controllable) error

type InventoryTransactionHandler

type InventoryTransactionHandler struct{}

func (*InventoryTransactionHandler) Handle

func (h *InventoryTransactionHandler) Handle(p packet.Packet, s *Session, tx *world.Tx, c Controllable) (err error)

type ItemStackRequestHandler

type ItemStackRequestHandler struct {
	// contains filtered or unexported fields
}

func (*ItemStackRequestHandler) Handle

type LecternUpdateHandler

type LecternUpdateHandler struct{}

func (LecternUpdateHandler) Handle

type MobEquipmentHandler

type MobEquipmentHandler struct{}

func (*MobEquipmentHandler) Handle

type ModalFormResponseHandler

type ModalFormResponseHandler struct {
	// contains filtered or unexported fields
}

func (*ModalFormResponseHandler) Handle

type NPCRequestHandler

type NPCRequestHandler struct {
	// contains filtered or unexported fields
}

func (*NPCRequestHandler) Handle

func (h *NPCRequestHandler) Handle(p packet.Packet, s *Session, tx *world.Tx, c Controllable) error

type NetworkEncodeableEntity

type NetworkEncodeableEntity interface {
	NetworkEncodeEntity() string
}

type OffsetEntity

type OffsetEntity interface {
	NetworkOffset() float64
}

type PlayerActionHandler

type PlayerActionHandler struct{}

func (*PlayerActionHandler) Handle

type PlayerAuthInputHandler

type PlayerAuthInputHandler struct{}

func (PlayerAuthInputHandler) Handle

type PlayerSkinHandler

type PlayerSkinHandler struct{}

func (PlayerSkinHandler) Handle

type RequestAbilityHandler

type RequestAbilityHandler struct{}

func (RequestAbilityHandler) Handle

type RequestChunkRadiusHandler

type RequestChunkRadiusHandler struct{}

func (*RequestChunkRadiusHandler) Handle

type RespawnHandler

type RespawnHandler struct{}

func (*RespawnHandler) Handle

func (*RespawnHandler) Handle(p packet.Packet, _ *Session, _ *world.Tx, c Controllable) error

type ServerBoundDiagnosticsHandler

type ServerBoundDiagnosticsHandler struct{}

func (*ServerBoundDiagnosticsHandler) Handle

type ServerBoundLoadingScreenHandler

type ServerBoundLoadingScreenHandler struct {
	// contains filtered or unexported fields
}

func (*ServerBoundLoadingScreenHandler) Handle

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) AddDebugShape

func (s *Session) AddDebugShape(shape debug.Shape)

func (*Session) Addr

func (s *Session) Addr() net.Addr

func (*Session) ChangingDimension

func (s *Session) ChangingDimension() bool

func (*Session) ChunkRadius

func (s *Session) ChunkRadius() int32

func (*Session) ClearInputLocks

func (s *Session) ClearInputLocks()

func (*Session) ClientData

func (s *Session) ClientData() login.ClientData

func (*Session) Close

func (s *Session) Close(tx *world.Tx, c Controllable)

func (*Session) CloseConnection

func (s *Session) CloseConnection()

func (*Session) CloseDialogue

func (s *Session) CloseDialogue()

func (*Session) CloseForm

func (s *Session) CloseForm()

func (*Session) Disconnect

func (s *Session) Disconnect(message string)

func (*Session) EnableCoordinates

func (s *Session) EnableCoordinates(enable bool)

func (*Session) EnableInstantRespawn

func (s *Session) EnableInstantRespawn(enable bool)

func (*Session) HandleInventories

func (s *Session) HandleInventories(tx *world.Tx, c Controllable, inv, offHand, enderChest, ui *inventory.Inventory, armour *inventory.Armour, heldSlot *uint32)

func (*Session) HideEntity

func (s *Session) HideEntity(e world.Entity)

func (*Session) HideHudElement

func (s *Session) HideHudElement(e hud.Element)

func (*Session) HudElementHidden

func (s *Session) HudElementHidden(e hud.Element) bool

func (*Session) InputLocked

func (s *Session) InputLocked(l input.Lock) bool

func (*Session) Latency

func (s *Session) Latency() time.Duration

func (*Session) LockInput

func (s *Session) LockInput(l input.Lock)

func (*Session) OpenBlockContainer

func (s *Session) OpenBlockContainer(pos cube.Pos, tx *world.Tx)

func (*Session) OpenSign

func (s *Session) OpenSign(pos cube.Pos, frontSide bool)

func (*Session) PlayLevelSoundEvent

func (s *Session) PlayLevelSoundEvent(soundType string, pos mgl64.Vec3)

func (*Session) PlaySound

func (s *Session) PlaySound(t world.Sound, pos mgl64.Vec3)

func (*Session) RefreshCommands

func (s *Session) RefreshCommands()

func (*Session) RefreshCommandsFor

func (s *Session) RefreshCommandsFor(c Controllable)

func (*Session) RemoveAllDebugShapes

func (s *Session) RemoveAllDebugShapes()

func (*Session) RemoveBossBar

func (s *Session) RemoveBossBar()

func (*Session) RemoveDebugShape

func (s *Session) RemoveDebugShape(shape debug.Shape)

func (*Session) RemoveScoreboard

func (s *Session) RemoveScoreboard()

func (*Session) RemoveViewLayer

func (s *Session) RemoveViewLayer(entity world.Entity)

func (*Session) SendAbilities

func (s *Session) SendAbilities(c Controllable)

func (*Session) SendActionBarMessage

func (s *Session) SendActionBarMessage(text string)

func (*Session) SendAnnouncement

func (s *Session) SendAnnouncement(message string)

func (*Session) SendBossBar

func (s *Session) SendBossBar(text string, colour uint8, healthPercentage float64)

func (*Session) SendChargeItemComplete

func (s *Session) SendChargeItemComplete()

func (*Session) SendCommandOutput

func (s *Session) SendCommandOutput(output *cmd.Output, l language.Tag)

func (*Session) SendDebugShapes

func (s *Session) SendDebugShapes(dim world.Dimension)

func (*Session) SendDialogue

func (s *Session) SendDialogue(d dialogue.Dialogue, e world.Entity)

func (*Session) SendEffect

func (s *Session) SendEffect(e effect.Effect)

func (*Session) SendEffectRemoval

func (s *Session) SendEffectRemoval(e effect.Type)

func (*Session) SendExperience

func (s *Session) SendExperience(level int, progress float64)

func (*Session) SendFood

func (s *Session) SendFood(food int, saturation, exhaustion float64)

func (*Session) SendForm

func (s *Session) SendForm(f form.Form)

func (*Session) SendGameMode

func (s *Session) SendGameMode(c Controllable)

func (*Session) SendGameRule

func (s *Session) SendGameRule(name string, val bool)

func (*Session) SendGameRuleInt

func (s *Session) SendGameRuleInt(name string, val int)

func (*Session) SendHealth

func (s *Session) SendHealth(health, max, absorption float64)

func (*Session) SendHeldSlot

func (s *Session) SendHeldSlot(slot int, c Controllable, force bool)

func (*Session) SendHudUpdates

func (s *Session) SendHudUpdates()

func (*Session) SendInputLocks

func (s *Session) SendInputLocks()

func (*Session) SendJukeboxPopup

func (s *Session) SendJukeboxPopup(message string)

func (*Session) SendMessage

func (s *Session) SendMessage(message string)

func (*Session) SendPlayerSpawn

func (s *Session) SendPlayerSpawn(pos mgl64.Vec3)

func (*Session) SendPopup

func (s *Session) SendPopup(message string)

func (*Session) SendRespawn

func (s *Session) SendRespawn(pos mgl64.Vec3, c Controllable)

func (*Session) SendScoreboard

func (s *Session) SendScoreboard(sb *scoreboard.Scoreboard)

func (*Session) SendSpeed

func (s *Session) SendSpeed(speed float64)

func (*Session) SendSubtitle

func (s *Session) SendSubtitle(text string)

func (*Session) SendTip

func (s *Session) SendTip(message string)

func (*Session) SendTitle

func (s *Session) SendTitle(text string)

func (*Session) SendToast

func (s *Session) SendToast(title, message string)

func (*Session) SendTranslation

func (s *Session) SendTranslation(t chat.Translation, l language.Tag, a []any)

func (*Session) SetHandle

func (s *Session) SetHandle(handle *world.EntityHandle, skin skin.Skin)

func (*Session) SetProxyAddr

func (s *Session) SetProxyAddr(addr net.Addr)

func (*Session) SetTitleDurations

func (s *Session) SetTitleDurations(fadeInDuration, remainDuration, fadeOutDuration time.Duration)

func (*Session) ShowHudElement

func (s *Session) ShowHudElement(e hud.Element)

func (*Session) Spawn

func (s *Session) Spawn(c Controllable, tx *world.Tx)

func (*Session) StartShowingEntity

func (s *Session) StartShowingEntity(e world.Entity)

func (*Session) StopShowingEntity

func (s *Session) StopShowingEntity(e world.Entity)

func (*Session) StopSound

func (s *Session) StopSound(soundName string, stopAll bool)

func (*Session) Transfer

func (s *Session) Transfer(ip net.IP, port int)

func (*Session) UnlockInput

func (s *Session) UnlockInput(l input.Lock)

func (*Session) VerifyAndSetHeldSlot

func (s *Session) VerifyAndSetHeldSlot(slot int, expected item.Stack, c Controllable) error

func (*Session) VerifySlot

func (s *Session) VerifySlot(slot int, expected item.Stack) error

func (*Session) ViewAlwaysShowNameTag

func (s *Session) ViewAlwaysShowNameTag(entity world.Entity, alwaysShow bool)

func (*Session) ViewBlockAction

func (s *Session) ViewBlockAction(pos cube.Pos, a world.BlockAction)

func (*Session) ViewBlockUpdate

func (s *Session) ViewBlockUpdate(pos cube.Pos, b world.Block, layer int)

func (*Session) ViewBrewingUpdate

func (s *Session) ViewBrewingUpdate(prevBrewTime, brewTime time.Duration, prevFuelAmount, fuelAmount, prevFuelTotal, fuelTotal int32)

func (*Session) ViewChunk

func (s *Session) ViewChunk(pos world.ChunkPos, dim world.Dimension, blockEntities map[cube.Pos]world.Block, c *chunk.Chunk)

func (*Session) ViewEmote

func (s *Session) ViewEmote(player world.Entity, emote uuid.UUID)

func (*Session) ViewEntity

func (s *Session) ViewEntity(e world.Entity)

func (*Session) ViewEntityAction

func (s *Session) ViewEntityAction(e world.Entity, a world.EntityAction)

func (*Session) ViewEntityAnimation

func (s *Session) ViewEntityAnimation(e world.Entity, a world.EntityAnimation)

func (*Session) ViewEntityArmour

func (s *Session) ViewEntityArmour(e world.Entity)

func (*Session) ViewEntityDisplacement

func (s *Session) ViewEntityDisplacement(e world.Entity, pos mgl64.Vec3, rot cube.Rotation, onGround bool)

func (*Session) ViewEntityGameMode

func (s *Session) ViewEntityGameMode(e world.Entity)

func (*Session) ViewEntityItems

func (s *Session) ViewEntityItems(e world.Entity)

func (*Session) ViewEntityMovement

func (s *Session) ViewEntityMovement(e world.Entity, pos mgl64.Vec3, rot cube.Rotation, onGround bool)

func (*Session) ViewEntityState

func (s *Session) ViewEntityState(e world.Entity)

func (*Session) ViewEntityTeleport

func (s *Session) ViewEntityTeleport(e world.Entity, position mgl64.Vec3)

func (*Session) ViewEntityVelocity

func (s *Session) ViewEntityVelocity(e world.Entity, velocity mgl64.Vec3)

func (*Session) ViewEntityWake

func (s *Session) ViewEntityWake(e world.Entity)

func (*Session) ViewFurnaceUpdate

func (s *Session) ViewFurnaceUpdate(prevCookTime, cookTime, prevRemainingFuelTime, remainingFuelTime, prevMaxFuelTime, maxFuelTime time.Duration)

func (*Session) ViewItemCooldown

func (s *Session) ViewItemCooldown(item world.Item, duration time.Duration)

func (*Session) ViewLayer

func (s *Session) ViewLayer() *world.ViewLayer

func (*Session) ViewLayerEntityChanged

func (s *Session) ViewLayerEntityChanged(e world.Entity)

func (*Session) ViewNameTag

func (s *Session) ViewNameTag(entity world.Entity, nameTag string)

func (*Session) ViewParticle

func (s *Session) ViewParticle(pos mgl64.Vec3, p world.Particle)

func (*Session) ViewPublicAlwaysShowNameTag

func (s *Session) ViewPublicAlwaysShowNameTag(entity world.Entity)

func (*Session) ViewPublicNameTag

func (s *Session) ViewPublicNameTag(entity world.Entity)

func (*Session) ViewPublicScoreTag

func (s *Session) ViewPublicScoreTag(entity world.Entity)

func (*Session) ViewScoreTag

func (s *Session) ViewScoreTag(entity world.Entity, scoreTag string)

func (*Session) ViewSkin

func (s *Session) ViewSkin(e world.Entity)

func (*Session) ViewSleepingPlayers

func (s *Session) ViewSleepingPlayers(sleeping, max int)

func (*Session) ViewSlotChange

func (s *Session) ViewSlotChange(slot int, newItem item.Stack)

func (*Session) ViewSound

func (s *Session) ViewSound(pos mgl64.Vec3, soundType world.Sound)

func (*Session) ViewSubChunks

func (s *Session) ViewSubChunks(centre world.SubChunkPos, offsets []protocol.SubChunkOffset, tx *world.Tx)

func (*Session) ViewTime

func (s *Session) ViewTime(time int)

func (*Session) ViewTimeCycle

func (s *Session) ViewTimeCycle(doDayLightCycle bool)

func (*Session) ViewVisibility

func (s *Session) ViewVisibility(entity world.Entity, level world.VisibilityLevel)

func (*Session) ViewWeather

func (s *Session) ViewWeather(raining, thunder bool)

func (*Session) ViewWorldSpawn

func (s *Session) ViewWorldSpawn(pos cube.Pos)

func (*Session) VisibleDebugShapes

func (s *Session) VisibleDebugShapes() []debug.Shape

type SubChunkRequestHandler

type SubChunkRequestHandler struct{}

func (*SubChunkRequestHandler) Handle

type TextHandler

type TextHandler struct{}

func (TextHandler) Handle

func (TextHandler) Handle(p packet.Packet, s *Session, _ *world.Tx, c Controllable) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL