-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
That fixes weird looking grass (and a couple of other textures) in resource packs and 1.20.2
- Loading branch information
Showing
9 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/textures/TextureReadingTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Minosoft | ||
* Copyright (C) 2020-2023 Moritz Zwerger | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* This software is not affiliated with Mojang AB, the original developer of Minecraft. | ||
*/ | ||
|
||
package de.bixilon.minosoft.gui.rendering.textures | ||
|
||
import de.bixilon.kotlinglm.vec2.Vec2i | ||
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData | ||
import org.testng.Assert.assertEquals | ||
import org.testng.annotations.Test | ||
import java.io.ByteArrayInputStream | ||
import java.io.InputStream | ||
|
||
@Test(groups = ["texture", "assets"]) | ||
class TextureReadingTest { | ||
private val GRAY_GRAY = TextureReadingTest::class.java.getResourceAsStream("/texture_reading/gray_gray.png")!!.readAllBytes() | ||
private val GRAY_RGB = TextureReadingTest::class.java.getResourceAsStream("/texture_reading/gray_rgb.png")!!.readAllBytes() | ||
|
||
private val READ_1 = TextureUtil::class.java.getDeclaredMethod("readTexture1", InputStream::class.java).apply { isAccessible = true } | ||
private val READ_2 = TextureUtil::class.java.getDeclaredMethod("readTexture2", InputStream::class.java).apply { isAccessible = true } | ||
|
||
private fun TextureData.assertGray() { | ||
assertEquals(size, Vec2i(16, 16)) | ||
|
||
assertEquals(buffer.get(0), 0x94.toByte()) | ||
assertEquals(buffer.get(1), 0x94.toByte()) | ||
assertEquals(buffer.get(2), 0x94.toByte()) | ||
assertEquals(buffer.get(3), 0xFF.toByte()) | ||
assertEquals(buffer.get(4), 0xC3.toByte()) | ||
assertEquals(buffer.get(128), 0xA3.toByte()) | ||
assertEquals(buffer.get(256), 0xA2.toByte()) | ||
} | ||
|
||
fun `read rgb 1`() { | ||
val texture = READ_1.invoke(TextureUtil, ByteArrayInputStream(GRAY_RGB)) as TextureData | ||
texture.assertGray() | ||
} | ||
|
||
fun `read rgb 2`() { | ||
val texture = READ_2.invoke(TextureUtil, ByteArrayInputStream(GRAY_RGB)) as TextureData | ||
texture.assertGray() | ||
} | ||
|
||
@Test(enabled = false) | ||
fun `read gray 1`() { | ||
val texture = READ_1.invoke(TextureUtil, ByteArrayInputStream(GRAY_GRAY)) as TextureData | ||
texture.assertGray() | ||
} | ||
|
||
fun `read gray 2`() { | ||
val texture = READ_2.invoke(TextureUtil, ByteArrayInputStream(GRAY_GRAY)) as TextureData | ||
texture.assertGray() | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters