XiaoMoMi Plugins
δΈ­ζ–‡η»΄εŸΊ
CraftEngine
CraftEngine
  • Plugin Wiki
    • 🏭️ CraftEngine
      • πŸ“ Atlas [MUST READ]
      • πŸ—ΊοΈ Mipmap [MUST READ]
      • βž•οΈ Add New Contents
        • πŸ“„ Templates [MUST READ]
          • 🟒 Argument Types
        • 🏭️ Model Generation
        • πŸͺ‡ Events
        • βš–οΈ Conditions
        • πŸ“– Recipes
        • πŸ’Ž Loot Table
        • πŸͺ‘ Furniture
          • βš™οΈ Furniture Settings
          • πŸ•ΉοΈ Furniture Behaviors
          • πŸ“ Furniture Placement
        • πŸ—‘οΈ Items
          • πŸ”’ Item Data
            • πŸ”’ Client Bound Item Data
          • βš™οΈ Item Settings
          • πŸ•ΉοΈ Item Behaviors
            • πŸͺ‘ Furniture Item
            • 🧱 Block Item
              • 🌊 Liquid Collision Block Item
            • πŸͺΉ Compostable Item
          • 🟰 Item Models
            • πŸ“ Model
              • 🎨 Tint
            • 🧩 Composite
            • βš–οΈ Condition
            • πŸ“‘ Range Dispatch
            • βœ… Select
            • πŸ‘» Special
        • 🧱 Blocks
          • βš™οΈ Block Settings
            • 🏷️ Useful Tags
          • πŸ”£ Block States
            • 🏷️ Properties
          • πŸ•ΉοΈ Block Behaviors
            • πŸ’¦ Concrete Powder Block
            • 🟨 Falling Block
            • 🍁 Leaves Block
            • 🎍 Vertical Crop Block
            • 🌽 Crop Block
            • 🌴 Sapling Block
            • πŸͺ» Bush Block
            • πŸͺ“ Strippable Block
            • 🚟 Hanging Block
            • 🌿 Grass Block
            • 🌊 On Liquid Block
            • 🌊 Near Liquid Block
            • πŸ’‘ Lamp Block
            • πŸ₯ͺ Stackable Block
            • πŸͺ¨ Sturdy Base Block
            • πŸͺŸ Trapdoor Block
            • πŸšͺ Door Block
            • πŸͺ΅ Fence Gate Block
            • 2️⃣ Double Height Block
            • 🎒 Stairs Block
            • βž–οΈ Slab Block
          • πŸ«‘ Block Entities
        • πŸ–ΌοΈ Images
        • πŸ˜€ Emoji
        • γŠ™οΈ Fonts
        • πŸ“‚ Category
        • πŸ”Š Sounds
        • 🌍 Server Lang (i18n)
        • 🌎️ Client Lang (lang)
        • πŸ—ƒοΈ Vanilla Loots
        • πŸ”  Global Variables
      • πŸ”’ Number Format
      • ✏️ Text Format
        • πŸ”— Chain Arguments
      • πŸ“¦οΈ Resource Pack
        • βš”οΈ File Conflict
        • πŸ›œ Host
      • 🐚 Commands
      • πŸ”Œ Compatibility
        • 🐌 External Item Providers
        • πŸͺ“ WorldEdit / FAWE
        • πŸ…ΏοΈ PlaceholderAPI
        • βš›οΈ Axiom
        • 🟒 AdvancedSlimePaper
        • πŸ–ŒοΈ World Painter
        • ⌨️ Skript
        • πŸ‘” Supported Levelers
        • πŸ¦• MythicMobs
      • πŸ“” Worldgen Datapack Tutorial
        • πŸͺ¨ Ore Vein
        • 🌳 Tree
        • 🌺 Surface Decoration
        • 🏰 Structure
      • ⌨️ API
      • πŸ—‚οΈ Misc
        • πŸ““ Config Format Changelog
        • ❓️ Common Questions
Powered by GitBook
On this page
  • Introduction
  • How it works?
  • Multiple Templates
  • Arguments
  • Overrides
  • Merges
  1. Plugin Wiki
  2. 🏭️ CraftEngine
  3. βž•οΈ Add New Contents

πŸ“„ Templates [MUST READ]

This page mainly explains how to add new templates to your server.

Previousβž•οΈ Add New ContentsNext🟒 Argument Types

Last updated 9 days ago

The following content applies to CraftEngine 0.0.57 and above. If you update to version 0.0.57 or newer, you need to use the command /ce debug migrate-templates to migrate the old templates.

Introduction

The plugin boasts an exceptionally high degree of customization, but it's impossible to configure it without providing any settings. Even a very brief option requires a line in your YAML file. With numerous such options, a configuration file can become excessively long. Therefore, the plugin has introduced a template system, allowing you to define a base template and use parameters and overrides to fill in or overwrite certain parameters, significantly simplifying the process and reducing the time spent on repetitive configurations.

How it works?

To configure a template, you need to use templates as the root key in your YAML file. The first thing under templates is your template's name. In the example below, the template is called namespace:my_first_template. Everything under that name is the actual template content.

templates:
  namespace:my_first_template:
    option_1: true
    option_2: false
    option_3: 
      - hello
    option_4: 20.25
    option_5:
      hello: world

Check out this quick animation to see how the plugin applies the template:

namespace:template_id serves as the unique identifier for your template. This name must be used whenever referencing or invoking this template elsewhere.

The configuration area under namespace:template_id is entirely customizable, as long as it adheres to YAML syntax. You have complete freedom to define it according to your needs.

Multiple Templates

You can combine multiple templates by setting up the template as a list.

items:
  craftengine:custom_item:
     template:
       - namespace:my_first_template
       - namespace:my_second_template

Heads up: If two templates have the same setting, the one below will overwrite the one above. But if the setting is a list, they’ll merge into one combined list instead.

Arguments

You can define parameters in template using ${xxx}, like ${nutrition} or ${saturation}. Then, when calling the template, use the "arguments" section to set the parameter values. Here's a quick example:

templates:
  craftengine:apple_template:
    material: apple
    data:
      food:
        nutrition: "${nutrition}"
        saturation: "${saturation}"
items:
  craftengine:custom_apple:
    template: craftengine:apple_template
    arguments:
      nutrition: 1
      saturation: 2.5

If you need to use curly braces {} as normal text (not as parameters), just escape them with a backslash like \{ or \}.

\${Hello world}

${a\{b\}c}

To set default values for parameters, add :- after the parameter name - for example:

  • ${nutrition:-1}

  • ${saturation:-2.5d}

  • ${map:-{aa:bb,cc:ddd}}

  • ${string:-"1234"}

The default values follow Minecraft's SNBT format (the same format used when specifying NBT data in commands).

Overrides

Overrides completely replace whatever's in the specified config pathβ€”including lists and maps. No merging, just a full swap.

items:
  craftengine:custom_bread:
    template: craftengine:apple_template
    arguments:
      nutrition: 1
      saturation: 2.5
    overrides:
      material: bread

Merges

Merges deeply combines two config sections, including all lists - nothing gets left behind. Basically, merges function almost exactly like multiple templates.

items:
  craftengine:custom_bread:
    template: craftengine:apple_template
    arguments:
      nutrition: 1
      saturation: 2.5
    merges:
      data:
        food:
          can-always-eat: true