Fix jobstate bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import importlib
|
||||
from math import floor, ceil
|
||||
from math import floor, ceil, sqrt, hypot
|
||||
|
||||
import blocks
|
||||
importlib.reload(blocks)
|
||||
@@ -31,6 +31,38 @@ def cap(x, amount):
|
||||
sign = 1 if x >= 0 else -1
|
||||
return sign * min(abs(x), amount)
|
||||
|
||||
def spiral(n):
|
||||
# return x, 0, z coords along a spiral at step n
|
||||
# I forget where I found this
|
||||
n += 1
|
||||
k = ceil((sqrt(n)-1)/2)
|
||||
t = 2 * k + 1
|
||||
m = t**2
|
||||
t = t - 1
|
||||
if n >= m-t:
|
||||
return k-(m-n), 0, -k
|
||||
else:
|
||||
m = m-t
|
||||
if n >= m-t:
|
||||
return -k, 0, -k+(m-n)
|
||||
else:
|
||||
m = m-t
|
||||
if n >= m-t:
|
||||
return -k+(m-n), 0, k
|
||||
else:
|
||||
return k, 0, k-(m-n-t)
|
||||
|
||||
def alternate(n, amount):
|
||||
# return 0, y, 0 where y alternates +/- by amount
|
||||
# example: 0, 2, -2, 4, -4, 6, -6 for amount = 2
|
||||
sign = 1 if n % 2 else -1
|
||||
return (0, ceil(n/2) * sign * amount, 0)
|
||||
|
||||
def diffrange(n):
|
||||
# same as range(n+1) but can go negative
|
||||
sign = 1 if n >= 0 else -1
|
||||
return range(0, n+sign, sign)
|
||||
|
||||
def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantments=[], effects={}):
|
||||
# from PrismarineJS/prismarine-block
|
||||
data = blocks.get(block_id)
|
||||
|
||||
Reference in New Issue
Block a user