TransWikia.com

How to reset a minigame world

Arqade Asked on July 30, 2021

So I am making a battle royale minigame server in minecraft, and there will be chests that are spawning, so I need to clear all those chests. and I thought that it would be easiest to reset the map somehow, because I couldn’t find out how to /kill a chest. The map size is 1000 blocks squared. So I need a way to reset an area that large. I would really appreciate some help.

3 Answers

I would highly recommend using a plugin to reset the area, there are many plugins available for different server types (spigot, sponge ect) so go with one for whatever your server is on. If for some reason you cant use plugins there are also datapacks available that can reset chests and areas as well.

The reason you cant /kill a chest is because its not an entity btw.

Answered by Topcode on July 30, 2021

As Topcode already stated, using an existing plugin (or create a new one, if you can) makes really most sense. There is a lot to consider....

You can (for example) take a look here: https://www.spigotmc.org/resources/hungergames.65942/

It's a simple (Spigot/Paper) Plugin which should fit your needs. It will also re-fill/empty your placed chests. The sourcecode of this plugin is also available (https://github.com/ShaneBeeStudios/HungerGames).

Answered by Ben on July 30, 2021

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 chain

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 /cloneing 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.

Answered by Quijibo on July 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