Utils
Version: 5
Mod Features
Utils is a universal library of functions for Minecraft that significantly simplifies the creation and management of various game mechanics. The mod offers a comprehensive set of tools for working with commands, entities, players, and other game world elements.
Key features:
- Global, entity, and player functions
- Entity movement control in specified directions
- Data storage system for entities
- Constant score values
- Player identification in the score system
- Predicates for various conditions
- Item modifiers
- Entity tag groups
- Macro functions
- Custom item cooldown settings
Command Usage Examples
Global Commands
Clear chat for all players:
/function utils:global/clear_chat
Hide sidebar interface:
/function utils:global/hide_sidebar
Entity Commands
Remove mobs and entities:
/execute as @n[type=zombie] run function utils:entity/despawn
Reset all attributes:
/execute as @n[type=zombie] run function utils:entity/reset_all_attributes
Full health restoration:
/execute as @n[type=iron_golem] run function utils:entity/heal_full
Player Commands
Clear chat for specific player:
/function utils:player/clear_chat
Reset experience:
/function utils:player/xp/reset
Get all experience points:
/function utils:player/xp/get_all_points
Result is saved in the utils.player.xp.total_points score
Random teleportation for void worlds:
/function utils:player/random_tp
Movement System
Functions for controlling entity movement:
function utils:motion/calc
summon fireball ^ ^ ^.5
execute store result entity @n[type=fireball] Motion[0] double -0.00025 run scoreboard players get @s utils.motion.mx
execute store result entity @n[type=fireball] Motion[1] double -0.00025 run scoreboard players get @s utils.motion.my
execute store result entity @n[type=fireball] Motion[2] double -0.00025 run scoreboard players get @s utils.motion.mz
Or use the storage and macro method:
function utils:motion/storage {"value":"-0.00025"}
summon fireball ^ ^ ^.5
data modify entity @n[type=fireball] Motion set from storage utils:motion motion
Entity Data Storage
Creating Data
Two ways to add data: set for absolute values and append for arrays.
# Absolute values
/function utils:entity/storage/set {"path":"lives","data":3}
/function utils:entity/storage/set {"path":"name","data":'"lullaby6"'}
# Arrays
/function utils:entity/storage/append {"path":"deaths","data":1}
/function utils:entity/storage/append {"path":"deaths","data":2}
/function utils:entity/storage/append {"path":"deaths","data":3}
Running Functions with Entity Data
All data from storage is passed to the function as macro arguments.
/function utils:entity/storage/function {"function":"namespace:say_lives"}
say_lives.mcfunction file:
$say $(lives)
Removing Data
# Absolute values
/function utils:entity/storage/remove/data {"path":"lives"}
/function utils:entity/storage/remove/data {"path":"name"}
# Arrays
/function utils:entity/storage/remove/first {"path":"deaths"}
/function utils:entity/storage/remove/index {"path":"deaths","index":1}
Constants
Constants from 0 to 1000 are available. Check values using:
/scoreboard players get <number> utils.const
Example:
/scoreboard players get 1 utils.const
Player Identifiers
Get player identification in the score system:
/scoreboard players get @s utils.player.id
Predicate System
The mod offers various predicates for condition checking:
— Weather conditions: can/see_sky, is/raining, is/thundering
— Effects: has/effect/<effect_name> (speed, regeneration and others)
— Interactions: has/passenger, is/riding, is/sneaking, is/sprinting
— Location: in/biome/<biome_name>, in/structure/<structure_name>, in/dimension/<dimension>
— Light: in/light/<level> (0, 5, 10, 15, ranges 0-5, 5-10 and others)
— State: is/baby, is/falling, is/flying, is/ground, is/on_fire, is/swimming
— Random: random/<chance> (0.1 for 10%, 0.5 for 50% etc.)
Usage example:
/execute as @s if predicate utils:is/on_fire run say I am on fire :D
Item Modifiers
Quantity operations:
{- count/add/
Other modifiers:
{- enchantment_glint_override/
Special functions:
{- Content clearing clear_bundle, clear_container
{- Death protection death_protection
{- Random enchantment enchant_randomly, enchant_randomly_compatible
{- Furnace smelting furnace_smelt
{- Gliding glider
{- Hiding tooltips, non-consumable items and other utilities
Usage example:
/execute if items entity @s weapon.mainhand minecraft:raw_iron run item modify entity @s weapon.mainhand utils:furnace_smelt
Entity Tag Groups
Extensive tag library for convenient work with different entity types:
— Living beings: animals, aquatics, arthropods, bosses, monsters, undead
— Narrower categories: aquatics_animals, aquatics_real_animals, real_animals
— Transportation: all_boats, boats, boats_with_chest, rideables, rideables_animals
— Social: humanoids, illagers, piglins, villagers, villagers_hostiles
— Aggressiveness: hostiles, flyers_hostiles, neutrals, passives
— Dimensions: end, nether
— Specific mobs: cows, fishs, flyers, horses, slimes, spiders, tameables, zombiess
— Team-related: team_player, proyectiles
Application example:
/effect give @e[type=#utils:team_player] glowing 1 0
License
The mod is distributed under MIT license.