-
Notifications
You must be signed in to change notification settings - Fork 6
/
arrows.py
35 lines (28 loc) · 930 Bytes
/
arrows.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
"""
Implement exploding arrows.
"""
from mciwb.imports import (
Direction,
Item,
Monitor,
Vec3,
get_client,
parse_nbt,
vec2params,
)
exploding = "exploding_arrows"
arrow_entity = "limit=1, type=arrow, nbt={inGround:1b}"
def enable_explosions(power=1):
def explosion_test():
c = get_client()
result = c.data.get(entity=f"@e[{arrow_entity}]")
if "Arrow has" in result:
nbt = parse_nbt(result)
pos = Vec3(*nbt["Pos"]).with_ints()
c.kill(f"@e[{arrow_entity}, {vec2params(pos)}]")
for i in range(power):
c.summon(str(Item.TNT), pos + Direction.UP * (i - power // 2))
c.summon(str(Item.TNT), pos + Direction.EAST * (i - power // 2))
c.summon(str(Item.TNT), pos + Direction.NORTH * (i - power // 2))
Monitor.stop_named(exploding)
Monitor(explosion_test, name=exploding)