mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-26 13:40:02 -04:00
fix entity attribute bad resource location in json
This commit is contained in:
parent
61fd25f300
commit
f2af044905
@ -16,6 +16,7 @@ import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.registry.Registry
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
|
||||
object EntityGenerator : Generator(
|
||||
"entities"
|
||||
@ -191,6 +192,8 @@ object EntityGenerator : Generator(
|
||||
null
|
||||
}
|
||||
|
||||
private val REGISTRY_KEY_VALUE_FIELD = getField(getClass("net.minecraft.util.registry.RegistryKey"), "value")
|
||||
|
||||
private val ENTITY_TYPE_FIRE_IMMUNE_FIELD = getField(EntityType::class.java, "fireImmune")
|
||||
|
||||
private val ATTRIBUTE_CLASS = getClass("net.minecraft.world.entity.ai.attributes.Attributes", "net.minecraft.world.entity.monster.SharedMonsterAttributes", "net.minecraft.entity.attribute.EntityAttributes")!!
|
||||
@ -235,7 +238,6 @@ object EntityGenerator : Generator(
|
||||
return Triple(ENTITY_WIDTH_FIELD!!.getFloat(entityType), ENTITY_HEIGHT_FIELD!!.getFloat(entityType), null)
|
||||
}
|
||||
|
||||
|
||||
private fun getAttributes(): Map<String, EntityAttribute> {
|
||||
val attributeRegistryField = getField(Registry::class.java, "ATTRIBUTE", "ATTRIBUTES")
|
||||
val attributeNameField = try {
|
||||
@ -257,7 +259,14 @@ object EntityGenerator : Generator(
|
||||
} ?: let {
|
||||
val registry = attributeRegistryField!!.get(null) as Registry<*>
|
||||
val method = attributeRegistryField.type.getMethod("getKey", Object::class.java)
|
||||
ret[method.invoke(registry, attribute).toString()] = attribute
|
||||
var key = method.invoke(registry, attribute)
|
||||
if (key is Optional<*>) {
|
||||
key = key.get()
|
||||
}
|
||||
if (key::class.java.simpleName == "RegistryKey") {
|
||||
key = REGISTRY_KEY_VALUE_FIELD!!.get(key)
|
||||
}
|
||||
ret[key.toString()] = attribute
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user