TransWikia.com

is it possible to kill armorstands that are inside another armorstand?

Arqade Asked by Ryan van Vuure on September 30, 2021

i want to fil a 2D area with armorstands, so next to every other armorstand i spawn 4 and so on, but if i dont kill the armorstands that are inside of other armorstands the game wil lagg realy quickly. i have this command now: execute as @e[type=minecraft:armor_stand,name=land] at @s run execute if entity @e[type=minecraft:armor_stand,distance=..0.1,name=land,limit=1] run kill @e[type=minecraft:armor_stand,distance=..0.1,name=land] but this kills all the armorstands. Do you have a idea?

One Answer

Whenever you summon an armor_stand, have it check if there is already an armor stand:

summon armor_stand ~ ~ ~ {Tags:["new_stand"]}
execute as @e[type=armor_stand,tag=new_stand] at @s as @e[type=armor_stand,distance=..0.1] run scoreboard players add #count count 1
execute if score #count count matches 2.. run kill @e[type=armor_stand,tag=new_stand]

scoreboard players reset #check_count check_count
tag @e[type=armor_stand,tag=new_stand] remove new_stand

This works by having all armor stands within a 0.1 block radius (so basically the exact same spot) add 1 score to a fake player, #count.

If there is only 1 armor_stand, #count will only have a score of 1.

If there are multiple armor_stands, #count will have a score of 2 or greater. If it does, kill the new armor stand.

Finally, reset #count's score and remove the new_stand tag.


Old answer

execute as @e[type=minecraft:armor_stand,name=land] at @s run execute as @e[type=minecraft:armor_stand,distance=..0.1,name=land,limit=1] run kill @s

You might have issues with armor stands detecting themselves and killing themselves.

Answered by ginkgo on September 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP