Tough As Nails

Tough As Nails

21M Downloads

Add Custom Drink or Armor Stats Based on NBT Values

CorneliaXaos opened this issue ยท 5 comments

commented

I was working on a modpack that uses both Tough As Nails and Rustic. Rustic adds several drinks but they all have the same Item ID and metadata (rustic:fluid_bottle:0). They, however, have different NBT tags based on the content of the bottle. I can add thirst regen to all of them.. but half of them are "alcoholic" and I wished to make it so that drinking alcohol slightly dehydrated you (by adding negative thirst).

So, what I'm wondering is if it's possible to update the drink_stats.json to allow for specifying NBT tags as a differentiating parameter. That way each fluid could be configured to provide varying thirst amounts (mainly so alcoholic drinks would cause slight dehydration).

commented

There's still no documentation on how to actually configure NBT. I have no idea how to utilize this.

commented

My bad, @Waynekosimoto . I never explained it in a config file as there was no real need to do so.

To summarize, NBT is stored in a sort of JSON way. That JSON string is what you'd put in the "nbt" field which is entirely optional and why it doesn't show up in any of the standard configs.

I'll give an example here, using the "Rustic" mod as the integration target (since that's why I wanted this feature in the first place).

We'll start with what was possible the old way. Let's make a simple config for one of Rustic's drinks: the "Wildberry Juice" bottle:

{
  "item": {
    "name": "rustic:fluid_bottle",
    "metadata": 0
  },
  "thirst": 3,
  "hydration": 1.0,
  "poisonChance": 0.0
}

(This goes in the config/toughasnails/drinkstats file, by the way.)
The problem with this is that ALL of Rustic's drinks use the same "rustic:fluid_bottle" item name. And I wanted to be able to differentiate between them so that the alcohol's make you thirsty, not replenish thirst.

in order to pick out the Wildberry Juice bottle from all of the fluid bottles we use NBT since that's how Rustic differentiates. If you use a mod like "Crafttweaker" you can look at the NBT tag values for whatever item you hold. The WIldberry Juice bottle prints out the following when you identify it with Crafttweaker's /ct hand command:

<rustic:fluid_bottle>.withTag({Fluid: {FluidName: "wildberryjuice", Amount: 1000}})

The NBT in there is a JSON string and is what we need to tell TAN to apply specific values to a particular Rustic fluid bottle. The updated TAN config file is the following:

{
  "item": {
    "name": "rustic:fluid_bottle",
    "metadata": 0,
    "nbt": "{Fluid: {FluidName: \"wildberryjuice\", Amount: 1000}}"
  },
  "thirst": 3,
  "hydration": 1.0,
  "poisonChance": 0.0
}

Pay close attention to the escape codes for the quotation marks! ( \" ) They are required to embed the entire tag in the string.

Anyway, by doing this we can select specifically the Wildberry Juice and apply specific values to its thirst, hydration, and poisonChance. It should be roughly the same way for applying heat values to specific armor pieces where NBT is all that differentiates them (though usually that's not the case). The "nbt" parameter is completely optional so if you leave it off then NBT comparisons will NOT be done. This was to allow compatibility with the old way of identifying objects and to make it easier overall to configure different types where NBT is not used as a differentiating parameter.

if you have any more questions just ask them here. I'll be happy to help you work them out.

commented

@Waynekosimoto I agree.. I'm a little free right now so I'm gonna pull the source and see if I can't figure it out. It doesn't look too difficult to add NBT support. I'll make a pull request and hopefully it'll get merged in..

commented

It's been several months and this suggestion has been completely ignored can you please reconsider adding this? We just want the ability to specify the NBT.

commented

Resolved. #562 merged into TAN-1.12.x-3.x.x