I made a boss fight in 1.12, where the boss would summon some silverfish if the player is too close
and if there's over 10 silverfish on the field, they will trigger an ultimate attack, where the boss casts enchantments and silverfish explode.
The command for counting silverfish was simply:
in an repeating command block, facing a redstone comparator.
With the command block output depending on the amount of silverfish detected,
the command block on the right will only be triggered with enough silverfish/power.
as seen in the attached screenshot below.
However, this doesn't work anymore for 1.13 and above,
with the command:
execute if entity @e[type=silverfish]
the command block only outputs a Boolean value.
So is there a way I can achieve the same effect as before?
Is there a way to detect the amount of a certain entity?
This can be done using /execute store.
Create a scoreboard objective to hold the number of silverfish:
/scoreboard objectives add count dummy
store the amount:
/execute as at @s run execute store result score @s count run execute if entity @e[type=silverfish,distance=..20]
the boss will now have the number of silverfish stored in his "count" objective
Some of my projects:
It worked like a charm! Thanks a lot for your reply!
The new command system takes some getting used to.