-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathegg.py
41 lines (34 loc) · 1.1 KB
/
egg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import mcpi_e.block as block
from mcpi_e.minecraft import Minecraft
from math import *
Block = block.Block
def egg(block=block.GOLD_BLOCK, h=40, a=2.5, b=1, c=0.1):
for y in range(0,h+1):
l = y / float(h)
# Formula from: http://www.jolyon.co.uk/myresearch/image-analysis/egg-shape-modelling/
r = h*a*exp((-0.5*l*l+c*l-.5*c*c)/(b*b))*sqrt(1-l)*sqrt(l)/(pi*b)
r2 = r*r
for x in range(-h,h+1):
for z in range(-h,h+1):
myr2 = x*x + z*z
if myr2 <= r2:
if x==0 and z==0:
theta = 0
else:
theta = atan2(z,x)
yield (x,y,z,block,theta)
address="server"
name="stoneskin"
mc = Minecraft.create(address,4712,name)
if len(sys.argv) >= 2:
height = int(sys.argv[1])
else:
height = 50
if len(sys.argv) >= 3:
material = Block.byName(sys.argv[2])
else:
material = block.GOLD_BLOCK
pos = mc.player.getPos()
for (x,y,z,block,theta) in egg(h=height,block=material):
mc.setBlock(x+pos.x,y+pos.y,z+pos.z,block)