From f9807c715dcd8c4372e4a5d50ee2039b0c0862ed Mon Sep 17 00:00:00 2001 From: ev chang Date: Sun, 23 Jun 2024 23:48:38 +0700 Subject: [PATCH] Fix crosshair being off-center and scaled weirdly --- .../org/polyfrost/crosshair/config/Drawer.kt | 2 +- .../crosshair/render/CrosshairRenderer.kt | 60 +++++++++++++------ src/main/resources/polycrosshair.svg | 12 ++-- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt b/src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt index e61c70c..7cc7e5c 100644 --- a/src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt +++ b/src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt @@ -292,7 +292,7 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) { override fun getHeight() = 256 override fun keyTyped(key: Char, keyCode: Int) { - + if (mc.currentScreen !is OneConfigGui) return if (keyCode == UKeyboard.KEY_W) moveQueue.add(MoveType.UP) if (keyCode == UKeyboard.KEY_S) { if (UKeyboard.isCtrlKeyDown()) { diff --git a/src/main/kotlin/org/polyfrost/crosshair/render/CrosshairRenderer.kt b/src/main/kotlin/org/polyfrost/crosshair/render/CrosshairRenderer.kt index 6fac879..3416907 100644 --- a/src/main/kotlin/org/polyfrost/crosshair/render/CrosshairRenderer.kt +++ b/src/main/kotlin/org/polyfrost/crosshair/render/CrosshairRenderer.kt @@ -6,17 +6,22 @@ import cc.polyfrost.oneconfig.images.OneImage import cc.polyfrost.oneconfig.libs.universal.UResolution import cc.polyfrost.oneconfig.utils.dsl.mc import net.minecraft.client.gui.Gui -import net.minecraft.client.renderer.* +import net.minecraft.client.renderer.EntityRenderer +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.texture.DynamicTexture import net.minecraft.entity.monster.IMob -import net.minecraft.entity.passive.* +import net.minecraft.entity.passive.EntityAmbientCreature +import net.minecraft.entity.passive.EntityAnimal +import net.minecraft.entity.passive.EntityVillager +import net.minecraft.entity.passive.EntityWaterMob import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 -import org.polyfrost.crosshair.config.* +import org.polyfrost.crosshair.config.ModConfig import org.polyfrost.crosshair.mixin.GuiIngameAccessor import java.awt.Color +import java.awt.image.BufferedImage object CrosshairRenderer { private var texture = DynamicTexture(15, 15) @@ -25,15 +30,19 @@ object CrosshairRenderer { private var whiteTextureLocation = mc.textureManager.getDynamicTextureLocation("polycrosshair", whiteTexture) fun updateTexture(image: OneImage) { - texture = DynamicTexture(image.image) + val paddedImage = if (ModConfig.canvaSize % 2 == 1) { + addPixel(image.image) + } else { + image.image + } + texture = DynamicTexture(paddedImage) textureLocation = mc.textureManager.getDynamicTextureLocation("polycrosshair", texture) - val size = ModConfig.canvaSize - whiteTexture = DynamicTexture(size, size) - for (posY in 0.. - - - - - - + + + + + +