Сборщики контента
Описание предметов, блоков, эффектов, NBT и компонентов.
В этом разделе
Другие страницы раздела:
Регистрация контента
Для своего контента используйте ctx.RegisterBlock(...), ctx.RegisterItem(...), ctx.RegisterEffect(...) и ctx.RegisterEntityType(...). Builders удобны, когда у определения есть hooks, components, drops или параметры контейнера.
content.go
ctx.RegisterBlock(content.DefineBlock("example:crate"). Container(27). Hardness(4). Tool("axe"). Drop(item.New("example:ruby").Stack()). OnInteract(func(event content.BlockContext) error { return nil }). Spec())ctx.RegisterItem(content.DefineItem("example:wand"). MaxCount(1). Component("minecraft:foil", true). OnUseOnBlock(func(event content.ItemContext) error { return event.World.SetBlock(event.Pos, block.New("gold_block").Block()) }). Spec())ctx.RegisterEffect(content.DefineEffect("example:focus"). BedrockID(200). Spec())Предметы и блоки
Builders держат данные рядом с объявлением предмета или блока. Обычные vanilla-имена приводятся к minecraft:<name>, а свой контент должен иметь namespace.
builders.go
sword := item.New("diamond_sword"). Enchant(item.Sharpness(5)). NameTag("Arena Blade"). Lore("Bound to the arena"). NBTTag("pulse:owner", "Steve"). Component("minecraft:foil", true). Stack()blockState := block.New("chest"). String("minecraft:cardinal_direction", "north"). Block()