IIterating through hotbar and inventory
I created this predicate which checks number of items in a stack, I've then duplicated this predicate into a seperate file for the different ranges I am checking.I am using this predicate to trigger a custom model change.
Continue to help post{ "condition": "minecraft:entity_properties", "entity": "this", "predicate": { "type": "minecraft:player", "slots": { "hotbar.8": { "items": "minecraft:cooked_chicken", "count": { "min": 1, "max": 7 } } } } }
Is there a way to iterate through each hotbar slot and inventory slot without having to create an individual predicate for each one, as I am checking multiple custom_data_models all based off of cooked_chicken. If I try inventory.* or hotbar.* it triggers if there are items in any slot, not just the one I am checking.
Here is the main function that is being checked each tick
execute if predicate itemscaler:hfc_one_seven_lv0 run item modify entity @s hotbar.0 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv1 run item modify entity @s hotbar.1 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv2 run item modify entity @s hotbar.2 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv3 run item modify entity @s hotbar.3 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv4 run item modify entity @s hotbar.4 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv5 run item modify entity @s hotbar.5 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv6 run item modify entity @s hotbar.6 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv7 run item modify entity @s hotbar.7 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_one_seven_lv8 run item modify entity @s hotbar.8 itemscaler:set_hfc_0 execute if predicate itemscaler:hfc_eight_fifteen_lv0 run item modify entity @s hotbar.0 itemscaler:set_hfc_1 execute if predicate itemscaler:hfc_eight_fifteen_lv1 run item modify entity @s hotbar.1 itemscaler:set_hfc_1 tellraw @s "I am running"
Etc, for each usecase that needed to be checked (if my math worked out correct worked out to a few thousand checks per player)
Here is a few examples of the the Item modifiers responsible for updating the model.
[ { "function": "minecraft:set_custom_model_data", "value": 2500 } ]
[ { "function": "minecraft:set_custom_model_data", "value": 2501 } ]
Finally, because it is updating the model, I run into two additional problems, one is that one the model updates, it changes its custom model data number, and will no longer stack, I also have to check each individual varient of cooked chicken seperately if I don't want it to affect minecrafts regular cooked chicken.
The method I am persuing seems to be working for the goal of making an item which changes it's apperanace based on number of items in a stack, however it's going to easily generate 3000+ files between predicate checking alone, if my math is correct. Any suggestions on how to optimize this so I don't have to iterate through every hotbar slot, and every inventory slot, check all seven varients of custom_model_data, etc.
Thanks!
I am aware this is not sampling every check that is needed for all the combinations, once I realized I was going to be making 100's of identical files with just a single value change, or filename change, I figured I'd better ask before I proceed further.