1

A Command that Detects entity near a player

lnard's Avatar lnard6/4/19 4:27 am history
1 emeralds 6.1k 2
6/18/2019 11:37 am
TheArchitect_95's Avatar TheArchitect_95
I was testing out some commands and was wondering on how would you make a command that would detect if there is a mob near the player any help would be appreciated! :)




Here's a reference on how I would like it to be

https://www.youtube.com/watch?v=UnoLSSUAUMMM

It's like some spidersense where if a mob is nearby it would alarm the player
Posted by lnard's Avatar
lnard
Level 1 : New Miner
0

Create an account or sign in to comment.

2

1
06/04/2019 6:13 am
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
/execute at @a if @e[type=entity,distance=#]
should work
1
06/18/2019 11:37 am
Level 32 : Artisan Architect
TheArchitect_95
TheArchitect_95's Avatar
This will not work unfortunately.
Assuming Java Edition 1.14, it would be a repeating command block with:

execute as @p at @s if entity @e[type=!player,type=!item,type=!any other entity you don’t want included,distance=..5] run command of your choice

This will detect any entities of the types not listed that are within 5 blocks of the player closest to the command block.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome