• check_circle Advancements
  • check_circle Functions
  • 22,051 views, 32 today
  • 2,392 downloads, 3 today
  • 47
  • 41
  • 37
Tetrajak avatar Tetrajak
Level 74 : Legendary Modder
292
This data pack encourages players to consume a variety of food. Each type of food can be consumed a certain number of times before it becomes unpalatable (you'll get a warning of hunger, but if you persist in eating the same thing, you'll suffer poison). Each time you eat any food, the consumption count of all other food items goes down, allowing you to consume them more times. This means that you'll need to switch between food items each time one becomes unpalatable, but eventually be able to return to previous food items you've eaten. When you consume a food item that has counted all the way back down to 0 (the default state of something you haven't eaten), eating that food item will give you absorption.

Foods you've eaten recently, and whether a food has become poisonous, are displayed in the Advancements under a dedicated advancement tab.

The severity of the hunger, poison, and absorption you receive from this data pack is influenced by the difficulty you've set; peaceful and easy have less effect than normal and hard difficulties.

If you'd like to change how many of each food item can be eaten before poisoning occurs, there is a config file ("data\phantom_menace\functions\config.mcfunction") in the data pack zip file where you can modify these values.

Have you made a data pack that adds new custom food items, and would like to make it compatible with Balanced Diet? Details on how to do so are in the following spoiler;
How to make your data pack compatible with Balanced Diet
Balanced Diet detects default food item consumption with advancements, however, it doesn't act upon that food item consumption until 1 tick after the advancement is granted. This allows you to also use advancements to detect your own custom food consumption and act on it before Balanced Diet does its thing for the same food items. Additionally, you need to tag the player who has just eaten your custom food item with the bd.ignore tag to prevent Balanced Diet from treating your custom food item like the regular food item it's disguising.

Using the aforementioned food consumption detection advancement, we can call a function to not only tell Balanced Diet to ignore the consumption of this custom food item, but also make it part of the food consumption management system. An example of all the necessary steps is present in my Happy Animals data pack; the advancements are located at data/happy_animals/advancements/balanced_diet, and the functions they call contain all the necessary steps for integrating your custom food item, so feel free to copy and paste. You'll need to swap out scoreboard objectives, function calls, and the happy_animals name space, with your own names to avoid collision, but otherwise Happy Animals integration with Balanced Diet makes a good template to copy for your own integration.

You'll need to set your own consumption maximums, per custom food item, on load. Following the Happy Animals example, I've put these in the data/happy_animals/functions/config.mcfunction file. Balanced Diet and Happy Animals both follow a particular calculation to figure out the maximum consumption numbers. You don't need to follow the same formula for your own, but if you're curious you can view the calculator spreadsheet I set up and copy as much or as little of its methodology as you like.

Food consumption user feedback advancements are placed under the minecraft:balanced_diet namespace, with their parent set to minecraft:balanced_diet/root to include them in the advancement tree. There are two advancements for each food item; one to show when the consumption score is above 0, and another that is a child of this one which shows when the poison scoreboard for this item is above 0.

Food consumption scoreboards are all ticked down by 1 when a food item is consumed. To have your custom food items also tick down whenever any Balanced Diet integrated food item is consumed (even from other data packs!), you'll need to add a function that does this just for your data pack's food items to the balanced_diet:reduce function tag. The functions in this tag also manage poison tracking reduction, and user feedback advancement revocation for poison and consumption in the minecraft:balanced_diet namespace. Check out the data/balanced_diet/functions/food_score_removal.mcfunction function for how this works for the vanilla MC food items.

Those are all the parts necessary for total integration with Balanced Diet! If you've got any questions about the process, or would like any help integrating your own data pack's custom food items with Balanced Diet, send me a message and we can talk about it!
CompatibilityMinecraft 1.15
toMinecraft 1.16
Tags

8 Update Logs

Version 9 : 04/04/2020 5:59:41 pmApr 4th, 2020

Changes
  • Delayed food eaten processing functions by 1 tick after advancement for compatibility with other data packs that add their own food which want to integrate with this data pack.
  • Added bd.ignore tag that can be added to a player upon consumption of a "custom" (i.e. disguised) food item to prevent Balanced Diet from processing it as if it were a default food item.
LOAD MORE LOGS

Create an account or sign in to comment.

1
06/08/2021 4:32 pm
Level 1 : New Explorer
DoogleSmile
DoogleSmile avatar
Hi, I've loved using this data pack on my server for a while, but I just tested updating my world to the new 1.17 version that just released, and it seems that something seems to be broken in that version of Minecraft,



Every food gives me a health boost when I eat it, but also poisons me.



Just thought I'd let you know.



I'm holding off updating my server to 1.17 until I've tested all the datapacks I use are working properly.
2
02/09/2021 9:56 am
Level 37 : Artisan Blacksmith
BenGamin98
BenGamin98 avatar
Underrated datapack. Love this eating system! Gives players a reason to eat something other than steak and golden carrots.
2
02/09/2021 2:43 pm
Level 74 : Legendary Modder
Tetrajak
Tetrajak avatar
Thank you, I'm glad you're enjoying it!
1
07/13/2020 9:23 am
Level 1 : New Miner
BlackShadowHRD
BlackShadowHRD avatar
Sorry, I feel I am becoming a bit of a pest. I got this error message on the server console today: "ERROR Failed to load function balanced_diet:eat/cooked_cod".
1
07/13/2020 4:23 pm
Level 74 : Legendary Modder
Tetrajak
Tetrajak avatar
I'm unable to replicate the error on a vanilla server, or vanilla singleplayer. Is there any more to the error log than that?
1
07/06/2020 4:36 am
Level 1 : New Miner
BlackShadowHRD
BlackShadowHRD avatar
I love the balanced diet datapack and it helps with the economy and stopping steak monoculture. We have run into a problem though, a couple of our players on the server have reported that all foods have turned to low yield / poisonous. We are running Paper 1.16.1 on our server. Is there anything I am missing?
1
07/06/2020 5:42 am
Level 74 : Legendary Modder
Tetrajak
Tetrajak avatar
I don't know how well Paper supports all data pack functionality, so I can't totally rule out that it's something to do with the server software. However, you can test whether foods are returning to edible like they should be running /scoreboard players get @s bd.apple , eating something other than an apple, and then running the command again. The second result should be less than the first.

Another question; is the server difficulty set to hard?
1
07/07/2020 10:58 am
Level 1 : New Miner
BlackShadowHRD
BlackShadowHRD avatar
The scoreboard command gives the expected output and the number goes down by 1 every time I eat a different type of food. What does a negative number for a food item signify?
1
07/07/2020 5:09 pm
Level 74 : Legendary Modder
Tetrajak
Tetrajak avatar
A negative number shouldn't be possible for the food item consumption count; have you come across a negative number in these scoreboards?

There are 34 food items in Minecraft, and even on hard difficulty it shouldn't be possible to exhaust all of them. If you can, it'd be useful to have screenshots of the users advancement screen for Balanced Diet so we can see what is and isn't poisonous.
1
07/06/2020 6:03 am
Level 1 : New Miner
BlackShadowHRD
BlackShadowHRD avatar
Thank you for your reply. I will try this and yes, the server difficulty is set to hard.
Planet Minecraft

Website

© 2010 - 2021
www.planetminecraft.com

Welcome