Skip to content

Commit

Permalink
Use new entities.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjum committed Jan 10, 2016
1 parent cb4d31e commit ae1b05d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ materials indexed by name

## Entities

### entities
### mobs

entities indexed by id
entities with `type == 'mob'` indexed by id

### objects

entities with `type == 'object'` indexed by id

### entities_name

Expand Down
2 changes: 1 addition & 1 deletion minecraft_data/data
7 changes: 6 additions & 1 deletion minecraft_data/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def convert(dir):
'instruments': _by_id(data['instruments']),
'instruments_list': data['instruments'],
'materials': data['materials'],
'entities': _by_id(data['entities']),
'mobs': _by_id(_filter('type', 'mob', data['entities'])),
'objects': _by_id(_filter('type', 'object', data['entities'])),
'entities_name': _by_name(data['entities']),
'entities_list': data['entities'],
'protocol': data['protocol'],
Expand Down Expand Up @@ -64,6 +65,10 @@ def _by(key, data):
return {item[key]: item for item in data}


def _filter(key, val, data):
return [d for d in data if d[key] == val]


def find_by(key, *args):
for arg in args:
if key in arg:
Expand Down

0 comments on commit ae1b05d

Please sign in to comment.