# Creating Addons

To create a Lucky Block Addon, you must first create a new folder. Copy the following folder structure:

<figure><img src="/files/mFay79wevszQswU3ARz8" alt="" width="228"><figcaption><p>Example Addon Folder Structure</p></figcaption></figure>

The **lucky\_block.json** file in the root of your datapack (in the namespace directory) defines the actual addon. The "**outcome**" folder defines various drops (see [Outcomes](/lucky-block/outcomes/outcomes.md)). Everything else is either vanilla assets or data.

A Lucky Block Addon can then be put inside of the "**addons"** folder in your game's run directory (typically **.minecraft**) to load it in game.

### Example

To see an example Datapack Lucky Block Addon, see the following:

{% embed url="<https://github.com/jack-zisa/lucky_block/tree/main/common/src/main/resources/data/lucky>" %}
Example Lucky Block Datapack Addon
{% endembed %}

{% code title="lucky\_block.json" %}

```json
{
  "id": "lucky:lucky_block",  // required
  "activations": [            // optional
    "break_creative",
    "break_survival",
    "right_click",
    "power"
  ],
  "settings": {               // optional
    "hardness": 0.2,
    "resistance": 20.0,
    "rarity": "rare"
  },
  "item_luck": {              // optional
    "minecraft:diamond": 12,
    "minecraft:diamond_block": 100,
    "minecraft:emerald": 8,
    "minecraft:emerald_block": 80,
    "minecraft:gold_ingot": 6,
    "minecraft:gold_block": 60,
    "minecraft:iron_ingot": 3,
    "minecraft:iron_block": 30,
    "minecraft:golden_carrot": 30,
    "minecraft:golden_apple": 40,
    "minecraft:enchanted_golden_apple": 100,
    "minecraft:nether_star": 100,
    "minecraft:rotten_flesh": -5,
    "minecraft:spider_eye": -10,
    "minecraft:fermented_spider_eye": -20,
    "minecraft:poisonous_potato": -10,
    "minecraft:pufferfish": -20
  },
  "debug": true                // optional
}
```

{% endcode %}

### Id

```json
"id": "lucky:lucky_block"
```

The only required field is the "**id**" field. This defines the id of your lucky block addon, block, and item.

### Activations

Activations determine how a Lucky Block is "opened" or "activated". This field is optional, and defaults to **\["break\_survival", "power"]**.

* **break\_survival**: lucky block activates when broken in survival
* **break\_creative**: lucky block activates when broken in creative
* **power**: lucky block activates when powered by Redstone
* **right\_click**: lucky block activates when right-clicked

### Settings

```json
"settings": {
    "hardness": 0.2,
    "resistance": 20.0,
    "rarity": "rare"
}
```

An optional field which defines block & item settings.

```json
"hardness": 0.2
```

Defines the block hardness. See below for more information.

{% embed url="<https://minecraft.wiki/w/Breaking#Blocks_by_hardness>" %}
Block Hardness
{% endembed %}

```json
"resistance": 0.2
```

Defines the block blast resistance. See below for more information.

{% embed url="<https://minecraft.wiki/w/Explosion#Blast_Resistance>" %}
Block Blast Resistance
{% endembed %}

```json
"rarity": "rare"
```

Defines the item rarity. See below for more information.

{% embed url="<https://minecraft.wiki/w/Rarity>" %}
Item Rarity
{% endembed %}

### Item Luck

```json
"item_luck": {
    "minecraft:diamond": 12,
    "minecraft:diamond_block": 100,
    "minecraft:emerald": 8,
    "minecraft:emerald_block": 80,
    "minecraft:gold_ingot": 6,
    "minecraft:gold_block": 60,
    "minecraft:iron_ingot": 3,
    "minecraft:iron_block": 30,
    "minecraft:golden_carrot": 30,
    "minecraft:golden_apple": 40,
    "minecraft:enchanted_golden_apple": 100,
    "minecraft:nether_star": 100,
    "minecraft:rotten_flesh": -5,
    "minecraft:spider_eye": -10,
    "minecraft:fermented_spider_eye": -20,
    "minecraft:poisonous_potato": -10,
    "minecraft:pufferfish": -20
}
```

An optional field which defines values for luck crafting. Maps item ids to an integer value between -100 and 100.

### Debug

Defaults to false, this field should be used when testing Lucky Blocks. When true, it will print messages in the console:

* Outcome Id when activating a block
* Outcome Ids when loading outcomes on world load
* Lucky Block Ids during initial game load


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.creoii.dev/lucky-block/creating-addons.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
