2
Need help with spreadplayers command
The /spreadplayers command is used in my map to teleport items to a random location (as it is intended), however, I want the items to only land on blocks of a certain type. Does anyone know the solution to my problem?
Create an account or sign in to comment.
18
1
So how do you only teleport items from a specific location? Just @e[type=item,x=__,y=__,z=__] does not work
1
x,y,z will state the coordinates the selector will search from. If you're ok with a spherical distance for the slector to search for, add distance=..<radius> to the selector
1
so an x,y,z and a distance? because this is what I have now: /spreadplayers -801 441 1 9 false @e[type=item,x=-824,y=122,z=506,distance=..2]
1
yes. That command should spread items within 2 blocks (1 in the block where the coord is and 1 outside that coord in all directions) of those coords to your stated coords beforehand
1
I am now at the next problem however, the items spawn at the structure void block I have placed around the water blocks, any other block I could use perhaps?
1
Yet again I have solved this by teleporting the items to the ground level as soon as they are spread
2
Found the solution, place lava high in the sky above the blocks where I don't want the items to spawn. It delays the items to spread for a bit but nonetheless it still works as intended
2
I think this works because spreadplayers acts on the bottommost block with an unobtruded sky view, and it only acts on solid blocks. (Hence why you cant use /spreadplayers on a water world custom world)
1
the only problem with this is the massive shadow it produces. any solutions for that perhaps?
1
Unless you put a lightblock under the lava or on top of the bottommost block under the lava, nope.
1
Putting lanterns around the map gives it some nice atmosphere, so it's a lucky coincidence
2
Unfortunately Command Witchery's method of entity marking before random tping or cookedporkbacon's method of tping the items until the block below are the only ways.
You cannot detect what block is in a certain coordinate or range of coordinates without a reference, such as an item, a marker or a raycast from underneath the player (because you said it was done in a flat area). The solution will always have an iterative nature
You cannot detect what block is in a certain coordinate or range of coordinates without a reference, such as an item, a marker or a raycast from underneath the player (because you said it was done in a flat area). The solution will always have an iterative nature
- If you want the most efficient way, use markers and use spreadplayers on them first, as they are the most efficient entity in the game (nearly no nbt). Items on the otherhand do have a lot of nbt so dont do method 2.
- Test if the block underneath is a certain block, if not, do a spreadplayer command on the marker again (easily done in functions)
- If it is, then tp the map item there and kill the marker.
3
If you dont have that many blocks then you can simply have an entity marking every single location, and then use the /tp command to teleport to a random location.
Other than that you might be able to do some trickery by using the under subcommand, so that is has to be below y something, and not having any air (all the way to bedrock) at some spots, but I haven't tested that
Other than that you might be able to do some trickery by using the under subcommand, so that is has to be below y something, and not having any air (all the way to bedrock) at some spots, but I haven't tested that
1
Theres an under subcommand?
I havent seen any trace of it in the wiki nor in the minecraftcommand discord and for y detection its usually [y=<y_coord>,dy=<0 - y_coord>]
I havent seen any trace of it in the wiki nor in the minecraftcommand discord and for y detection its usually [y=<y_coord>,dy=<0 - y_coord>]
1
the technique with the entities would be causing way too much lag and it needs to be done in a flat area so I don't think that the under command would work
1
You could run the command over and over again until it lands on the right block:
/execute unless block ~ ~-1 ~ minecraft:whatever run spreadplayers ...
/execute unless block ~ ~-1 ~ minecraft:whatever run spreadplayers ...
1
but then the item would be teleporting constantly until it reaches the right block, right?
1
True. This is a tough problem to solve