Skip to content

Commit

Permalink
fix: vanilla textures not tied to a model being obfuscated
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Aug 9, 2024
1 parent 3ae832d commit 7e99a4f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/com/mineinabyss/packy/PackObfuscator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class PackObfuscator(private val resourcePack: ResourcePack) {

private fun Model.obfuscateModelTextures(): Model {
obfuscatedModels.findObf(this.key())?.let { return it }
if (ResourcePacks.defaultVanillaResourcePack?.model(key()) != null) return this

val layers = textures().layers().filter { it.key() != null }.map { modelTexture ->
obfuscateModelTexture(modelTexture)?.key()?.let(ModelTexture::ofKey) ?: modelTexture
Expand Down Expand Up @@ -207,12 +208,12 @@ class PackObfuscator(private val resourcePack: ResourcePack) {

private fun obfuscateModelTexture(modelTexture: ModelTexture): Texture? {
val keyPng = modelTexture.key()?.removeSuffix(".png") ?: return null
return obfuscatedTextures.findObf(keyPng) ?: resourcePack.texture(keyPng)?.obfuscate()
return obfuscatedTextures.findObf(keyPng) ?: ResourcePacks.defaultVanillaResourcePack?.texture(keyPng) ?: resourcePack.texture(keyPng)?.obfuscate()
}

private fun obfuscateFontTexture(provider: BitMapFontProvider): Texture? {
val keyPng = provider.file().appendSuffix(".png")
return obfuscatedTextures.findObf(keyPng) ?: resourcePack.texture(keyPng)?.obfuscate()
return obfuscatedTextures.findObf(keyPng) ?: ResourcePacks.defaultVanillaResourcePack?.texture(keyPng) ?: resourcePack.texture(keyPng)?.obfuscate()
}

private fun Key.obfuscateKey() = when (packy.config.obfuscation) {
Expand Down

0 comments on commit 7e99a4f

Please sign in to comment.