Skip to content

Server resources

Crystal Spider edited this page Aug 31, 2024 · 5 revisions

Data Driven Enchantments

Data driven enchantments are available since Minecraft 1.21 only.

Definition

How to define data driven enchantments is out of scope for this wiki, but you can follow these guides:

Here you can find examples for a custom Fire Aspect and a custom Flame, specifically the ones provided by this mod.
You can safely copy-paste them, just make sure to change the "fire_type" property to match your Fire Id.

Soul Fire Aspect
{
  "anvil_cost": 4,
  "description": {
    "translate": "enchantment.minecraft.soul_fire_aspect" // Change this to match your Mod Id and Fire Id.
  },
  "effects": {
    "minecraft:post_attack": [
      {
        "affected": "victim",
        "effect": {
          "type": "soul_fire_d:ignite",
          "duration": {
            "type": "minecraft:linear",
            "base": 4.0,
            "per_level_above_first": 4.0
          },
          "fire_type": "soul" // Change this to match your Fire Id.
        },
        "enchanted": "attacker",
        "requirements": {
          "condition": "minecraft:damage_source_properties",
          "predicate": {
            "is_direct": true
          }
        }
      }
    ]
  },
  "max_cost": {
    "base": 60,
    "per_level_above_first": 20
  },
  "max_level": 2,
  "min_cost": {
    "base": 10,
    "per_level_above_first": 20
  },
  "primary_items": "#minecraft:enchantable/sword",
  "slots": [
    "mainhand"
  ],
  "exclusive_set": "#soul_fire_d:exclusive_set/fire_aspect",
  "supported_items": "#minecraft:enchantable/fire_aspect",
  "weight": 2
}

Also remember to add this enchantment to the smelts_loot enchantment tag, otherwise mobs that die in one hit won't drop cooked food!
To do so, simply add a file called smelts_loot.json under data/minecraft/tags/enchantment/ with the following content:

{
  "replace": false,
  "values": [
    "mod_id:fire_id_fire_aspect" // Change this to match your Mod Id and Fire Id.
  ]
}
Soul Flame
{
  "anvil_cost": 4,
  "description": {
    "translate": "enchantment.minecraft.soul_flame" // Change this to match your Mod Id and Fire Id.
  },
  "effects": {
    "minecraft:projectile_spawned": [
      {
        "effect": {
          "type": "soul_fire_d:ignite",
          "duration": 100.0,
          "fire_type": "soul" // Change this to match your Fire Id.
        }
      }
    ]
  },
  "max_cost": {
    "base": 50,
    "per_level_above_first": 0
  },
  "max_level": 1,
  "min_cost": {
    "base": 20,
    "per_level_above_first": 0
  },
  "slots": [
    "mainhand"
  ],
  "exclusive_set": "#soul_fire_d:exclusive_set/flame",
  "supported_items": "#minecraft:enchantable/bow",
  "weight": 2
}

Ignite effect

Minecraft provides an enchantment effect, called minecraft:ignite, to set entities on fire with an enchantment.
Soul Fire'd provides a very similar enchantment effect, called soul_fire_d:ignite, to do the same, but with a Fire Type.
The format is the exact same as the Vanilla ignite effect, but requires a new property, "fire_type", that needs to be set to a Fire Id.

Exclusive sets

As you could see by the examples above, Soul Fire'd introduces new enchantment tags for the exclusive set of incompatible enchantments.
By default, these tags include Fire Aspect and Soul Fire Aspect, and Flame and Soul Flame.
To make your custom Fire enchantments exclusive with the others, you need to add them to these tags.

Under data/soul_fire_d/tags/enchantment/exclusive_set/ add the file fire_aspect.json with the following content:

{
  "replace": false,
  "values": [
    "mod_id:fire_id_fire_aspect"
  ]
}

Under data/soul_fire_d/tags/enchantment/exclusive_set/ add the file flame.json with the following content:

{
  "replace": false,
  "values": [
    "mod_id:fire_id_flame"
  ]
}

Fire Components data

The only Fire Component to require server sided data is SOURCE_BLOCK.
As for Vanilla Soul Fire, you need to create a block tag to define on which blocks your fire can burn.

Under data/mod_id/tags/blocks/ add the file fire_id_fire_base_blocks.json with the following content:

{
  "values": [
    // Add here all the blocks you want.
  ]
}