2

Need help with spreadplayers command

WatermelonFarm's Avatar WatermelonFarm8/5/21 12:47 pm history
8/9/2021 7:08 pm
HoboMaggot's Avatar HoboMaggot
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's Avatar
WatermelonFarm
Level 29 : Expert Engineer
30

Create an account or sign in to comment.

18

1
08/09/2021 6:24 am
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
So how do you only teleport items from a specific location? Just @e[​type=item,x=__,y=__,z=__] does not work
1
08/09/2021 9:02 amhistory
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
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
08/09/2021 12:16 pmhistory
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
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
08/09/2021 7:08 pm
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
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
08/07/2021 9:39 am
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
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
08/07/2021 3:04 pm
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
Yet again I have solved this by teleporting the items to the ground level as soon as they are spread
2
08/06/2021 9:25 amhistory
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
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
08/06/2021 9:43 am
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
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
08/06/2021 11:05 am
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
the only problem with this is the massive shadow it produces. any solutions for that perhaps?
1
08/06/2021 11:16 pm
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
Unless you put a lightblock under the lava or on top of the bottommost block under the lava, nope.
1
08/07/2021 7:21 am
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
Putting lanterns around the map gives it some nice atmosphere, so it's a lucky coincidence
2
08/05/2021 7:33 pm
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
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
3
08/05/2021 4:25 pm
Level 63 : High Grandmaster Robot
Command Witchery
Command Witchery's Avatar
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
1
08/05/2021 7:37 pm
Level 52 : Grandmaster Blob
HoboMaggot
HoboMaggot's Avatar
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
08/05/2021 6:24 pm
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
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
08/05/2021 1:39 pm
Level 61 : High Grandmaster Baconator
cookedporkbacon
cookedporkbacon's Avatar
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
08/05/2021 1:49 pm
Level 29 : Expert Engineer
WatermelonFarm
WatermelonFarm's Avatar
but then the item would be teleporting constantly until it reaches the right block, right?
1
08/05/2021 3:52 pm
Level 61 : High Grandmaster Baconator
cookedporkbacon
cookedporkbacon's Avatar
True. This is a tough problem to solve
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome