I need to detect and kill sand (only sand) as an item drop in a specific area. I can detect and kill sand if it’s dropped anywhere using a lengthy command, but it doesn’t include the part where it only kills it in a certain area.

It doesn't matter whether the detection part of the command is within the killing area or not, though it would be preferred.

I'm on Java Version 1.14.4

My current command is: /execute at @e[type=item,nbt={id:”minecraft:sand”}}] run kill @e[type=item,nbt={id:”minecraft:sand”}}]

  • What command are you currently using? – Corsaka Feb 7 at 10:27
  • Why are you using 1.14.1? That's not a very old version, but it's still weird that you're not using 1.14.4. I'm pretty sure that the only thing that changed are bug fixes. And of course 1.15.2 also exists and is in my opinion better in every way (except if you hate bees). – Fabian Röling Feb 7 at 11:19
  • This is a duplicate of gaming.stackexchange.com/q/262782/171580 , but the website isn't letting me close it or add the MCJava tag. – Fabian Röling Feb 7 at 11:24
  • 4
    Does this answer your question? How do I kill a specific item with a command block – Corsaka Feb 7 at 13:40
  • This question asks about killing entities in a specific area. The linked question does not answer this question at all. – Gigazelle Feb 8 at 0:18

The dx,dy and dz arguments can be used to specify an area in the selector. Example:

/kill @e[type=item,nbt={Item:{id:"minecraft:sand"}},x=5,y=5,z=5,dx=10,dy=10,dz=10]

^ this command will remove any sand items located between 5,5,5 and 15,15,15

x,y and z are the coordinates of one corner and dx,dy and dz are the width, height and length of the cube area. You can read about these arguments on the wiki https://minecraft.gamepedia.com/Commands in the Selecting targets by volume section.

Not the answer you're looking for? Browse other questions tagged or ask your own question.