all entities serialize templates
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-14 21:26:13 -04:00
parent f60d83172d
commit baea1e1906
3 changed files with 14 additions and 2 deletions

View File

@ -1784,6 +1784,7 @@ Grid alignment visualization work
Move around entity debug tab classes Move around entity debug tab classes
Grid alignment data editing in debug menus Grid alignment data editing in debug menus
Grid alignment offsets work Grid alignment offsets work
Inventory state in non-creatures actually saves/loads to/from disk

View File

@ -1002,7 +1002,7 @@ public class CommonEntityUtils {
public static ObjectTemplate getObjectTemplate(Entity e){ public static ObjectTemplate getObjectTemplate(Entity e){
ObjectTemplate template = (ObjectTemplate)e.getData(EntityDataStrings.OBJECT_TEMPLATE); ObjectTemplate template = (ObjectTemplate)e.getData(EntityDataStrings.OBJECT_TEMPLATE);
if(template == null){ if(template == null){
return null; template = ObjectTemplate.create(CommonEntityUtils.getEntityType(e), CommonEntityUtils.getEntitySubtype(e));
} }
ObjectInventoryData inventoryData = template.getInventoryData(); ObjectInventoryData inventoryData = template.getInventoryData();
inventoryData.clear(); 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; return template;
} }

View File

@ -66,6 +66,15 @@ public class StateCollection {
this.values.add(value); 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;
}
/** /**
* <p> Automatically generated </p> * <p> Automatically generated </p>
* <p> * <p>