• check_circle Advancements
  • check_circle Functions
  • 28,662 views, 3 today
  • 2,762 downloads, 0 today
  • 62
  • 57
Deprecated's Avatar Deprecated
Level 76 : Legendary Modder
337
Support and development on this data pack are discontinued.

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 : by Deprecated 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
Comments have been disabled on this content.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome