mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-27 14:10:01 -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 net.minecraft.util.registry.Registry
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import java.lang.reflect.Modifier
|
import java.lang.reflect.Modifier
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
object EntityGenerator : Generator(
|
object EntityGenerator : Generator(
|
||||||
"entities"
|
"entities"
|
||||||
@ -191,6 +192,8 @@ object EntityGenerator : Generator(
|
|||||||
null
|
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 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")!!
|
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)
|
return Triple(ENTITY_WIDTH_FIELD!!.getFloat(entityType), ENTITY_HEIGHT_FIELD!!.getFloat(entityType), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getAttributes(): Map<String, EntityAttribute> {
|
private fun getAttributes(): Map<String, EntityAttribute> {
|
||||||
val attributeRegistryField = getField(Registry::class.java, "ATTRIBUTE", "ATTRIBUTES")
|
val attributeRegistryField = getField(Registry::class.java, "ATTRIBUTE", "ATTRIBUTES")
|
||||||
val attributeNameField = try {
|
val attributeNameField = try {
|
||||||
@ -257,7 +259,14 @@ object EntityGenerator : Generator(
|
|||||||
} ?: let {
|
} ?: let {
|
||||||
val registry = attributeRegistryField!!.get(null) as Registry<*>
|
val registry = attributeRegistryField!!.get(null) as Registry<*>
|
||||||
val method = attributeRegistryField.type.getMethod("getKey", Object::class.java)
|
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