How to reset a minigame world
You can either replace all the chests one by one without changing everything around them or resetting the whole map. Both is possible.
Method 1: replacing chests only
Emptying a chest is easy. All you need to do is use the /setblock
command to put a chest to certain coordinates. For example, let's say we want to replace a chest at coordinates 0 100 0
:
/setblock 0 100 0 minecraft:chest
Setting a chest like this makes it automatically empty and facing north. However, if you want to have preset items in chests and you also want the chests facing a certain way, you can do that as well.
The easiest way to do so is to build your chests and put items inside as you want them, then hover over the chest with your cursor and press F3 + I. This will copy a /setblock
command to your clipboard (a better explanation of how to do this can be found here). If the chest had a diamond in the first slot, the command would look like this:
/setblock 0 100 0 minecraft:chest[facing=north,type=single,waterlogged=false]{Items:[{Slot:0b,id:"minecraft:diamond",Count:1b}]}
Paste it into a command block that you'll be using when resetting the map.
For some reason, when testing this I found out that the command that sets the chest with items in it only works if the block you're about to set isn't a chest already. Else, it just creates an empty chest. The solution is to have a 2 block command chain: one which will /setblock
air, and the other which will /setblock
a chest with items in it. It will look like this:
Command block 1 is set to Impulse Unconditional Needs redstone and has the following command:
/setblock 0 100 0 minecraft:air
Command block 2 is set to Chain Unconditional Always active and looks like this:
/setblock 0 100 0 minecraft:chest[facing=north,type=single,waterlogged=false]{Items:[{Slot:0b,id:"minecraft:diamond",Count:1b}]}
If you power command block 1, the block at 0 100 0
will be replaced with a chest that has a diamond in it's first slot.
Of course, each chest will have its own command block chain with different coordinates and item sets.
Method 2: resetting the entire map
This method is easier to do, but causes a lot of lag when loading the map, and is not suitable for very big maps.
First off, you'll need a copy of the map somewhere in your world. You can do that by /clone
ing the entire map to a different location.
To do so, get the coordinates of two opposite corners of your map. So, if one corner of your map is located at 1 1 1
and the map is 100 blocks long and wide, and 1 block tall, the two coordinates that you would need could be 1 1 1
and 100 1 100
.
Now you need a location to clone the map to. That can be wherever you like it to. For example to 0 0 200
. The result could look like:
/clone 1 1 1 100 1 100 0 0 200
If that's unclear, here's a tutorial for /clone
.
Now you have a copy of the map. Each time you reset the map, clone the copy of the map onto the playing field the same way as you created the copy of the map to overwrite the playing field.
Unfortunately, there is a huge problem with cloning maps as big as you have. The maximum allowed size of a cloned area is 32768 blocks. If your 1000x1000 map is 50 blocks high, that would mean you have to clone a total of 50 000 000 blocks. You'd have to split up the process into at least 1500 separate /clone
commands just because of how big the map would be, which is absurd.
In conclusion, the method with replacing each chest individually will probably be better.
Keep in mind that there's one more thing to worry about: having the entire map loaded at all times. If the area where you want to /setblock
or /clone
blocks is not loaded (it's out of anyone's render distance), the command will not execute. The easiest way to keep chunks loaded is with the command /forceload
.