Arqade Asked by Marker9999 on April 3, 2021
I’m working on a map, which has a castle in it. The castle has different levels (floors), and when a floor is cleared (when there are no mobs left on that floor), I want to make a button appear to open some iron doors, for the players to be able to go up to next floor.
If you really wanted to you could just do a really long command that checks for each potential mob type in the floor.
execute unless entity @e[type=zombie,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=creeper,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=spider,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=skeleton,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=enderman,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=silverfish,x=14,y=12,z=21,dx=20,dy=8,dz=13] unless entity @e[type=endermite,x=14,y=12,z=21,dx=20,dy=8,dz=13] run setblock 30 14 26 acacia_button[facing=south]
Correct answer by Airtoum on April 3, 2021
Try this, hopefully you can understand it:
1>
for example)dummy
is the holder of the objectivesmobs_in_floor
tracks the mobs in the floormob_entered
tracks whether a mob has entered the floorCommand blocks: 1a>2ac>
Command for 1a:
execute if score dummy mobs_in_floor matches 0 run execute if score dummy mobs_entered matches 1.. run scoreboard players set dummy mobs_entered 0
Command for 2ac is the command you want to execute.
Answered by halp on April 3, 2021
This method uses a scoreboard to track the mobs on a floor, and executes a command when the scoreboard is 0
.
Important: This method works only in versions 1.13+
First off, you need a scoreboard with a dummy criteria. You can do that with the following command.
scoreboard objectives add floor.mobs_left dummy
Next, we need to assign names for the floors, to hold values in the scoreboard. The names are going to be fake players, otherwise it will interfere with the players playing the map. To name these fake players, add characters that are not allowed in normal names, I put "%" in front of the names. Remember these names, because we will need them later. Next, place a Repeating Command Block set to Always Active facing a Chain Command Block set to Always Active.
Now we get to the commands part. First off, in the Repeating Command Block you just placed down, you need a command that tests for entities, then stores it in the appropriate fake player value in our scoreboard. You can do that with the following command.
execute if entity @e[<args>] store result score <fake player> floor.mobs_left
Depending on how your mobs are spawned, you can choose one of the following ways to detect them:
Tags: If your mobs are spawned with commands, you can tag them with a recognizable tag to detect later. You can spawn them with the following command:
summon wither_skeleton ~ ~ ~ {Tags:["floor1"]}
To detect it, replace <args>
with tag=floor1
in the above command.
Rectangular prismic box:
Continue reading here
After you have finished setting up the previous command, in the Chain Command Block, add the command you want to execute if the scoreboard is 0. You can do that with the following command.
execute if score <fake player> floor.mobs_left matches 0 run <your command>
Remember to repeat the command process for each floor
This method grabs the amount of entities in an area or with a specific tag, and stores it in a scoreboard. Then executes any command if there is no entities matching the criteria.
Answered by randomuser922 on April 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP