command

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentAttackRequest

func AgentAttackRequest(direction mctype.Direction) string

AgentAttackRequest produces the command used to make an agent attack.

func AgentDestroyRequest

func AgentDestroyRequest(direction mctype.Direction) string

AgentDestroyRequest produces a command used to make an agent destroy a block in a direction.

func AgentMoveRequest

func AgentMoveRequest(direction mctype.Direction) string

AgentMoveRequest produces the command used to move the agent of a player in a direction.

func AgentPlaceRequest

func AgentPlaceRequest(direction mctype.Direction) string

AgentPlaceRequest produces the command used to make an agent place the block in slot 0 of its inventory.

func AgentPositionRequest

func AgentPositionRequest() string

AgentPositionRequest produces the command used to get the position of a player's agent.

func AgentTillRequest

func AgentTillRequest(direction mctype.Direction) string

AgentTillRequest produces a command used to make an agent till a dirt-like block in a direction.

func AgentTurnRequest

func AgentTurnRequest(direction mctype.Direction) string

AgentTurnRequest produces the command used to turn an agent. The direction must be either left or right.

func ChunkDataRequest

func ChunkDataRequest(dimension string, chunkX, chunkZ int, maxY int) string

ChunkDataRequest produces the command used to get a string of chunk data of a certain chunk. The command is only available on education edition games. This may be enabled using minecraft://?edu=1.

func CloseChatRequest

func CloseChatRequest() string

CloseChatRequest produces the command required to close the chat window of a player.

func EduClientInfoRequest

func EduClientInfoRequest() string

EduClientInfoRequest produces a command that is used to get education edition related information about a connected player.

func EnableEncryptionRequest

func EnableEncryptionRequest(publicKey []byte, salt []byte) string

EnableEncryptionRequest produces the command required to enable encryption using a public key byte slice and salt passed. The salt passed must be exactly 16 bytes long.

func LocalPlayerNameRequest

func LocalPlayerNameRequest() string

LocalPlayerNameRequest produces a command used to get the name of the player connected to a websocket.

func ParseChunkData

func ParseChunkData(data string) (colourMap []color.RGBA, heightMap []byte, err error)

ParseChunkData parses a chunk data string from a ChunkData struct. The values returned are RGB values ordered in XZ order, and a byte slice of the heights, ordered in the same order. If not successful, an error is returned.

func ParticleRequest

func ParticleRequest(particle string, position mctype.Position) string

ParticleRequest produces the command required to spawn a particle using a particle name and position.

func QueryTargetRequest

func QueryTargetRequest(target mctype.Target) string

QueryTargetRequest produces the command used to query information about a target.

func SayRequest

func SayRequest(message string) string

SayRequest produces the command used to broadcast a message to all players in a world.

func SetBlockRequest

func SetBlockRequest(position mctype.BlockPosition, block string, tileData byte, placementMethod string) string

SetBlockRequest produces the command required to place a block in the world of a player. placementMethod can be one of either 'replace', 'destroy' and 'keep'. The effects of each of these is explained on the Minecraft Wiki page here:

func TellRawRequest

func TellRawRequest(target mctype.Target, lines ...string) string

TellRawRequest produces a tell raw command string. The function does not implement logic such as translations and formatting.

func TellRequest

func TellRequest(target mctype.Target, message string) string

TellRequest produces the command required to private message a target.

func TopSolidBlockRequest

func TopSolidBlockRequest(x, z, maxY int) string

TopSolidBlockRequest produces the command required to request the top solid block at a location.

Types

type AgentAttack

type AgentAttack AgentInstruction

AgentAttack is sent by the server to make the agent of a player attack in a direction.

type AgentDestroy

type AgentDestroy AgentInstruction

AgentDestroy is sent by the server to make the agent of a player destroy a block in a direction.

type AgentInstruction

type AgentInstruction struct {
	// StatusCode is the status code of the command. 0 on success.
	StatusCode int `json:"statusCode"`
	// StatusMessage indicates if the command was successful with a message.
	StatusMessage string `json:"statusMessage"`
}

AgentInstruction is a shared structure for agent commands that instruct the agent to do an action.

type AgentMove

type AgentMove AgentInstruction

AgentMove is sent by the server to move the agent of a player.

type AgentPlace

type AgentPlace AgentInstruction

AgentPlace is sent by the server to make the agent of a player place a block in a direction.

type AgentPosition

type AgentPosition struct {
	// YRotation is the rotation on the Y axis of the agent. (yaw) This is always a full number.
	YRotation float64 `json:"y-rot"`
	// Position is the position of the agent. These are always full numbers.
	Position mctype.Position `json:"position"`
	// StatusCode is the status code of the command. 0 on success.
	StatusCode int `json:"statusCode"`
	// StatusMessage indicates if the command was successful with a message.
	StatusMessage string `json:"statusMessage"`
}

AgentPosition is sent by the server to get the position of the agent of a player.

type AgentTill

type AgentTill AgentInstruction

AgentTill is sent by the server to make the agent of a player till a block in a direction. In non-edu mode, this action seems not to work.

type AgentTurn

type AgentTurn AgentInstruction

AgentTurn is sent by the server to turn the agent of a player. The fields are the same as those of the AgentMove response.

type ChunkData

type ChunkData struct {
	// Data is a string of data, with the data being joined with commas. The string has some methods to make
	// consume less space. The Data string is ordered in XZ order. Multiple blocks after each other result in
	// a multiplier being added to the previous. The multiplier needs one added to get the total amount.
	// "AAAAAQ*254" translates to 255 times AAAAAQ in a row.
	// If the same block is found twice in the chunk data at different positions, the second position gets a
	// pointer to the data of the first position. This results in values like these: "jMnVPw,c6SuPw,11,12,11".
	// When having all offsets to their correct data, each string must be base64 decoded. Note that these
	// strings do not end with '=='. This needs to be added if needed.
	// Each of the values that were base64 decoded exist out of 4 bytes. The first 3 bytes are the blue, green
	// and red colours respectively. The last byte is the height of the block.
	Data string `json:"data"`
	// StatusCode is the status code of the command. This is 0 on success.
	StatusCode int `json:"statusCode"`
	// StatusMessage is a message indicating if the command was successful.
	StatusMessage string `json:"statusMessage"`
}

ChunkData is sent by the server to receive a string of chunk data of the highest blocks in a chunk, containing an RGB-24 colour of the blocks and their heights.

type CloseChat

type CloseChat struct {
	// StatusCode is the status code of the command. This is 0 if successful.
	StatusCode int `json:"statusCode"`
	// StatusMessage is the status message of the command. If successful, this is 'Chat closed'.
	StatusMessage string `json:"statusMessage"`
}

CloseChat is sent by the server to force the client to close its chat window.

This is a client-side command which can be called even on third-party servers that do not implement it.

type EduClientInfo

type EduClientInfo struct {
	// IsEdu indicates if the player's game was of education edition.
	IsEdu bool `json:"isEdu"`
	// CompanionProtocolVersion is the 'protocol version' of the learn-to-code agent. This is currently 4.
	CompanionProtocolVersion int `json:"companionProtocolVersion"`
	// IsHost indicates if the player was the host of the game that the player is currently in.
	IsHost bool `json:"isHost"`
	// Permission is the permission level of the player.
	Permission int `json:"permission"`
	// PlayerSessionUUID is the UUID of the session of a player.
	PlayerSessionUUID string `json:"playersessionuuid"`
	// ClientUUID is the UUID of the client.
	ClientUUID string `json:"clientuuid"`
	// StatusCode is the status code of the command. This is 0 when successful.
	StatusCode int `json:"statusCode"`
}

EduClientInfo is sent by the server to receive education information about the player connected to the websocket server. This command is available even if the player is not using education edition.

This is a client-side command which can be called even on third-party servers that do not implement it.

type EnableEncryption

type EnableEncryption struct {
	// PublicKey is the public key of the client. It is base64 encoded, so it must first be decoded before it
	// can be converted to a key.
	PublicKey string `json:"publicKey"`
	// StatusCode is the status code of the command. This is 0 if successful.
	StatusCode int `json:"statusCode"`
	// StatusMessage is the status message of the command. If
	StatusMessage string `json:"statusMessage"`
}

EnableEncryption is sent by the server to enable websocket encryption. The server sends its public key and salt in the command itself, and the client submits its own public key in a response.

This is a client-side command which can be called even on third-party servers that do not implement it.

type LocalPlayerName

type LocalPlayerName struct {
	// LocalPlayerName is the name of the player connected.
	LocalPlayerName string `json:"localplayername"`
	// StatusCode is the status code of the command. This is generally 0 for this command.
	StatusCode int `json:"statusCode"`
	// StatusMessage is the same as LocalPlayerName for this command.
	StatusMessage string `json:"statusMessage"`
}

LocalPlayerName is sent by the server to find out the player name of the player connected to the websocket. This command is executed automatically by the server and stored in a field of the Player struct.

This is a client-side command which can be called even on third-party servers that do not implement it.

type Particle

type Particle struct {
	// StatusCode is the status code of the command. This status code is always non-0, which appears to be
	// a bug in the command.
	StatusCode int `json:"statusCode"`
}

Particle is sent by the server to spawn a particle in the world. It supports both default particles and particles defined using behaviour packs.

type QueryResults

type QueryResults queryResults

QueryResults is a slice with details for all targets matching the query.

func (*QueryResults) UnmarshalJSON

func (results *QueryResults) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a data slice passed and implements the json.Unmarshaler. It is implemented to make sure the details string is unmarshaled to an array properly.

type QueryTarget

type QueryTarget struct {
	// Details is a slice with details for all targets matching the query. It is an escaped JSON string,
	// unlike a proper JSON array as might be expected.
	Details *QueryResults `json:"details"`
	// StatusCode is the status code of the response. If successful, this is 0.
	StatusCode int `json:"statusCode"`
	// StatusMessage is the same as Details, except a string.
	StatusMessage string `json:"statusMessage"`
}

QueryTarget is sent by the server to find out information about entities in the world, in particular the position related information.

type Say

type Say struct {
	// Message is the message that was broadcasted using the command.
	Message string `json:"message"`
	// StatusCode returns the status code of the command. 0 if successful.
	StatusCode int `json:"statusCode"`
}

Say is sent by the server to broadcast a message to all players in a world.

type SetBlock

type SetBlock struct {
	// Position is the position that the block ended up being placed at.
	Position mctype.Position `json:"position"`
	// StatusMessage is the status message of the command. This is 'Block placed' if the command was
	// successful.
	StatusMessage string `json:"statusMessage"`
	// StatusCode is the status code of the command. If successful, this is 0.
	StatusCode int `json:"statusCode"`
}

SetBlock is sent by the server to set a block at a specific position using a particular placement method.

type Tell

type Tell struct {
	// StatusMessage is a message describing the status of the command execution. Executing /tell when the
	// privacy settings of the XBOX Live account of the client did not allow chatting to other players will
	// fail. It will come up with a status message like 'You cannot chat with other players because of how
	// your Xbox Live account is set up.  This can be changed in your privacy & online safety settings on
	// Xbox.com.'
	StatusMessage string `json:"statusMessage"`
	// StatusCode describes the status of the command in a code. 0 if successful.
	StatusCode int `json:"statusCode"`
}

Tell is sent by the server to send a private message from one player to another.

type TellRaw

type TellRaw struct {
	// Recipients is a slice of recipients of the raw message sent. This is useful in the case of unspecific
	// target selectors used.
	Recipients []string `json:"recipient"`
	// StatusCode is the status code of the command. It is 0 on success.
	StatusCode int `json:"statusCode"`
}

TellRaw is sent by the server to send a raw message to a player, possibly with additional formatting options.

type TopSolidBlock

type TopSolidBlock struct {
	// Block is the string block type. For a grass block for example, this is 'grass'.
	Block string `json:"blockName"`
	// AuxType is the metadata value of a block. For a grass block this is 0.
	AuxType int `json:"blockData"`
	// Position is the block position of the block. In particular the Y value is important here, as it
	// indicates the height of the top solid block.
	Position mctype.BlockPosition `json:"position"`
	// StatusCode is the status code of the command. This is 0 on success.
	StatusCode int `json:"statusCode"`
}

TopSolidBlock is sent by the server to find the top solid block under a given position.

Jump to

Keyboard shortcuts

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