Skip to content

Commit 32cc2e5

Browse files
committed
vanilla mode size fixes
1 parent 2838e51 commit 32cc2e5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/main/kotlin/org/polyfrost/crosshair/config/ModConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ object ModConfig : Config(Mod(PolyCrosshair.NAME, ModType.HUD, "/${PolyCrosshair
5757
addDependency(options[3], options[0])
5858
addDependency(options[4], options[1])
5959
addDependency(options[5], options[2])
60+
addDependency("centered", "mode")
6061
options = listOf("mirror", "canvaSize")
6162
options.forEach { hideIf(it) { !mode } }
6263
addListener("canvaSize") {

src/main/kotlin/org/polyfrost/crosshair/render/CrosshairRenderer.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ object CrosshairRenderer {
5252

5353
fun updateVanilla() {
5454
val icon = TextureUtil.readBufferedImage(mc.resourceManager.getResource(Gui.icons).inputStream)
55-
vanilla = DynamicTexture(15, 15)
56-
for (y in 0 until 15) {
57-
for (x in 0 until 15) {
58-
if (icon.getRGB(x, y) == -1) {
59-
vanilla.textureData[x + y * 15] = -1
55+
val size = icon.width * 16 / 256
56+
vanilla = DynamicTexture(size, size)
57+
for (y in 0 until size) {
58+
for (x in 0 until size) {
59+
icon.getRGB(x, y).let {
60+
if (it != 0) vanilla.textureData[x + y * size] = it
6061
}
6162
}
6263
}
@@ -99,10 +100,10 @@ object CrosshairRenderer {
99100
GL.translate(crosshair.offsetX.toFloat(), crosshair.offsetY.toFloat(), 0f)
100101
GL.translate((UResolution.windowWidth / 2).toFloat(), (UResolution.windowHeight / 2).toFloat(), 0f)
101102
GL.rotate(crosshair.rotation.toFloat(), 0f, 0f, 1f)
102-
val scale = ModConfig.newCurrentCrosshair.scale / 100f
103-
val textureSize = if (ModConfig.mode) drawingImage.width else 15
103+
val scale = crosshair.scale / 100f
104+
val textureSize = if (ModConfig.mode) drawingImage.width else 16
104105
val size = ceil(textureSize * mcScale * scale).toInt()
105-
val translation = if (crosshair.centered) (-size / 2).toFloat() else (-(size - mcScale) / 2).toInt().toFloat()
106+
val translation = if (ModConfig.mode) if (crosshair.centered) (-size / 2).toFloat() else (-(size - mcScale) / 2).toInt().toFloat() else ceil(-7 * mcScale * scale)
106107
GL.translate(translation, translation, 0f)
107108
Gui.drawScaledCustomSizeModalRect(0, 0, 0f, 0f, textureSize, textureSize, size, size, textureSize.toFloat(), textureSize.toFloat())
108109
val c = getColor()

0 commit comments

Comments
 (0)