entities: move entity attributes to sub json object

This commit is contained in:
Bixilon 2021-04-05 23:19:42 +02:00
parent 446a500fdb
commit 61fd25f300
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -57,6 +57,7 @@ object EntityGenerator : Generator(
// ToDo: entityData.addProperty("category", entityType.getEntityCategory(entity).ordinal)
if (entity is LivingEntity && entity2 is LivingEntity) {
val attributesData = JsonObject()
for ((resourceLocation, attribute) in ATTRIBUTE_MAP) {
val attributes = LIVING_ENTITY_GET_ATTRIBUTES_METHOD.invoke(entity) ?: continue
val instance = BASE_ATTRIBUTE_MAP_GET_INSTANCE_METHOD.invoke(attributes, attribute) as EntityAttributeInstance? ?: continue
@ -68,7 +69,11 @@ object EntityGenerator : Generator(
if (value != value2) {
continue
}
entityData.addProperty(resourceLocation, value)
attributesData.addProperty(resourceLocation, value)
}
if (attributesData.size() > 0) {
entityData.add("attributes", attributesData)
}
// entity.getEatingSound(ItemStack.EMPTY)?.let {