mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-24 20:58:04 -04:00
fix proper class name detection
This commit is contained in:
parent
4dfa4ed1f8
commit
5a04d16516
@ -11,6 +11,7 @@ import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getGetter
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.variable
|
||||
import de.bixilon.pixlyzer.util.Util
|
||||
import de.bixilon.pixlyzer.util.Util.of
|
||||
import de.bixilon.pixlyzer.util.Util.realName
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
@ -93,10 +94,10 @@ object BlockGenerator : Generator(
|
||||
}
|
||||
}
|
||||
|
||||
if (block::class.simpleName == "CampfireBlock") {
|
||||
if (block::class.java.of("CampfireBlock")) {
|
||||
blockData.addProperty("lava_particles", block.variable<Boolean>("emitsParticles"))
|
||||
}
|
||||
if (block::class.simpleName == "TorchBlock") {
|
||||
if (block::class.java.of("TorchBlock")) {
|
||||
block.variable<ParticleEffect>("particle")?.type?.let {
|
||||
blockData.addProperty("flame_particle", Registry.PARTICLE_TYPE.getRawId(it))
|
||||
}
|
||||
|
@ -66,4 +66,16 @@ object Util {
|
||||
|
||||
val Class<*>.realName: String
|
||||
get() = this.name.removePrefix(this.packageName).removePrefix(".")
|
||||
|
||||
fun Class<*>.of(name: String): Boolean {
|
||||
var `class` = this
|
||||
while (`class` != Object::class.java) {
|
||||
if (`class`.realName == name) {
|
||||
return true
|
||||
}
|
||||
|
||||
`class` = `class`.superclass
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user