I'm playing in a level Minecraft world. The slimes are always bustling there. I want to try to set a command block that will execute a / kill command whenever a slime is nearby that will kill the slimes. Can someone tell me what the command should look like and which settings or external structural changes (redstone, etc.) must be made?
You don't need a command block, you can change the gamerule.
/ gamerule doMobSpawning true
The upper and lower case must be observed!
no MOBS (monsters etc.) are spawned by the command.
First, to turn mob spawning off you would have to write it like this:
/ gamerule doMobSpawning false
Second, if you just want to turn off the slimes / monsters, I would use this command:
/ difficulty peaceful
If you only want to knock out slimes, you have to use your method, for which you use two commands:
/ kill @e [type = slime]
And this so that all drops, i.e. Slim balls, are deleted:
/ kill @e [type = item, nbt = {Item: {id: "minecraft: slime_ball"}}]
Thank you