Making a datapack - SilentChaos512/ScalingHealth GitHub Wiki

Brief introduction to datapacks

A lot of Scaling Health's configurability comes from datapacks, the SH resources can be downloaded to get started.

The file can be unzipped then in the datapack folder, the examples folder contains a zip which is an actual datapack, that configures SH to not have heart crystals. More examples might be added later. The folder pack name is meant to be renamed, and will be the final pack folder. In it, there is an assets folder, which, unless making a resource pack is desired, can be entirely deleted. The READ_ME contains some other information about datapacks and some links to other resources.

pack.mcmeta

Information about this file can be found on the minecraft wiki

Modifying SH Mechanics

In the pack folder there is data/scalinghealth/sh_mechanics/ which contains json files that can be modified to change the games behaviour. In the difficulty.json for instance, which can be edited using a text editor (e.g. visual studio code). Some of what can be edited is straightforward, for example, startingValue, minValue and maxValue can take on any value as long as some rules are respected between them, i.e. min <= max and min <=starting <= max. This is unless max == 0, in which case it is considered to be infinity. This can be seen in the code here which then takes you here. The code is only meant to help, it is not a requirement to understand it.

A more complicated example is the "mode" which is a Json object and will change depending on the "type" value.

Minimum information needed for the mode

  "mode" : {
    "type" : "the_mode_here"
  }

As of 30/7/21, type can be: extrema, average, distance, distance_and_time or server_wide.

extrema:

  • requires a radius field greater or equal to 64
  • Optionally has a min field that defaults to true and can be used to make extrema be a maximum instead (so by default it's a minimum).

Configuring the mode to be the maximum difficulty in a 256 radius would be:

  "mode" : {
    "type" : "extrema",
    "radius" : 256,
    "min" : false
  }

average and distance also require a radius field greater or equal to 64.

average can optionally have a weighted field that defaults to true. If false a normal average is done in the radius, instead of a weighted one.

distance can optionally have a fromOrigin field that defaults to false. If it's true, the difficulty will be calculated from the origin (x=0, z=0), instead of the world spawn.

server_wide does not require any fields.

distance_and_time require two fields, one that will configure the average part and the other will configure the distance part. An example of this is seen in the default difficulty mechaniscs.

Explanations of other complicated json objects can be found here (TODO!)

Modifying loot tables

Re-creating entire loot tables is not explained here, but simply how to remove entries from Scaling Health's existing loot tables. These are found in data/scalinghealth/loot_tables the chests_addition subfolder contains all loot that are added to chests. To remove an entry, heart crystals for instance, the json object associated with it must be removed from the entries list.

The complete entry for a heart crystal is

        {
          "type": "minecraft:item",
          "weight": 3,
          "quality": 2,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1.0,
                "max": 2.0,
                "type": "minecraft:uniform"
              }
            }
          ],
          "name": "scalinghealth:heart_crystal"
        }

All of it has to be removed for it to work (there is also a comma that will become unnecessary). To verify the json is still valid, it can be pasted into this website, although a good text editor should detect errors.

The bonus_drops subfolder contains more complicated loot tables, as they contain multiple pools. Heart crystals appear both in the crystals pool and in the blights pool. There are also drops of heart_crystal_shards that would also need to be removed in this context. To deal with this easily, Ctrl+f can be used to search the text file for heart for instance and then those entries can be found and removed.

Adding to tags

Scaling Health has two tags, to determine what entities are exempt from being blights and from difficulty. These can be found in data/scalinghealth/tags/entity_types/. Adding to the list is simple and a mod like TOP will make it easier to find the registry name of the mob, it will be formatted as mod_id:the_mob_name.

Adding the datapack

Datapacks can be added by adding them to the datapacks folder of a world, it can also be added when first creating a singleplayer world in the datapack menu. The folder to add is the folder that was renamed pack name. The datapack can also be in a zip format, in which case the data folder and pack.mcmeta file must be compressed (not the pack name folder).