File: explosify.py

package info (click to toggle)
minetest-mod-pycraft 0.22-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,744 kB
  • sloc: python: 79,282; makefile: 10
file content (36 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (3)
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
#
# Code under the MIT license by Alexander Pruss
#

from mc import *
import math
import sys
from ast import literal_eval

def parseBlock(s):
    try:
        return literal_eval(s)
    except:
        return globals()[s.upper()]

def replace(mcx,mcy,mcz,R,mcblock):
  for x in range(-R,R):
     for y in range(-R,R):
         for z in range(-R,R):
            if (x**2 + y**2 + z**2 <= R**2 and mc.getBlock(mcx+x,mcy+y,mcz+z) != AIR.id):
                mc.setBlock(mcx+x,mcy+y,mcz+z,mcblock)

mc = Minecraft()

playerPos = mc.player.getPos()
R = 20
b = TNT

if len(sys.argv) >= 2:
   R = int(sys.argv[1])
   if len(sys.argv) >= 3:
      b = parseBlock(sys.argv[2])

replace(playerPos.x, playerPos.y, playerPos.z, R, b)

mc.postToChat("Explosify done")