From 27adfd1b6f7cb46ffe769c55d9dacb06cc38257f Mon Sep 17 00:00:00 2001 From: punchready Date: Fri, 4 Jun 2021 04:45:25 +0200 Subject: [PATCH] feat: respectfully add NPC deserializing --- .../json/ingame/deserialize/EntityDeserializer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/deserialize/EntityDeserializer.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/deserialize/EntityDeserializer.java index 8432413..9826b6d 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/deserialize/EntityDeserializer.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/deserialize/EntityDeserializer.java @@ -55,6 +55,16 @@ public class EntityDeserializer extends JsonDeserializer { ((Character) result).inventory.addStone(StoneType.valueOf(i)); } } + case NPC -> { + result = new NPC( + new EntityID(EntityType.NPC, node.get("ID").asInt()), + codec.treeToValue(node.get("position"), IntVector2.class), + node.get("MP").asInt() + ); + for (var i: codec.treeToValue(node.get("stones"), Integer[].class)) { + ((NPC) result).inventory.addStone(StoneType.valueOf(i)); + } + } case InfinityStone -> result = new InfinityStone( new EntityID(EntityType.InfinityStones, node.get("ID").asInt()), codec.treeToValue(node.get("position"), IntVector2.class),