2

Need help with spreadplayers command

WatermelonFarm 8/5/21 12:47 pm history
1.3k
8/9/2021 7:08 pm
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?
Posted by
WatermelonFarm
Level 32 : Artisan Engineer Engineer
41

  Have something to say?

JoinSign in

18

WatermelonFarm
08/09/2021 6:24 am
Level 32 : Artisan Engineer Engineer
So how do you only teleport items from a specific location? Just @e[​type=item,x=__,y=__,z=__] does not work
1
HoboMaggot
08/09/2021 9:02 am
Level 55 : Grandmaster Blob
history
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
WatermelonFarm
08/09/2021 12:16 pm
Level 32 : Artisan Engineer Engineer
history
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
HoboMaggot
08/09/2021 7:08 pm
Level 55 : Grandmaster Blob
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
WatermelonFarm
08/07/2021 9:39 am
Level 32 : Artisan Engineer Engineer
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
WatermelonFarm
08/07/2021 3:04 pm
Level 32 : Artisan Engineer Engineer
Yet again I have solved this by teleporting the items to the ground level as soon as they are spread
1
WatermelonFarm
08/06/2021 9:25 am
Level 32 : Artisan Engineer Engineer
history
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
HoboMaggot
08/06/2021 9:43 am
Level 55 : Grandmaster Blob
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)
2
WatermelonFarm
08/06/2021 11:05 am
Level 32 : Artisan Engineer Engineer
the only problem with this is the massive shadow it produces. any solutions for that perhaps?
1
HoboMaggot
08/06/2021 11:16 pm
Level 55 : Grandmaster Blob
Unless you put a lightblock under the lava or on top of the bottommost block under the lava, nope.
1
WatermelonFarm
08/07/2021 7:21 am
Level 32 : Artisan Engineer Engineer
Putting lanterns around the map gives it some nice atmosphere, so it's a lucky coincidence
1
HoboMaggot
08/05/2021 7:33 pm
Level 55 : Grandmaster Blob
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

  • 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.
Best done in a datapack as can do all the tping in 1 tick using recursion
2
Command Witchery
08/05/2021 4:25 pm
Level 64 : High Grandmaster Robot
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
3
HoboMaggot
08/05/2021 7:37 pm
Level 55 : Grandmaster Blob
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>]
1
WatermelonFarm
08/05/2021 6:24 pm
Level 32 : Artisan Engineer Engineer
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
cookedporkbacon
08/05/2021 1:39 pm
Level 64 : High Grandmaster Baconator
You could run the command over and over again until it lands on the right block:
/execute unless block ~ ~-1 ~ minecraft:whatever run spreadplayers ...
1
WatermelonFarm
08/05/2021 1:49 pm
Level 32 : Artisan Engineer Engineer
but then the item would be teleporting constantly until it reaches the right block, right?
1
cookedporkbacon
08/05/2021 3:52 pm
Level 64 : High Grandmaster Baconator
True. This is a tough problem to solve
1

Welcome