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

Started by Litleck on

Topic category: Advanced modding

Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How could I create a sphere shape with random x,y,z coords?

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.

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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.

Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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?