TerraForged / tracker

Technical issue tracker
1 stars 0 forks source link

Customization & Data Pack Examples #196

Closed augustsaintfreytag closed 1 year ago

augustsaintfreytag commented 1 year ago

The sparse wiki of Terraforged is severely lacking a few actual examples for data packs that are supposed to be placed in /config/terraforged/datapacks/. The documentation only gives the keys to use in a supposed JSON file placed in this data packs folder but does not give any working example.

This is slowly driving me insane. I'm trying to get rid of mushroom trees in the dark_oak forest biome, a vanilla feature. Writing an injector that overwrites the tree types for a match of minecraft:dark_oak_tree for stage VEGETAL_DECORATION does not work. Copying the one data pack for vanilla I found into datapacks does not work. What is the supposed way to customise biomes/vegetation generation in Terraforged?

Won-Ton commented 1 year ago

Hi,

For more examples you can look at TF's built-in injectors (contained within the mod jar). This is how TF matches on dark oak trees: (Note: vanilla bundles the trees and giant mushrooms into a single feature annoyingly)

  "biomes": [
    "minecraft:dark_forest",
    "minecraft:dark_forest_hills"
  ],
  "match": [
    [
      "minecraft:dark_oak_log",
      "minecraft:dark_oak_leaves"
    ]
  ],

File: data/terraforged/features/trees/dark_oak.json

Yours isn't working (probably) because your match rules are wrong, but also TF itself injects into this feature with the above file so you'd need to override it in your datapack, otherwise it might be undoing the changes made by yours.

Won-Ton commented 1 year ago

The documentation only gives the keys to use in a supposed JSON file placed in this data packs folder but does not give any working example.

Also, just in case there was any ambiguity; You need to put properly formatted datapacks in the datapacks folder. They can be in zip or folder format, but they need the basics like a pack.mcmeta so that minecraft can load them. TerraForged prints into the log file all the datapacks it found and loaded so you can check that yours is working.

augustsaintfreytag commented 1 year ago

Thanks for your help. The last piece I don't get is how the config part should actually look. My only reference was digging out the existing formula of dark oak from existing code. I also found that you had to answer something similar for the Enhanced Mushrooms mod a year ago.

Currently, I'm trying something like this:

{
  "biomes": [
    "minecraft:dark*"
  ],
  "match": [
    [
      "minecraft:dark*"
    ]
  ],
  "replace": {
    "config": {
      "feature": {
        "config": {
          "features": [
            {
              "feature": "minecraft:dark_oak",
              "chance": 0.6666667
            },
            {
              "feature": "minecraft:birch",
              "chance": 0.2
            },
            {
              "feature": "minecraft:fancy_oak",
              "chance": 0.1
            }
          ],
          "default": "minecraft:oak"
        },
        "type": "minecraft:random_selector"
      },
      "decorator": {
        "config": {},
        "type": "minecraft:dark_oak_tree"
      }
    },
    "type": "minecraft:decorated"
  }
}

I'm assuming I'm targeting the definition for dark oak trees where vanilla has mushroom blocks included and just replace the entire section without these blocks, only leaves. This still doesn't work, so I'm clearly still not understanding the expected format of what I am even replacing here.

The pack I've built uses the path you gave, the file above is at <instance>/config/terraforged/datapacks/purge_the_shrooms/data/terraforged/features/trees/dark_oak.json. The pack has a pack.mcmeta file and is loaded according to the logs.

augustsaintfreytag commented 1 year ago

I've found a working solution! I'm leaving my broken approach above as-is for others stumbling across this post -- what worked is checking out the code from here (or unpacking the jar and looking for the file you're trying to customise (dark_oak.json in this case). These are, as you said, already injectors in the expected format, so they're easy to use as reference, that is exactly what I needed. The wildcard matching didn't seem to work, so biomes and match seem to be required to be exact.

So, a working data pack to remove mushroom trees was as simple as copying the whole contents of the dark_oak.json and removing the blocks you don't want, in pack form as described in the previous comments.

{
  "biomes": [
    "minecraft:dark_forest",
    "minecraft:dark_forest_hills"
  ],
  "match": [
    [
      "minecraft:dark_oak_log",
      "minecraft:dark_oak_leaves"
    ]
  ],
  "replace": {
    "config": {
      "feature": {
        "config": {
          "features": [
            {
              "feature": {
                "config": {
                  "template": "terraforged:dark_oak_large"
                },
                "type": "terraforged:template"
              },
              "chance": 0.3
            },
            {
              "feature": {
                "config": {
                  "template": "terraforged:dark_oak_small"
                },
                "type": "terraforged:template"
              },
              "chance": 0.2
            },
            {
              "feature": {
                "config": {
                  "template": "terraforged:birch_forest"
                },
                "type": "terraforged:template"
              },
              "chance": 0.05
            },
            {
              "feature": {
                "config": {
                  "template": "terraforged:oak_forest"
                },
                "type": "terraforged:template"
              },
              "chance": 0.025
            }
          ],
          "default": {
            "config": {
              "template": "terraforged:dark_oak_large"
            },
            "type": "terraforged:template"
          }
        },
        "type": "minecraft:random_selector"
      },
      "decorator": {
        "config": {
          "placement": {
            "config": {
              "radius": 5,
              "scale": 0.3,
              "jitter": 0.8,
              "biome_fade": 0.2,
              "density_scale": 300,
              "density_variation": 0.75
            },
            "type": "terraforged:fast_poisson_surface"
          },
          "filter": "biome"
        },
        "type": "terraforged:filter"
      }
    },
    "type": "minecraft:decorated"
  }
}