feat: respectfully add NPC deserializing

This commit is contained in:
punchready 2021-06-04 04:45:25 +02:00
parent 0fce509111
commit 27adfd1b6f
1 changed files with 10 additions and 0 deletions

View File

@ -55,6 +55,16 @@ public class EntityDeserializer extends JsonDeserializer<Entity> {
((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),