palette

package
v0.0.0-...-6250647 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blocks

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

Blocks is a Palette that exists out of a slice of world.Block. It is a static palette in the sense that the blocks returned in the Blocks method do not change.

func NewBlocks

func NewBlocks(b []world.Block) Blocks

NewBlocks creates a Blocks palette that returns the blocks passed in the Blocks method.

func Read

func Read(r io.Reader) (Blocks, error)

Read reads a Blocks palette from an io.Reader.

func (Blocks) Blocks

func (b Blocks) Blocks() []world.Block

Blocks returns all world.Block passed to the NewBlocks function upon creation of the palette.

func (Blocks) Write

func (b Blocks) Write(w io.Writer) error

Write writes a Blocks palette to an io.Writer.

type DeleteCommand

type DeleteCommand struct {
	Sub cmd.SubCommand `cmd:"delete"`
	// Name is the name of the palette to delete. Upon deleting, the palette will be removed from the database
	// it is stored in.
	Name paletteName `cmd:"name"`
	// contains filtered or unexported fields
}

DeleteCommand implements the deletion of palettes previously saved using SaveCommand.

func (DeleteCommand) Allow

func (DeleteCommand) Allow(src cmd.Source) bool

Allow returns false if the cmd.Source passed is not of the type *player.Player.

func (DeleteCommand) Run

func (d DeleteCommand) Run(src cmd.Source, o *cmd.Output)

Run allows a *player.Player to delete a palette previously saved using /palette save.

type Handler

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

Handler handles the selection and storage of palettes during the session of a player.

func LookupHandler

func LookupHandler(p *player.Player) (*Handler, bool)

LookupHandler finds the Handler of a specific player.Player, assuming it is currently online.

func NewHandler

func NewHandler(p *player.Player) *Handler

NewHandler creates a Handler for the *player.Player passed.

func (*Handler) HandleBlockBreak

func (h *Handler) HandleBlockBreak(ctx *event.Context, pos cube.Pos, _ *[]item.Stack)

HandleBlockBreak handles selection of a block for the palette.

func (*Handler) HandleItemUseOnBlock

func (h *Handler) HandleItemUseOnBlock(ctx *event.Context, pos cube.Pos, _ cube.Face, _ mgl64.Vec3)

HandleItemUseOnBlock handles selection of a block for the palette.

func (*Handler) HandleQuit

func (h *Handler) HandleQuit()

HandleQuit deletes the Handler from the handlers map.

func (*Handler) Palette

func (h *Handler) Palette(name string) (Palette, bool)

Palette looks up the Palette with the name passed. If found, the Palette returned is non-nil and the bool true.

If "m" or "M" is passed as Palette, the Palette will always be non-nil. Note that this Palette might still, however, be zero. This should be checked for using len(Palette.Blocks()).

type Palette

type Palette interface {
	// Blocks returns the list of world.Block that should be used as palette for a world edit action. Blocks can
	// return the same world.Block multiple times to change the occurrence of one block vs another block.
	Blocks() []world.Block
}

Palette is a source for a selection of world.Block to be used in a world edit action.

type SaveCommand

type SaveCommand struct {
	Sub cmd.SubCommand `cmd:"save"`
	// Name is the name by which the palette currently selected should be saved. The palette will be saved to a
	// database so that it can be reloaded when the server restarts.
	Name string `cmd:"name"`
	// contains filtered or unexported fields
}

SaveCommand implements the saving of palettes to disk, so that they may be re-used.

func (SaveCommand) Allow

func (SaveCommand) Allow(src cmd.Source) bool

Allow returns false if the cmd.Source passed is not of the type *player.Player.

func (SaveCommand) Run

func (s SaveCommand) Run(src cmd.Source, o *cmd.Output)

Run allows a *player.Player to save the Selection previously created using /palette to disk with a specific name, so that it can be re-used.

type Selection

type Selection struct {
	geo.Area
	// contains filtered or unexported fields
}

Selection is a Palette implementation based on a selection done by a player in a world. It is directly tied to that world and cannot return the blocks without it.

func NewSelection

func NewSelection(a, b cube.Pos, w *world.World) Selection

NewSelection creates a new Selection based on the two corners and a world.

func (Selection) Blocks

func (p Selection) Blocks() []world.Block

Blocks returns all world.Block present between two corners in the world passed to NewSelection upon creation.

func (Selection) Zero

func (p Selection) Zero() bool

Zero checks if the Selection was set and created using NewSelection. It also checks if the we.Area held by the Selection is non-zero.

type SetCommand

type SetCommand struct {
	Sub cmd.SubCommand `cmd:"set"`
	// contains filtered or unexported fields
}

SetCommand implements the selection of a Selection palette in the world that a player is in. This palette may later be saved using SaveCommand.

func (SetCommand) Allow

func (SetCommand) Allow(src cmd.Source) bool

Allow returns false if the cmd.Source passed is not of the type *player.Player.

func (SetCommand) Run

func (c SetCommand) Run(src cmd.Source, o *cmd.Output)

Run enables palette selection for the *player.Player that runs the command.

Jump to

Keyboard shortcuts

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