mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-27 05:59:53 -04:00
don't extract block models
This commit is contained in:
parent
c23a271ae7
commit
dd00689b76
@ -46,6 +46,5 @@ object Generators {
|
|||||||
|
|
||||||
|
|
||||||
VoxelShapeGenerator,
|
VoxelShapeGenerator,
|
||||||
ModelsGenerator,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,7 @@ import de.bixilon.pixlyzer.util.ReflectionUtil.getClass
|
|||||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getGetter
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getGetter
|
||||||
import de.bixilon.pixlyzer.util.ReflectionUtil.variable
|
import de.bixilon.pixlyzer.util.ReflectionUtil.variable
|
||||||
import de.bixilon.pixlyzer.util.Util
|
|
||||||
import de.bixilon.pixlyzer.util.Util.compound
|
import de.bixilon.pixlyzer.util.Util.compound
|
||||||
import de.bixilon.pixlyzer.util.Util.listCast
|
|
||||||
import de.bixilon.pixlyzer.util.Util.mapCast
|
|
||||||
import de.bixilon.pixlyzer.util.Util.nullCast
|
import de.bixilon.pixlyzer.util.Util.nullCast
|
||||||
import de.bixilon.pixlyzer.util.Util.of
|
import de.bixilon.pixlyzer.util.Util.of
|
||||||
import de.bixilon.pixlyzer.util.Util.realName
|
import de.bixilon.pixlyzer.util.Util.realName
|
||||||
@ -100,69 +97,6 @@ object BlockGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val render = Util.readJsonMinecraftResource("assets/${resourceLocation.namespace}/blockstates/${resourceLocation.path}.json")
|
|
||||||
|
|
||||||
val multipartVariants: MutableMap<MutableMap<String, MutableSet<String>>, MutableList<Any>> = mutableMapOf()
|
|
||||||
|
|
||||||
|
|
||||||
render["multipart"]?.listCast<Any>()?.let {
|
|
||||||
for (condition in it) {
|
|
||||||
check(condition is Map<*, *>)
|
|
||||||
val properties: MutableSet<MutableMap<String, MutableSet<String>>> = mutableSetOf()
|
|
||||||
|
|
||||||
fun addPropertyMap(json: Any) {
|
|
||||||
val singlePropertyMap: MutableMap<String, MutableSet<String>> = mutableMapOf()
|
|
||||||
for ((property, propertyValue) in json.mapCast()!!) {
|
|
||||||
check(property is String)
|
|
||||||
val valueSet: MutableSet<String> = mutableSetOf()
|
|
||||||
val propertyValues = propertyValue.toString().split("|")
|
|
||||||
for (value in propertyValues) {
|
|
||||||
valueSet.add(value)
|
|
||||||
}
|
|
||||||
singlePropertyMap[property.lowercase(Locale.getDefault())] = valueSet
|
|
||||||
}
|
|
||||||
properties.add(singlePropertyMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
condition["when"]?.mapCast()?.let letWhen@{
|
|
||||||
it["OR"]?.listCast<Any>()?.let {
|
|
||||||
for (or in it) {
|
|
||||||
addPropertyMap(or)
|
|
||||||
}
|
|
||||||
return@letWhen
|
|
||||||
}
|
|
||||||
addPropertyMap(it)
|
|
||||||
}
|
|
||||||
if (properties.isEmpty()) {
|
|
||||||
properties.add(mutableMapOf())
|
|
||||||
}
|
|
||||||
addBlockModel(condition["apply"]!!)
|
|
||||||
for (propertyMap in properties) {
|
|
||||||
multipartVariants.getOrPut(propertyMap) { mutableListOf() }.add(condition["apply"]!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val renderVariants: MutableMap<MutableMap<String, String>, Any> = mutableMapOf()
|
|
||||||
render["variants"]?.mapCast()?.let {
|
|
||||||
for ((property, variant) in it) {
|
|
||||||
check(property is String)
|
|
||||||
|
|
||||||
addBlockModel(variant)
|
|
||||||
if (property.isBlank()) {
|
|
||||||
renderVariants[mutableMapOf()] = variant
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
val propertiesOut: MutableMap<String, String> = mutableMapOf()
|
|
||||||
for (split in property.split(",")) {
|
|
||||||
val splitProperty = split.split("=")
|
|
||||||
propertiesOut[splitProperty[0].lowercase(Locale.getDefault())] = splitProperty[1].lowercase(Locale.getDefault())
|
|
||||||
}
|
|
||||||
renderVariants[propertiesOut] = variant
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val hasColorProperties = (TINT_PROPERTIES_METHOD?.invoke(DEFAULT_BLOCK_COLORS, block) as Set<*>?)?.size?.let { it > 0 } ?: let {
|
val hasColorProperties = (TINT_PROPERTIES_METHOD?.invoke(DEFAULT_BLOCK_COLORS, block) as Set<*>?)?.size?.let { it > 0 } ?: let {
|
||||||
val blockColorProviderList = BLOCK_COLORS_PROVIDERS_ID_LIST!!.get(DEFAULT_BLOCK_COLORS)
|
val blockColorProviderList = BLOCK_COLORS_PROVIDERS_ID_LIST!!.get(DEFAULT_BLOCK_COLORS)
|
||||||
ID_LIST_GET_METHOD.invoke(blockColorProviderList, Registry.BLOCK.getRawId(block)) != null
|
ID_LIST_GET_METHOD.invoke(blockColorProviderList, Registry.BLOCK.getRawId(block)) != null
|
||||||
@ -260,55 +194,6 @@ object BlockGenerator : Generator(
|
|||||||
stateData["properties"] = propertyData
|
stateData["properties"] = propertyData
|
||||||
}
|
}
|
||||||
|
|
||||||
for ((propertyMap, variant) in renderVariants) {
|
|
||||||
var valid = true
|
|
||||||
for ((propertyName, propertyValue) in propertyMap) {
|
|
||||||
if (propertyData[propertyName]?.toString() != propertyValue) {
|
|
||||||
valid = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
stateData["render"] = variant
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val multipart = mutableListOf<Any>()
|
|
||||||
for ((properties, elementList) in multipartVariants) {
|
|
||||||
var valid = true
|
|
||||||
for ((propertyName, values) in properties) {
|
|
||||||
if (propertyData[propertyName] == null) {
|
|
||||||
valid = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if (!values.contains(propertyData[propertyName]?.toString())) {
|
|
||||||
valid = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
for (element in elementList) {
|
|
||||||
if (element is List<*>) {
|
|
||||||
for (apply in element) {
|
|
||||||
if (!multipart.contains(apply)) {
|
|
||||||
multipart.add(apply!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (element is Map<*, *>) {
|
|
||||||
if (!multipart.contains(element)) {
|
|
||||||
multipart.add(element)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multipart.size > 0 && !stateData.contains("render")) {
|
|
||||||
val multipartWrapper = mutableListOf<Any>()
|
|
||||||
multipartWrapper.add(multipart)
|
|
||||||
stateData["render"] = multipartWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
state.initShapeCache()
|
state.initShapeCache()
|
||||||
|
|
||||||
val positionOffset = BLOCK_STATE_GET_OFFSET.invoke(state, EntitySpawner.CLIENT_LEVEL, EMPTY_BLOCK_POSITION) as Vec3d
|
val positionOffset = BLOCK_STATE_GET_OFFSET.invoke(state, EntitySpawner.CLIENT_LEVEL, EMPTY_BLOCK_POSITION) as Vec3d
|
||||||
@ -570,21 +455,5 @@ object BlockGenerator : Generator(
|
|||||||
|
|
||||||
output[name] = input
|
output[name] = input
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addBlockModel(json: Any) {
|
|
||||||
when (json) {
|
|
||||||
is Map<*, *> -> {
|
|
||||||
ModelsGenerator.MODELS_TO_GENERATE.add(json["model"]!!.toString())
|
|
||||||
}
|
|
||||||
is List<*> -> {
|
|
||||||
for (element in json) {
|
|
||||||
ModelsGenerator.MODELS_TO_GENERATE.add(element!!.mapCast()!!["model"]!!.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
error("Invalid variant json")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package de.bixilon.pixlyzer.generator.generators
|
|
||||||
|
|
||||||
import de.bixilon.pixlyzer.generator.Generator
|
|
||||||
import de.bixilon.pixlyzer.util.Util
|
|
||||||
import de.bixilon.pixlyzer.util.Util.listCast
|
|
||||||
import de.bixilon.pixlyzer.util.Util.mapCast
|
|
||||||
import net.minecraft.util.Identifier
|
|
||||||
import net.minecraft.util.registry.Registry
|
|
||||||
|
|
||||||
object ModelsGenerator : Generator(
|
|
||||||
"models"
|
|
||||||
) {
|
|
||||||
val MODELS_TO_GENERATE: MutableList<String> = mutableListOf()
|
|
||||||
override fun generate() {
|
|
||||||
for (model in MODELS_TO_GENERATE) {
|
|
||||||
val resourceLocation = Identifier(model)
|
|
||||||
loadModel(resourceLocation)
|
|
||||||
}
|
|
||||||
for (item in Registry.ITEM) {
|
|
||||||
val itemIdentifier = Registry.ITEM.getId(item)
|
|
||||||
loadModel(Identifier(itemIdentifier.namespace, "item/" + itemIdentifier.path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadModel(resourceLocation: Identifier) {
|
|
||||||
if (data.containsKey(resourceLocation.toString())) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data[resourceLocation.toString()] = Util.readJsonMinecraftResource("assets/${resourceLocation.namespace}/models/${resourceLocation.path}.json")
|
|
||||||
|
|
||||||
val modelJson = Util.readJsonMinecraftResource("assets/${resourceLocation.namespace}/models/${resourceLocation.path}.json")
|
|
||||||
modelJson["parent"]?.let {
|
|
||||||
if (!it.toString().startsWith("builtin/")) {
|
|
||||||
loadModel(Identifier(it as String))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
modelJson["overrides"]?.listCast<Any>()?.let {
|
|
||||||
for (override in it) {
|
|
||||||
override.mapCast()!!["model"]?.let {
|
|
||||||
loadModel(Identifier(it as String))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user