fluid models: fix texture path fixing

This commit is contained in:
Moritz Zwerger 2023-10-05 21:02:52 +02:00
parent 704eca3c00
commit 767d69e41b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 15 additions and 13 deletions

View File

@ -47,7 +47,9 @@ open class PixLyzerItem(resourceLocation: ResourceLocation, registries: Registri
val className = data["class"]?.toString() val className = data["class"]?.toString()
var factory = PixLyzerItemFactories[className] var factory = PixLyzerItemFactories[className]
if (factory == null) { if (factory == null) {
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Item for class $className not found, defaulting..." } if (className != null) {
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Item for class $className not found, defaulting..." }
}
// ToDo: This item class got renamed or is not yet implemented // ToDo: This item class got renamed or is not yet implemented
factory = if (data["food_properties"] != null) { factory = if (data["food_properties"] != null) {
PixLyzerFoodItem // ToDo: Remove this edge case PixLyzerFoodItem // ToDo: Remove this edge case

View File

@ -27,12 +27,12 @@ class LavaFluidModel : FluidModel {
override val transparency = TextureTransparencies.OPAQUE// TODO: from texture override val transparency = TextureTransparencies.OPAQUE// TODO: from texture
override fun load(context: RenderContext) { override fun load(context: RenderContext) {
still = context.textures.staticTextures.createTexture(context.models.block.fixPath(STILL).texture()) still = context.textures.staticTextures.createTexture(context.models.block.fixTexturePath(STILL).texture())
flowing = context.textures.staticTextures.createTexture(context.models.block.fixPath(FLOWING).texture()) flowing = context.textures.staticTextures.createTexture(context.models.block.fixTexturePath(FLOWING).texture())
} }
companion object { companion object {
private val STILL = minecraft("block/lava_still").texture() private val STILL = minecraft("block/lava_still")
private val FLOWING = minecraft("block/lava_flow").texture() private val FLOWING = minecraft("block/lava_flow")
} }
} }

View File

@ -31,8 +31,8 @@ class WaterFluidModel : FluidModel {
override val transparency = TextureTransparencies.TRANSLUCENT// TODO: from texture override val transparency = TextureTransparencies.TRANSLUCENT// TODO: from texture
override fun load(context: RenderContext) { override fun load(context: RenderContext) {
still = context.textures.staticTextures.createTexture(context.models.block.fixPath(STILL).texture()) still = context.textures.staticTextures.createTexture(context.models.block.fixTexturePath(STILL).texture())
flowing = context.textures.staticTextures.createTexture(context.models.block.fixPath(FLOWING).texture()) flowing = context.textures.staticTextures.createTexture(context.models.block.fixTexturePath(FLOWING).texture())
} }
companion object { companion object {

View File

@ -74,12 +74,12 @@ class BlockLoader(private val loader: ModelLoader) {
this.cache.clear() this.cache.clear()
} }
fun fixPath(name: ResourceLocation): ResourceLocation { fun fixTexturePath(name: ResourceLocation): ResourceLocation {
return ResourceLocation(name.namespace, name.path.fixPrefix(loader.packFormat, 4, "block/", "blocks/")) return ResourceLocation(name.namespace, name.path.fixPrefix(loader.packFormat, 4, "blocks/", "block/"))
} }
private fun ResourceLocation.blockModel(): ResourceLocation { private fun ResourceLocation.blockModel(): ResourceLocation {
return fixPath(this).model() return this.prefix("block/").model()
} }

View File

@ -73,11 +73,11 @@ class ItemLoader(private val loader: ModelLoader) {
this.cache.clear() this.cache.clear()
} }
fun fixPath(name: ResourceLocation): ResourceLocation { fun fixTexturePath(name: ResourceLocation): ResourceLocation {
return ResourceLocation(name.namespace, name.path.fixPrefix(loader.packFormat, 4, "item/", "items/")) return ResourceLocation(name.namespace, name.path.fixPrefix(loader.packFormat, 4, "items/", "item/"))
} }
private fun ResourceLocation.itemModel(): ResourceLocation { private fun ResourceLocation.itemModel(): ResourceLocation {
return fixPath(this).model() return this.prefix("item/").model()
} }
} }