nbt_parser_block

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopyAndFixStates

func DeepCopyAndFixStates(blockType uint8, blockName string, blockStates map[string]any) map[string]any

DeepCopyAndFixStates 先深拷贝 blockStates,然后修复类型为 blockType, 方块名称为 blockName 且方块状态为 blockStates 的方块的方块状态。

这主要用于解决导入时产生的不可能问题,即用户提供的方块状态可能包含 一些不可能抵达的成分,例如一些方块状态字段指示了这个方块是否被红石 激活等。 在实际导入时,我们并不会提供红石信号,这意味着放置的方块在很大程度上, 其方块状态会被纠正 (例如改变为没有红石激活的情况)。

基于此,我们需要结合导入的实际环境,修正传入方块的方块状态。 DeepCopyAndFixStates 在实现上是深拷贝的,这意味着使用者可以安全的修改返回值

func ParseBlock

func ParseBlock(
	nameChecker func(name string) bool,
	blockName string,
	blockStates map[string]any,
	blockNBT map[string]any,
) (block nbt_parser_interface.Block, err error)

ParseBlock 从方块实体数据 blockNBT 解析一个方块实体。 blockName 和 blockStates 分别指示这个方块实体的名称和方块状态。

nameChecker 是一个可选的函数,用于检查 name 所指示的物品名称是 否可通过指令获取。如果不能,则 nameChecker 返回假。

nameChecker 对于大多数方块的解析可能没有帮助,但它可以帮助验证 容器内的物品是否是可以通过指令获取的物品。

另外,如果没有这样的 nameChecker 函数,则可以将其简单的置为 nil

func SetShulkerBoxFacing

func SetShulkerBoxFacing(container nbt_parser_interface.Block, facing uint8)

SetShulkerBoxFacing 将 container 的潜影盒朝向设置为 facing。 SetShulkerBoxFacing 假定 container 可以被断言为 Container。 如果不是 Container,则 SetShulkerBoxFacing 将不执行任何操作

Types

type Banner struct {
	DefaultBlock
	NBT BannerNBT
}

旗帜

func (*Banner) Format

func (b *Banner) Format(prefix string) string

func (*Banner) FullStableBytes

func (b *Banner) FullStableBytes() []byte

func (Banner) NBTStableBytes

func (b Banner) NBTStableBytes() []byte

func (Banner) NeedCheckCompletely

func (b Banner) NeedCheckCompletely() bool

func (Banner) NeedSpecialHandle

func (b Banner) NeedSpecialHandle() bool

func (*Banner) Parse

func (b *Banner) Parse(nbtMap map[string]any) error

type BannerNBT

type BannerNBT struct {
	Base     int32
	Patterns []nbt_parser_general.BannerPattern
	Type     int32
}

BannerNBT ..

type BrewingStand

type BrewingStand struct {
	DefaultBlock
	NBT BrewingStandNBT
}

酿造台

func (*BrewingStand) Format

func (b *BrewingStand) Format(prefix string) string

func (*BrewingStand) FullStableBytes

func (b *BrewingStand) FullStableBytes() []byte

func (BrewingStand) NBTStableBytes

func (b BrewingStand) NBTStableBytes() []byte

func (BrewingStand) NeedCheckCompletely

func (BrewingStand) NeedCheckCompletely() bool

func (*BrewingStand) NeedSpecialHandle

func (b *BrewingStand) NeedSpecialHandle() bool

func (*BrewingStand) Parse

func (b *BrewingStand) Parse(nbtMap map[string]any) error

type BrewingStandNBT

type BrewingStandNBT struct {
	Items      []ItemWithSlot
	CustomName string
}

BrewingStandNBT ..

type CommandBlock

type CommandBlock struct {
	DefaultBlock
	NBT CommandBlockNBT
}

命令方块

func (*CommandBlock) Format

func (c *CommandBlock) Format(prefix string) string

func (*CommandBlock) FullStableBytes

func (c *CommandBlock) FullStableBytes() []byte

func (CommandBlock) NBTStableBytes

func (c CommandBlock) NBTStableBytes() []byte

func (CommandBlock) NeedCheckCompletely

func (c CommandBlock) NeedCheckCompletely() bool

func (*CommandBlock) NeedSpecialHandle

func (c *CommandBlock) NeedSpecialHandle() bool

func (*CommandBlock) Parse

func (c *CommandBlock) Parse(nbtMap map[string]any) error

type CommandBlockNBT

type CommandBlockNBT struct {
	Command            string `mapstructure:"Command"`
	CustomName         string `mapstructure:"CustomName"`
	TickDelay          int32  `mapstructure:"TickDelay"`
	ExecuteOnFirstTick byte   `mapstructure:"ExecuteOnFirstTick"`
	TrackOutput        byte   `mapstructure:"TrackOutput"`
	ConditionalMode    byte   `mapstructure:"conditionalMode"`
	Auto               byte   `mapstructure:"auto"`
}

CommandBlockNBT ..

type Container

type Container struct {
	DefaultBlock
	NBT ContainerNBT
}

容器

func (*Container) ConsiderOpenDirection

func (c *Container) ConsiderOpenDirection() bool

ConsiderOpenDirection 指示打开目标容器 是否需要考虑其打开方向上的障碍物方块, 这似乎只对箱子和潜影盒有效

func (*Container) Format

func (c *Container) Format(prefix string) string

func (*Container) FullStableBytes

func (c *Container) FullStableBytes() []byte

func (Container) NBTStableBytes

func (c Container) NBTStableBytes() []byte

func (Container) NeedCheckCompletely

func (c Container) NeedCheckCompletely() bool

func (*Container) NeedSpecialHandle

func (c *Container) NeedSpecialHandle() bool

func (*Container) Parse

func (c *Container) Parse(nbtMap map[string]any) error

func (*Container) SetBytes

func (c *Container) SetBytes() []byte

type ContainerNBT

type ContainerNBT struct {
	Items         []ItemWithSlot
	CustomName    string
	ShulkerFacing uint8
}

ContainerNBT ..

type Crafter

type Crafter struct {
	DefaultBlock
	NBT CratferNBT
}

合成器

func (*Crafter) AsContainer

func (c *Crafter) AsContainer() *Container

func (*Crafter) Format

func (c *Crafter) Format(prefix string) string

func (*Crafter) FullStableBytes

func (c *Crafter) FullStableBytes() []byte

func (*Crafter) NBTStableBytes

func (c *Crafter) NBTStableBytes() []byte

func (Crafter) NeedCheckCompletely

func (c Crafter) NeedCheckCompletely() bool

func (*Crafter) NeedSpecialHandle

func (c *Crafter) NeedSpecialHandle() bool

func (*Crafter) Parse

func (c *Crafter) Parse(nbtMap map[string]any) error

type CratferNBT

type CratferNBT struct {
	ContainerInfo ContainerNBT
	DisabledSlots int16
}

CratferNBT ..

type DefaultBlock

type DefaultBlock struct {
	Name        string
	States      map[string]any
	NameChecker func(name string) bool
}

默认 NBT 实体

func (*DefaultBlock) BlockName

func (d *DefaultBlock) BlockName() string

func (DefaultBlock) BlockStates

func (d DefaultBlock) BlockStates() map[string]any

func (DefaultBlock) BlockStatesString

func (d DefaultBlock) BlockStatesString() string

func (*DefaultBlock) Format

func (d *DefaultBlock) Format(prefix string) string

func (*DefaultBlock) FullStableBytes

func (d *DefaultBlock) FullStableBytes() []byte

func (DefaultBlock) NBTStableBytes

func (DefaultBlock) NBTStableBytes() []byte

func (DefaultBlock) NeedCheckCompletely

func (DefaultBlock) NeedCheckCompletely() bool

func (DefaultBlock) NeedSpecialHandle

func (DefaultBlock) NeedSpecialHandle() bool

func (*DefaultBlock) Parse

func (*DefaultBlock) Parse(nbtMap map[string]any) error

type Frame

type Frame struct {
	DefaultBlock
	NBT FrameNBT
}

物品展示框

func (*Frame) Format

func (f *Frame) Format(prefix string) string

func (*Frame) FullStableBytes

func (f *Frame) FullStableBytes() []byte

func (Frame) NBTStableBytes

func (f Frame) NBTStableBytes() []byte

func (Frame) NeedCheckCompletely

func (f Frame) NeedCheckCompletely() bool

func (Frame) NeedSpecialHandle

func (f Frame) NeedSpecialHandle() bool

func (*Frame) Parse

func (f *Frame) Parse(nbtMap map[string]any) error

type FrameNBT

type FrameNBT struct {
	ItemRotation float32
	HaveItem     bool
	Item         nbt_parser_interface.Item
}

FrameNBT ..

type ItemWithSlot

type ItemWithSlot struct {
	Item nbt_parser_interface.Item
	Slot uint8
}

ItemWithSlot ..

func (ItemWithSlot) Format

func (i ItemWithSlot) Format(prefix string) string

Format ..

type JukeBox

type JukeBox struct {
	DefaultBlock
	NBT JukeBoxNBT
}

唱片机

func (*JukeBox) Format

func (j *JukeBox) Format(prefix string) string

func (*JukeBox) FullStableBytes

func (j *JukeBox) FullStableBytes() []byte

func (JukeBox) NBTStableBytes

func (j JukeBox) NBTStableBytes() []byte

func (JukeBox) NeedCheckCompletely

func (JukeBox) NeedCheckCompletely() bool

func (JukeBox) NeedSpecialHandle

func (j JukeBox) NeedSpecialHandle() bool

func (*JukeBox) Parse

func (j *JukeBox) Parse(nbtMap map[string]any) error

type JukeBoxNBT

type JukeBoxNBT struct {
	CustomName string
	HaveDisc   bool
	Disc       nbt_parser_interface.Item
}

JukeBoxNBT ..

type Lectern

type Lectern struct {
	DefaultBlock
	NBT LecternNBT
}

讲台

func (*Lectern) Format

func (l *Lectern) Format(prefix string) string

func (*Lectern) FullStableBytes

func (l *Lectern) FullStableBytes() []byte

func (Lectern) NBTStableBytes

func (l Lectern) NBTStableBytes() []byte

func (Lectern) NeedCheckCompletely

func (Lectern) NeedCheckCompletely() bool

func (Lectern) NeedSpecialHandle

func (l Lectern) NeedSpecialHandle() bool

func (*Lectern) Parse

func (l *Lectern) Parse(nbtMap map[string]any) error

type LecternNBT

type LecternNBT struct {
	CustomName string
	HaveBook   bool
	Book       nbt_parser_interface.Item
}

LecternNBT ..

type Sign

type Sign struct {
	DefaultBlock
	NBT SignNBT
}

告示牌

func (*Sign) Format

func (s *Sign) Format(prefix string) string

func (*Sign) FullStableBytes

func (s *Sign) FullStableBytes() []byte

func (Sign) NBTStableBytes

func (s Sign) NBTStableBytes() []byte

func (Sign) NeedCheckCompletely

func (s Sign) NeedCheckCompletely() bool

func (*Sign) NeedSpecialHandle

func (s *Sign) NeedSpecialHandle() bool

func (*Sign) Parse

func (s *Sign) Parse(nbtMap map[string]any) error

type SignNBT

type SignNBT struct {
	IsWaxed   byte     `mapstructure:"IsWaxed"`
	FrontText SignText `mapstructure:"FrontText"`
	BackText  SignText `mapstructure:"BackText"`
}

SignNBT ..

type SignText

type SignText struct {
	IgnoreLighting byte   `mapstructure:"IgnoreLighting"`
	SignTextColor  int32  `mapstructure:"SignTextColor"`
	Text           string `mapstructure:"Text"`
}

SignText ..

type StructureBlock

type StructureBlock struct {
	DefaultBlock
	NBT StructureBlockNBT
}

结构方块

func (*StructureBlock) Format

func (s *StructureBlock) Format(prefix string) string

func (*StructureBlock) FullStableBytes

func (s *StructureBlock) FullStableBytes() []byte

func (StructureBlock) NBTStableBytes

func (s StructureBlock) NBTStableBytes() []byte

func (StructureBlock) NeedCheckCompletely

func (s StructureBlock) NeedCheckCompletely() bool

func (StructureBlock) NeedSpecialHandle

func (s StructureBlock) NeedSpecialHandle() bool

func (*StructureBlock) Parse

func (s *StructureBlock) Parse(nbtMap map[string]any) error

type StructureBlockNBT

type StructureBlockNBT struct {
	AnimationMode    byte    `mapstructure:"animationMode"`
	AnimationSeconds float32 `mapstructure:"animationSeconds"`
	Data             int32   `mapstructure:"data"`
	DataField        string  `mapstructure:"dataField"`
	IgnoreEntities   byte    `mapstructure:"ignoreEntities"`
	IncludePlayers   byte    `mapstructure:"includePlayers"`
	Integrity        float32 `mapstructure:"integrity"`
	Mirror           byte    `mapstructure:"mirror"`
	RedstoneSaveMode int32   `mapstructure:"redstoneSaveMode"`
	RemoveBlocks     byte    `mapstructure:"removeBlocks"`
	Rotation         byte    `mapstructure:"rotation"`
	Seed             int64   `mapstructure:"seed"`
	ShowBoundingBox  byte    `mapstructure:"showBoundingBox"`
	StructureName    string  `mapstructure:"structureName"`
	XStructureOffset int32   `mapstructure:"xStructureOffset"`
	XStructureSize   int32   `mapstructure:"xStructureSize"`
	YStructureOffset int32   `mapstructure:"yStructureOffset"`
	YStructureSize   int32   `mapstructure:"yStructureSize"`
	ZStructureOffset int32   `mapstructure:"zStructureOffset"`
	ZStructureSize   int32   `mapstructure:"zStructureSize"`
}

StructureBlockNBT ..

Jump to

Keyboard shortcuts

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