WingedSeal / jmc

A compiler for JMC (JavaScript-like Minecraft Function), a mcfunction extension language for making Minecraft Datapack
https://jmc.wingedseal.com
MIT License
64 stars 8 forks source link

Extends keyword #36

Closed Zefyro closed 9 months ago

Zefyro commented 1 year ago

Inheriting properties from an already defined file using extends keyword

In simple terms, allow modifying values of a file created using the new keyword without copying the whole file.
This would be really useful for custom advancements that are different by a single line or the likes.

new advancement(blue_reward) {
  "display": {
    "icon": {
      "item": "minecraft:blue_concrete"
    },
    "title": "Example",
    "description": "example",
    "frame": "goal"
  },
  "criteria": {
    "requirement": {
      "trigger": "minecraft:tick",
      "conditions": {
        "player": {
          "team": "blue"
        }
      }
    }
  },
  "rewards": {
    "function": "example:reward"
  }
}

new advancement(red_reward) extends(blue_reward) {
  "display": {
    "icon": {
      "item": "minecraft:red_concrete"
    },
  },
  "criteria": {
    "requirement": {
      "conditions": {
        "player": {
          "team": "red"
        }
      }
    }
  }
}

This would allow one to copy and modify files that require minor changes without completely copying the contents of the file.
This also allows making the same changes to the files faster for example if the reward were changed to also include experience, all the files extending the parent would get the change.

Nico314159 commented 1 year ago

+1, this would be a very useful feature

(Definitely would be a relief for all my loot table stuff)