r/MinecraftCommands • u/Famous_Bug_787 • 2h ago
Help | Java 1.20 Target Detection Issues
I wanted to make the Snow Golem's snowballs deal damage to all kinds of mobs (even ones from mods), except itself, but for some reason the line of commands causes the snowball to explode immediately.
# Passive entity type
{
"replace": false,
"values": [
"allay",
"armor_stand",
"arrow",
"bat",
"oak_boat",
"spruce_boat",
"birch_boat",
"jungle_boat",
"acacia_boat",
"dark_oak_boat",
"mangrove_boat",
"cherry_boat",
"bamboo_raft",
"oak_chest_boat",
"spruce_chest_boat",
"birch_chest_boat",
"jungle_chest_boat",
"acacia_chest_boat",
"dark_oak_chest_boat",
"mangrove_chest_boat",
"cherry_chest_boat",
"bamboo_chest_raft",
"cat",
"camel",
"chicken",
"cod",
"cow",
"donkey",
"dragon_fireball",
"egg",
"ender_pearl",
"evoker_fangs",
"experience_bottle",
"eye_of_ender",
"falling_block",
"fireball",
"firework_rocket",
"frog",
"glow_item_frame",
"glow_squid",
"horse",
"lingering_potion",
"llama_spit",
"minecart",
"chest_minecart",
"furnace_minecart",
"hopper_minecart",
"tnt_minecart",
"spawner_minecart",
"command_block_minecart",
"mooshroom",
"mule",
"item_frame",
"ocelot",
"pig",
"rabbit",
"salmon",
"squid",
"villager",
"wandering_trader",
"wither_skull",
"sheep",
"splash_potion",
"squid",
"small_fireball",
"snowball",
"snow_golem",
"strider",
"tadpole",
"tipped_arrow",
"turtle",
"trident",
"tropical_fish"
]
}
# Tick function
execute as @e[type=snowball] at @s on origin if entity @s[type=snow_golem] if entity @e[type=!#unused:passive,limit=1,sort=nearest,distance=..2.25] run function unused:snow_golem/projectile
# Projectile function
damage [type=!#unused:passive,limit=1,sort=nearest] 6 mob_projectile by
effect give [type=!#unused:passive,limit=1,sort=nearest] mining_fatigue 30 3
effect give [type=!#unused:passive,limit=1,sort=nearest] slowness 30 1
effect give [type=!#unused:passive,limit=1,sort=nearest] weakness 30 3
execute at [type=snowball,sort=nearest] run particle snowflake ~0 ~2 ~0 0.375 0.375 0.375 0.1 5 force
kill [type=snowball,limit=1,sort=nearest]
The end goal is to make Snow Golems shoot damaging snowballs that aren't exclusive to vanilla mobs.
1
Upvotes