diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index ecb44252..609bf58a 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1784,6 +1784,7 @@ Grid alignment visualization work Move around entity debug tab classes Grid alignment data editing in debug menus Grid alignment offsets work +Inventory state in non-creatures actually saves/loads to/from disk diff --git a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java index 53c98789..db3dcb17 100644 --- a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java +++ b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java @@ -1002,7 +1002,7 @@ public class CommonEntityUtils { public static ObjectTemplate getObjectTemplate(Entity e){ ObjectTemplate template = (ObjectTemplate)e.getData(EntityDataStrings.OBJECT_TEMPLATE); if(template == null){ - return null; + template = ObjectTemplate.create(CommonEntityUtils.getEntityType(e), CommonEntityUtils.getEntitySubtype(e)); } ObjectInventoryData inventoryData = template.getInventoryData(); inventoryData.clear(); @@ -1038,7 +1038,9 @@ public class CommonEntityUtils { } } } - template.setStateCollection(StateCollection.getStateCollection(e)); + if(StateCollection.hasStateCollection(e)){ + template.setStateCollection(StateCollection.getStateCollection(e)); + } return template; } diff --git a/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java b/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java index bf372bf0..f4a95e4e 100644 --- a/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java +++ b/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java @@ -66,6 +66,15 @@ public class StateCollection { this.values.add(value); } + /** + * Checks if the entity has a state collection + * @param entity The entity + * @return true if it has a state collection, false otherwise + */ + public static boolean hasStateCollection(Entity entity){ + return Globals.entityValueTrackingService.getEntityTrees(entity) != null; + } + /** *
Automatically generated
*