How could I create a sphere shape with random x,y,z coords?

Started by Litleck on Sat, 06/30/2018 - 04:20

Topic category: Advanced modding

Last seen on 14:19, 15. Sep 2018
Joined May 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How could I create a sphere shape with random x,y,z coords?
Sat, 06/30/2018 - 04:20

Hello,

So I have created this function which randomly places a block in a specified range.

Procedure

 

 

 

 

This gets blocks randomly placed in a cube of 4 blocks away from the center point.  How would I be able to modify this so that it'll form a sphere?  I would need to use sin, cos and maybe some tan? 

All help will be appreciated.

Last seen on 13:44, 15. May 2020
Joined Oct 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
This is out of my…
Sat, 06/30/2018 - 14:26

This is out of my possibilities. I can suggest you something, but it is VEERY long. And I don't know if I got you right.

So, for range 1 sphere(1 block on every side) use something like "place block x+1, x-1, y+1, y-1, z+1, z-1" and if you want to more just loop it but except 1 you place another variable that is increasing every loop. But if you mean placing blocks in sphere range rather than cuboid, sorry. This is out of my possibilities.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
The easiest way is iterating…
Sat, 06/30/2018 - 19:01

The easiest way is iterating a cube (centered to the center of the sphere) that has the length of a side two times bigger than the radius of the sphere, and checking for each block in the cube if its distance from the center is less or equal to the radius.

Last seen on 10:07, 14. Aug 2020
Joined Jul 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Wouldn't it just be easier…
Mon, 07/02/2018 - 04:43

Wouldn't it just be easier to create a schematic of a sphere thing & then just use the "Place schematic" button?

Last seen on 07:25, 22. Oct 2020
Joined Apr 2010
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You can use the loop blocks…
Mon, 07/02/2018 - 08:22

You can use the loop blocks in MCreator to achieve this the way Nuparu suggested.