-
Notifications
You must be signed in to change notification settings - Fork 4
/
deathstar.py
executable file
·117 lines (87 loc) · 4.56 KB
/
deathstar.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as mcstuff
import math
from time import sleep
from random import randint
class DeathStar:
def __init__(self, pos, radius):
self.mc = minecraft.Minecraft.create()
self.pos = pos
self.radius = radius
self._draw()
def _draw(self):
mcDraw = mcstuff.MinecraftDrawing(self.mc)
#create hollow sphere for death star
mcDraw.drawHollowSphere(self.pos.x, self.pos.y, self.pos.z, self.radius, block.WOOL.id, 7)
#create a gun
self.gunX, self.gunY, self.gunZ = self._findPointOnSphere(self.pos.x, self.pos.y, self.pos.z,
45, 25, self.radius)
self.mc.setBlock(self.gunX, self.gunY, self.gunZ, block.WOOL.id, 14)
#gunX, gunY, gunZ = self._findPointOnSphere(self.pos.x, self.pos.y, self.pos.z,
# 45, 25, self.radius)
#rotate around point and draw a circle
#for angle in range(0,360,15):
# circleX, circleY, circleZ = self._findPointOnSphere(gunX, gunY, gunZ, angle, 155, 5)
# mc.setBlock(circleX, circleY, circleZ, block.WOOL.id, 15)
#angles = ((45,17),(45,33),(37,25),(53,25))
#for angle in angles:
# x,y,z = self._findPointOnSphere(self.pos.x, self.pos.y, self.pos.z,
# angle[0], angle[1], self.radius)
# self.mc.setBlock(x,y,z,block.WOOL.id,15)
#gunX2, gunY2, gunZ2 = self._findPointOnSphere(self.pos.x, self.pos.y, self.pos.z,
# 45, 25, int(self.radius + (self.radius / 2) + 1))
#draw a sphere of black wool, outside the death star to create the divit
#mcDraw.drawSphere(gunX, gunY, gunZ, int(self.radius - (self.radius / 2.5)), block.AIR.id, 15)
#mcDraw.drawSphere(gunX2, gunY2, gunZ2, int(self.radius - (self.radius / 2.5) + 1), block.AIR.id)
#create some black blocks over the surface
#for count in range(0,200):
# angle = randint(0,359)
# pitch = randint(-90,90)
# x, y, z = self._findPointOnSphere(self.pos.x, self.pos.y, self.pos.z,
# angle, pitch, self.radius - 1)
# self.mc.setBlock(x, y, z, block.WOOL.id, 15)
#create horizontal circle all the way round
mcDraw.drawHorizontalCircle(self.pos.x, self.pos.y, self.pos.z,
self.radius, block.AIR.id)
mcDraw.drawHorizontalCircle(self.pos.x, self.pos.y, self.pos.z,
self.radius - 1, block.WOOL.id, 15)
def fire(self, x, y, z, delayStart, delayEnd):
#draw a red line between the gun and the point
sleep(delayStart)
mcDraw = mcstuff.MinecraftDrawing(self.mc)
mcDraw.drawLine(self.gunX, self.gunY, self.gunZ,
x, y, z,
block.WOOL.id, 14)
sleep(delayEnd)
#clear the line
mcDraw.drawLine(self.gunX, self.gunY, self.gunZ,
x, y, z,
block.AIR.id)
def destroy(self):
mcDraw = mcstuff.MinecraftDrawing(self.mc)
mcDraw.drawSphere(self.pos.x, self.pos.y, self.pos.z,
self.radius, block.LAVA_STATIONARY.id)
sleep(3)
self.clear()
def clear(self):
mcDraw = mcstuff.MinecraftDrawing(self.mc)
mcDraw.drawSphere(self.pos.x, self.pos.y, self.pos.z, self.radius, block.AIR.id)
def _findPointOnSphere(self, cx, cy, cz, horizontalAngle, verticalAngle, radius):
x = cx + (radius * (math.cos(math.radians(verticalAngle)) * math.cos(math.radians(horizontalAngle))))
y = cy + (radius * (math.sin(math.radians(verticalAngle))))
z = cz + (radius * (math.cos(math.radians(verticalAngle)) * math.sin(math.radians(horizontalAngle))))
return self._roundXYZ(x, y, z)
def _roundXYZ(self,x,y,z):
return int(round(x,0)), int(round(y,0)), int(round(z,0))
#tests
if __name__ == "__main__":
print "running"
mc = minecraft.Minecraft.create()
playerPos = mc.player.getTilePos()
playerPos.y += 35
deathStar = DeathStar(playerPos, 20)
sleep(10)
playerPos = mc.player.getTilePos()
deathStar.fire(playerPos.x, playerPos.y, playerPos.z, 1, 5)
deathStar.clear()