From 4d118cf634bb5e3e71c2b61d87f87fc596d78b29 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 27 Feb 2024 13:55:26 -0500 Subject: [PATCH] More parsing work. --- src/engine/objects/ItemTemplate.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 16b4972c..8d77c7d5 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -25,6 +25,8 @@ public class ItemTemplate { // Template Properties public String obj_name; public Vector3fImmutable obj_scale; + public Vector3fImmutable obj_forward_vector; + public Vector3fImmutable obj_default_alignment; public int obj_render_object; public int obj_icon; public float combat_health_current; @@ -84,10 +86,23 @@ public class ItemTemplate { // Reading floats from an array (note always check for empty arrays) JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale"); + if (scaleData.isEmpty() == false) obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(), ((Double) scaleData.get(2)).floatValue()); + JSONArray forwardVector = (JSONArray) jsonObject.get("obj_forward_vector"); + + if (forwardVector.isEmpty() == false) + obj_forward_vector = new Vector3fImmutable(((Double) forwardVector.get(0)).floatValue(), ((Double) forwardVector.get(1)).floatValue(), + ((Double) forwardVector.get(2)).floatValue()); + + JSONArray defaultAlighment = (JSONArray) jsonObject.get("obj_default_alignment"); + + if (defaultAlighment.isEmpty() == false) + obj_default_alignment = new Vector3fImmutable(((Double) defaultAlighment.get(0)).floatValue(), ((Double) defaultAlighment.get(1)).floatValue(), + ((Double) defaultAlighment.get(2)).floatValue()); + // Reading an integer value obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue();