Skip to content

Commit

Permalink
Fix blocks topping generating invalid json
Browse files Browse the repository at this point in the history
The various return object() statements cause problems if they end up in the result, since object() can't be serialized.  In this case, it's because candles have a light level dependent on a block state, and the lambda for that is stored as a field (instead of being in the block list).  Work around by returning None for that case (same as if the lambda were in the list, but failed to evaluate)
  • Loading branch information
Pokechu22 committed Feb 17, 2022
1 parent 15525e2 commit 2add25b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions burger/toppings/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ def on_get_field(self, ins, const, obj):
return "air"
elif const.class_.name.value == listclass:
return block[block_fields[const.name_and_type.name.value]]
elif const.name_and_type.descriptor == "Ljava/util/function/ToIntFunction;":
# Light level lambda, used by candles. Not something we
# can evaluate (it depends on the block state).
return None
else:
return object()

Expand Down

0 comments on commit 2add25b

Please sign in to comment.