You can use NBTExplorer for this.
Why? Because the command(s) you had in your command blocks are stored in the NBT data of the command block. Using NBTExplorer, you can find the command block, but only if:
If you do not know any part of the command being run, try typing "@
", "/
" or "
" into the search box. (Thanks to @MBraedley for the notice)
How to install NBTExplorer:
You will have to have .NET framework 2.0 (or higher) to run the program. You can download the installer for Windows (and Linux with mono-core and mono-winforms packages installed) here and here for Mac.
After downloading, unzip the .zip file (I recommend doing so to do this in a new folder). Then run the program labeled "NBTExplorer.exe"
How to use NBTExplorer
One you have installed the application, run it. Then proceed by these steps:
Click on File in the upper tab and then select Open Minecraft Save Folder (not needed in newer versions)
Select your world from the GUI. Double click on it after it shows in the window, and then single-click (select) the folder "region":
If you look inside it (not needed), you should see files labeled *.mca or *.mcr, for example "r.0.1.mcr"
- Click Search in the upper tab and then Find in the list that appears:
- A window named "Find" will pop up. Inside will be two checkboxes and two text areas next to them. Check both boxes. In the first empty text box, enter "Command". In the second one, type any part of the command in your command block you remember. I guess that you used the command "
time set day
". If so, enter that command into the box. Else enter any part of the command you remember:
- Click on Find or press Enter on your keyboard. After a while (depending on your world size, from seconds to minutes), your search will return a result (the first it found) - it will show you the full command, the coordinates and some more NBT data of the command block with the command you searched for:
My testing world (the map The Dropper) didn't have the command "time set day
" anywhere, so instead I searched for /spawnpoint
:
If this is the command block you searched for, take the coordinates it gave you (X, Y, Z) and teleport to them in Minecraft by /tp @p X Y Z
.
If the command block it found is not the one you searched for, press Search on the upper tab, and then press Find next in the list that pops up:
Then, repeat steps 5-7 until you find your command block!
- If the program didn't find the wanted result, try searching for something else (eg. just
time set
instead of time set day
).
For further reference, here are some links:
Best Answer
So this is complicated, but not much worse than preventing a player from crafting a diamond sword. The biggest difference here is that everything must happen on the same tick, and it must happen every tick. This precludes the strategy I used in the linked answer; a 20hz fill clock is pretty much a necessity, whereas I could use a slower, simpler clock in that other answer. For this to work, you're still going to want to disable mob griefing, as I'm using ghast fireballs to create the actual explosion. It's also possible to have the effect, but cause 0 damage to players or other entities, and I'll add the commands for that at the end.
The first step is to set up a scoreboard objective to track TNT that's about to explode:
Next, we need to set up a
fill
clock. You'll need two command blocks in a column with an air block separating them. In the bottom, enter the following command:and in the top one, enter this command:
Put a redstone block between the two, and you have your fill clock. Ideally, this won't be near a chunk boundary, but mine was and it still worked fine. Funny stuff can start happening if part of a fill clock gets unloaded from memory, but if it's a spawn chunk or you're always near the clock, you don't have to worry.
You should see three more redstone blocks out one side. You're going to put down three more command blocks adjacent to the redstone blocks (preferably above or below). In order of closest to the first two command blocks, the commands you want to use are:
Okay, let's go over those three commands. The first sets the scoreboard value for the TNTGoBoom objective to 1 for every TNT that's ready to explode on the next tick. This is how we track the TNT. The next command summons an invisible fireball at the exact location of the TNT, moving directly downwards, and with the same explosive power of a piece of TNT. This is what will actually cause the explosion effect and damage to players/entities, but since mob griefing is turned off it won't damage the terrain. Finally, we
kill
(effectively delete) the TNT that's about to explode so that it doesn't damage the terrain.Now if you want to still have the explosion effect without causing any damage, then you need to replace the fireball summon command with 2 command blocks (and therefore extend your fill clock by one more block):
These two commands create the particle effect and sound of TNT exploding, but that's it. There's no damage to the world, players, or entities if you use this instead of the fireball method.
Addendum: So this is really going to mess up things like TNT cannons. I had this running in my creative world where I was previously testing an infinite TNT cannon, and while it kinda works (the projectile TNT still shoots out a bit), it has a tendency to send a fireball into the sky. Also, using this means that each TNT block needs to be lit individually, since with mob-griefing off, the fireball won't light others nearby. I'm sure there's a way around this with a little more command-block-fu. Actually, I know there's a way to do this, I'm just not 100% on the details yet.