make me a datapack for minecraft version 26.2 that spawns phantoms only if the player has the bad omen effect, is night time and the player has sky access
I’ll create a minimal omen_phantoms datapack with:
A Minecraft 26.2 pack manifest.
Load/tick function tags.
A combined bad-omen, nighttime, and sky-access predicate.
Timer-based phantom spawning and removal of vanilla phantoms.
Created the omen_phantoms datapack for Minecraft 26.2.
Behavior:
Natural phantoms are removed.
Eligible players must:
Have the Bad Omen effect.
Be outside during nighttime, between ticks 13,000–23,000.
Have direct sky access.
One phantom spawns 8 blocks away every 10 seconds while conditions remain valid.
Spawned phantoms are tagged so they are not immediately removed.
Place the created files directly in the datapack root, then put the folder or ZIP inside the world’s datapacks directory.
it doesnt spawn the phantoms and I can't use the function in the function command
Fix the datapack directory name: Minecraft 26.2 expects
function, notfunctions.Keep the existing commands and move all three functions into the recognized directory.
The issue was the function folder name. Minecraft 26.2 requires:
data/omen_phantoms/function/
not:
data/omen_phantoms/functions/
I moved all three functions into the correct directory. Now run:
/reload
Then verify the datapack is enabled:
/datapack list enabled
Test the function directly:
/function omen_phantoms:spawn
For automatic spawning, give yourself Bad Omen, go outside under open sky at night, and wait up to 10 seconds:
/effect give @s minecraft:bad_omen 600 0
The datapack will only spawn phantoms when all three conditions are true: Bad Omen, nighttime, and direct sky access.
the spawn function works when I use the command but the phantoms dont spawn
Fix the invalid time predicate condition so the eligibility check can evaluate.
Keep the existing timer and spawning behavior unchanged.
Fixed the automatic spawn check. The predicate used the invalid condition minecraft:time; it now correctly uses minecraft:time_check.
Run:
/reload
Then test at night with:
/effect give @s minecraft:bad_omen 600 0
You must be outdoors with direct sky access. The phantom should spawn after approximately 10 seconds.
The problem is with the tick function, I cant use it on a command I think
Make the tick function self-initialize its scoreboard objective, so it works even if the load function was not run after installing/reloading the pack.
Keep the automatic tick tag and existing spawn conditions unchanged.
Fixed the tick initialization issue.
Changes:
Added
omen_phantoms:init, which creates the scoreboard objective.The tick function now initializes itself if needed.
The load function now calls the initializer.
Run:
/reload
Then use the fully qualified command:
/function omen_phantoms:tick
The automatic tick tag will also run normally after the reload.
execute unless data storage omen_phantoms:state initialized run function omen_phantoms:init
scoreboard players add @a omen_phantom_timer 1
kill @e[type=minecraft:phantom,tag=!omen_phantom]
execute as @a[scores={omen_phantom_timer=200..}] at @s if predicate omen_phantoms:eligible_player run function omen_phantoms:spawn