Marcie ???

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

Kodari AI
KodariSep 10 at 6:18 pm 1
PhantomOmenTrigger
PhantomOmenTrigger is a Minecraft 26.2 datapack that restricts phantom spawning to specific conditions. Phantoms will only spawn when a player has the Bad Omen effect active, it is nighttime, and the player has direct sky access. The datapack continuously checks all players, verifying their status effect, time of day, and exposure to open sky before allowing phantom spawns. It prevents phantom spawns during the day, indoors, underground, or when the player lacks the Bad Omen effect. The system uses a tick-based scoreboard timer to efficiently manage spawn checks and uses advancement triggers to detect when players gain or lose the Bad Omen effect, ensuring precise and performant condition validation.

I’ll create a minimal omen_phantoms datapack with:

  1. A Minecraft 26.2 pack manifest.

  2. Load/tick function tags.

  3. A combined bad-omen, nighttime, and sky-access predicate.

  4. 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.

Marcie ???

it doesnt spawn the phantoms and I can't use the function in the function command

Kodari AI
KodariSep 10 at 6:23 pm 1
  1. Fix the datapack directory name: Minecraft 26.2 expects function, not functions.

  2. Keep the existing commands and move all three functions into the recognized directory.

The issue was the function folder name. Minecraft 26.2 requires:

Plain Text
data/omen_phantoms/function/

not:

Plain Text
data/omen_phantoms/functions/

I moved all three functions into the correct directory. Now run:

Mcfunction
/reload

Then verify the datapack is enabled:

Mcfunction
/datapack list enabled

Test the function directly:

Mcfunction
/function omen_phantoms:spawn

For automatic spawning, give yourself Bad Omen, go outside under open sky at night, and wait up to 10 seconds:

Mcfunction
/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.

Marcie ???

the spawn function works when I use the command but the phantoms dont spawn

Kodari AI
KodariSep 10 at 6:28 pm 1
  1. Fix the invalid time predicate condition so the eligibility check can evaluate.

  2. 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:

Mcfunction
/reload

Then test at night with:

Mcfunction
/effect give @s minecraft:bad_omen 600 0

You must be outdoors with direct sky access. The phantom should spawn after approximately 10 seconds.

Marcie ???

The problem is with the tick function, I cant use it on a command I think

Kodari AI
KodariSep 10 at 6:34 pm 1
  1. 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.

  2. 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:

Mcfunction
/reload

Then use the fully qualified command:

Mcfunction
/function omen_phantoms:tick

The automatic tick tag will also run normally after the reload.

Kodari can make mistakes. Review important code before using.
Files
data
pack.mcmeta
Code
8 54
data/omen_phantoms/function/tick.mcfunction
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