From 2add25b493bb1b782034a2b7240719937ee36e00 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Thu, 12 Nov 2020 13:27:51 -0800 Subject: [PATCH] Fix blocks topping generating invalid json 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) --- burger/toppings/blocks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/burger/toppings/blocks.py b/burger/toppings/blocks.py index 866c229d..c41a78f5 100644 --- a/burger/toppings/blocks.py +++ b/burger/toppings/blocks.py @@ -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()