Skip to content

Instantly share code, notes, and snippets.

@Arcensoth
Last active February 10, 2018 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arcensoth/18f731cba3736c621bbab994d3dcd770 to your computer and use it in GitHub Desktop.
Save Arcensoth/18f731cba3736c621bbab994d3dcd770 to your computer and use it in GitHub Desktop.
import itertools
import sys
# requires python 3.6+
#
# usage:
# py benchmarkers.py <file> <entity> <range>
#
# where:
# <file> is the pre-formatted file to print commands to, e.g. '{e}.{r}.mcfunction'
# <entity> is one of the keys in 'g' below, e.g. 'clouds'
# <range> is the size of the cube around the player to fill with entities, e.g. 16
e = sys.argv[2]
r = int(sys.argv[3])
f = sys.argv[1].format(e=e, r=r)
g = {
'clouds': lambda x, y, z: ''.join(('summon minecraft:area_effect_cloud ', f'~{x} ~{y} ~{z}', ' {Duration:2000000000}', '\n')),
'items': lambda x, y, z: ''.join(('summon minecraft:item ', f'~{x} ~{y} ~{z}', ' {NoGravity:1b,Invulnerable:1b,Age:-32768s,Health:32767s,PickupDelay:32767s,Item:{id:"minecraft:ender_pearl",Count:1b,tag:{nostack:"', f'{x} {y} {z}', '"}}}', '\n')),
'stands': lambda x, y, z: ''.join((f'summon minecraft:armor_stand ', f'~{x} ~{y} ~{z}', ' {NoGravity:1b,Invulnerable:1b,Marker:1b,Invisible:1b}', '\n')),
}[e]
with open(f, 'w') as fp:
fp.writelines(g(x, y, z) for x, y, z in itertools.product(range(r), repeat=3))
print(f'wrote {r**3} commands to {f}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment