Skip to content

Instantly share code, notes, and snippets.

@ogurets
Created December 16, 2017 21:09
Show Gist options
  • Save ogurets/5d27578215a05258db8f102bb579e666 to your computer and use it in GitHub Desktop.
Save ogurets/5d27578215a05258db8f102bb579e666 to your computer and use it in GitHub Desktop.
Generate spawner entries for RFTools
import sys
class ConfigFormat(object):
@staticmethod
def mobspawn(**kwargs):
print(""" S:"{mobname}.spawnamount.0" <
I
{key}
0
{key_amount}
>
S:"{mobname}.spawnamount.1" <
B
{bulk}
0
{bulk_amount}
>
S:"{mobname}.spawnamount.2" <
L
0
{living_amount}
>""".format(**kwargs))
@staticmethod
def mobrf(**kwargs):
print(' I:"{mobname}"={rf}'.format(**kwargs))
class SourceFormat(object):
@staticmethod
def mobrecord(**kwargs):
print(""" addMobSpawnRF(cfg, "{mobname}", {rf});
addMobSpawnAmount(cfg, "{mobname}", MATERIALTYPE_KEY, "{key}", 0, {key_amount}f);
addMobSpawnAmount(cfg, "{mobname}", MATERIALTYPE_BULK, "{bulk}", 0, {bulk_amount}f);
addMobSpawnAmount(cfg, "{mobname}", MATERIALTYPE_LIVING, null, 0, {living_amount}f);""".format(**kwargs))
def mobentry(mobname, key, key_amount, bulk, bulk_amount, living_amount, rf):
return locals()
mobregistry = [
# mob name key matter key amount bulk bulk amount, living amount, RF cost
mobentry('animania:hamster', 'animania:hamster_food', 0.2, 'minecraft:dirt', 0.5, 10.0, 300),
# TODO: Paste your entries here in the same format as above
]
# Usage:
# run "python rftools_gen_entries.py" to print the lines for config
# run "python rftools_gen_entries.py source" to print the lines for SpawnerConfiguration.java (for the devs or people willing to create a patch)
if len(sys.argv) > 1 and sys.argv[1] == 'source':
for mob in mobregistry:
SourceFormat.mobrecord(**mob)
else:
print('Add this to mobspawnamounts:\n')
for mob in mobregistry:
ConfigFormat.mobspawn(**mob)
print('\n\nAdd this to mobspawnrf:\n')
for mob in mobregistry:
ConfigFormat.mobrf(**mob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment