Skip to content

Commit

Permalink
Compatibility up to 12w19a + Metadata for recipe results
Browse files Browse the repository at this point in the history
  • Loading branch information
dalbothek committed May 22, 2012
1 parent f2032fa commit d58019e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion burger/toppings/identify.py
Expand Up @@ -136,5 +136,5 @@ def act(aggregate, jar, verbose=False):
result = identify(cf)
if result:
classes[result[0]] = result[1]
if len(classes) == 7:
if len(classes) == 8:
break
18 changes: 16 additions & 2 deletions burger/toppings/recipes.py
Expand Up @@ -69,10 +69,12 @@ def find_recipes(jar, cf, method, target_class, setter_names):
tmp_recipes = []
started_item = False
next_push_is_val = False
with_metadata = False
block_substitute = None
block_subs = {}
rows = []
make_count = 0
metadata = 0
recipe_target = None
pushes_are_counts = False
positions = True
Expand All @@ -94,8 +96,10 @@ def find_recipes(jar, cf, method, target_class, setter_names):
started_item = True
pushes_are_counts = False
next_push_is_val = False
with_metadata = False
rows = []
make_count = 0
metadata = 0
recipe_target = None
method_name = const["name_and_type"]["name"]["value"]
positions = method_name == setter_names[0]
Expand Down Expand Up @@ -149,16 +153,23 @@ def find_recipes(jar, cf, method, target_class, setter_names):
cl_name = const["class"]["name"]["value"]
cl_field = const["name_and_type"]["name"]["value"]

recipe_target = (cl_name, cl_field)
recipe_target = (cl_name, cl_field, metadata)
print recipe_target
# Block string substitute value
elif ins.name == "bipush" and next_push_is_val:
next_push_is_val = False
block_subs[chr(ins.operands[0][1])] = block_substitute
# Number of items that the recipe makes
elif ins.name == "bipush" and pushes_are_counts:
make_count = ins.operands[0][1]
if with_metadata:
metadata = make_count
with_metadata = False
elif ins.name.startswith("iconst_") and pushes_are_counts:
make_count = int(ins.name[-1])
if with_metadata:
metadata = make_count
with_metadata = False
# Recipe row
elif ins.name == "ldc" and started_item:
const_i = ins.operands[0][1]
Expand All @@ -185,6 +196,8 @@ def find_recipes(jar, cf, method, target_class, setter_names):
name = const["name_and_type"]["name"]["value"]
if name == "<init>":
pushes_are_counts = True
if "II" in const["name_and_type"]["descriptor"]["value"]:
with_metadata = True
return tmp_recipes

tmp_recipes = find_recipes(jar, cf, method, target_class, setter_names)
Expand All @@ -204,7 +217,7 @@ def find_recipes(jar, cf, method, target_class, setter_names):
def getName(cls_fld):
if cls_fld is None:
return None
field = ":".join(cls_fld)
field = ":".join(cls_fld[:2])
if field in block_map:
return block_map[field]
elif field in item_map:
Expand Down Expand Up @@ -247,6 +260,7 @@ def getName(cls_fld):
# Try to get the created item/block name.
target = getName(recipe["recipe_target"])
final["makes"] = target
final["metadata"] = recipe["recipe_target"][2]
if isinstance(target, dict):
key = target["id"]
elif target is None:
Expand Down

0 comments on commit d58019e

Please sign in to comment.