illusivesoulworks / consecration

Minecraft Mod: Makes the undead more resilent except against fire and holy damage, and adds new features to help you slay them
https://www.curseforge.com/minecraft/mc-mods/consecration
Other
4 stars 5 forks source link

[Clarification Request] How exactly does "Material" work? #53

Closed IdrisQe closed 3 years ago

IdrisQe commented 3 years ago

I'm probably going to do some testing later, but I feel like for the sake of future people with the same question I should ask and maybe get an answer from the actual person who made the mod.

How does the "material" setting work exactly?

What I would assume is it's based on either the name, or the crafting recipe, both of which have issues. Name-based would mean for example hitting a Zombie with "silver ore" or a "silver ingot" would consecrate them, unless there are checks in place to only allow items with attack damage (tools, weapons) to be used. Recipe based would basically just be a recursive version of the above, looking back at the materials for the tool/item and checking if it's the right kind of item, either using Forge's ore dictionary or more name checking stuff. This probably wouldn't account for things like the Smithing Table being the only way to make Netherite gear (or the Aeternium stuff in BetterEnd which is made with two seperate item pieces, a handle and a blade, together in a smithing table) and stuff like that.

I tried looking back in previous issues to see if anyone had gotten an answer to this, but the closest I could find was: "All Consecration does is take the material names listed in its config and use that to test against a particular mod's materials, which often times needs special parsing in itself and is evaluated at the time of smiting. For example, some mods require that I dig through their tools/weapons' NBT data to find the right material name."

Is "material" an actual property on items? Or do you just check like... name, tooltip, nbt, etc. and just hope something matches? In the same response you said modpack devs would probably need to ask about the material but if people knew what the actual process was, even simplified into a short list of what is checked, it would help immensely in figuring stuff out for configuration.

TheIllusiveC4 commented 3 years ago

I'm not sure if I can answer this eloquently but I'll try my best to try and explain the process.

Minecraft has a concept of ItemTier which holds several properties such as harvestLevel or attackDamage. These properties are applied onto a particular type of item known as a TieredItem, which typically consist of swords, axes, pickaxes, etc. Basically, it is used to denote items with various properties related to the material they are associated with.

The relevant portion of this is that one of these properties is repairMaterial, which denotes the type of item that can be used to repair the tool. For instance, an iron axe would have an iron ingot listed as its repairMaterial. Note that this isn't some kind of catch-all that is used for any type of repair. This is strictly an item or tag of items that is denoted to be the repair material in the interface.

For Consecration's material configuration setting, what it does is it first retrieves all of the possible items listed as a repairMaterial for the item being processed. This automatically limits the processing to mostly tools and weapons because only those are usually classified as a TieredItem. Then it takes those ingredients and looks at the resource name (i.e. "minecraft:iron_ingot") and takes the path only (i.e. "iron_ingot"). It then tries to find a match between that and the names listed in the configuration, but not a strict match. As a general rule of thumb, it will match if it finds the material name at the beginning and it is not a compound word. If you list "iron" as a material, it will match names like "iron_ingot", "iron_shard", but it will not match "darkiron" or "ironsteel".

There are some caveats to this. If a particular item is coded to use a repair material that is not associated with its own material for some reason, this will lead to errant behavior. Also, the name matching works for almost all use-cases I can imagine, but it is not 100% infallible. If you write "silver" as a material in the configuration and it finds two materials "silver" and "silver_dark", it will match with both even though perhaps the latter might not actually be valid. This is the type of extreme example where it wouldn't work as desired but I have yet to have anyone even report such an issue. Nevertheless, it's something to be aware of.

tl;dr: Consecration checks the path name of the resource location of the repair material associated with the item and tries to find a match with the ones in the configuration.

I hope this clarifies some of the process for you and others.

Edit: Oh, right. One more thing. About my comments you referenced where I talked about other mod's materials and such. With the above in mind, some mods use their own material system rather than Minecraft's tiered item system. In these cases, obviously none of this process would be applicable and I have to dig through the mod's systems to figure out how I can best process their material names in Consecration. This process will vary wildly for each mod that needs it and that's why modpack developers may need to ask me directly about integration if a particular mod's items do not work with the material configuration.

IdrisQe commented 3 years ago

Thank you greatly for the involved response! Using the repair material makes a whole lot of sense and also solves the tool vs. ingot/etc. issue! And this'll make it a lot easier to figure out how to add the right materials! ... Here's hoping the items I intend to add actually have repair materials set.