diff --git a/build.gradle.kts b/build.gradle.kts index aac5e21..21e4740 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,6 +31,8 @@ toolkitLoomHelper { } } + useDevAuth("1.2.1") + // Turns off the server-side run configs, as we're building a client-sided mod. disableRunConfigs(GameSide.SERVER) diff --git a/src/main/java/org/polyfrost/polynametag/mixin/Mixin_Render_ReplaceRendering.java b/src/main/java/org/polyfrost/polynametag/mixin/Mixin_Render_ReplaceRendering.java index 8bbccd6..9b0e51f 100644 --- a/src/main/java/org/polyfrost/polynametag/mixin/Mixin_Render_ReplaceRendering.java +++ b/src/main/java/org/polyfrost/polynametag/mixin/Mixin_Render_ReplaceRendering.java @@ -13,11 +13,9 @@ import org.polyfrost.polynametag.NametagRenderer; import org.polyfrost.polynametag.PolyNametagConfig; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(Render.class) public class Mixin_Render_ReplaceRendering { @@ -28,7 +26,7 @@ public class Mixin_Render_ReplaceRendering { return original.call(instance, text, x, y, color); } - return NametagRenderer.drawStringWithoutZFighting(instance, text, x, y, color); + return NametagRenderer.drawNametagString(instance, text, x, y, color); } @Inject(method = "renderLivingLabel", at = @At("HEAD"), cancellable = true) @@ -38,6 +36,18 @@ public class Mixin_Render_ReplaceRendering { } } + @ModifyArgs(method = "renderLivingLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;scale(FFF)V")) + private void polyNametag$changeScale(Args args) { + if (!PolyNametagConfig.INSTANCE.getEnabled()) { + return; + } + + double scale = PolyNametagConfig.INSTANCE.getScale(); + args.set(0, ((double) args.get(0)) * scale); + args.set(1, ((double) args.get(1)) * scale); + args.set(2, ((double) args.get(2)) * scale); + } + @Inject(method = "renderLivingLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()V")) private void polynametag$replaceDefaultBackgroundRendering(T entity, String str, double x, double y, double z, int maxDistance, CallbackInfo ci) { if (!PolyNametagConfig.INSTANCE.getEnabled()) { diff --git a/src/main/java/org/polyfrost/polynametag/mixin/Mixin_RendererLivingEntity_ReplaceRendering.java b/src/main/java/org/polyfrost/polynametag/mixin/Mixin_RendererLivingEntity_ReplaceRendering.java index 899be39..365a2f3 100644 --- a/src/main/java/org/polyfrost/polynametag/mixin/Mixin_RendererLivingEntity_ReplaceRendering.java +++ b/src/main/java/org/polyfrost/polynametag/mixin/Mixin_RendererLivingEntity_ReplaceRendering.java @@ -13,11 +13,9 @@ import org.polyfrost.polynametag.NametagRenderer; import org.polyfrost.polynametag.PolyNametagConfig; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(RendererLivingEntity.class) public class Mixin_RendererLivingEntity_ReplaceRendering { @@ -28,7 +26,7 @@ public class Mixin_RendererLivingEntity_ReplaceRendering fontRenderer.invokeRenderString(text, x, y, color, false) 1 -> fontRenderer.invokeRenderString(text, x, y, color, true) else -> 0 @@ -39,8 +38,8 @@ object NametagRenderer { } @JvmStatic - fun drawStringWithoutZFighting(text: String, x: Float, y: Float, color: Int): Int { - return drawStringWithoutZFighting(mc.fontRendererObj, text, x, y, color) + fun drawNametagString(text: String, x: Float, y: Float, color: Int): Int { + return drawNametagString(mc.fontRendererObj, text, x, y, color) } @JvmStatic @@ -53,14 +52,14 @@ object NametagRenderer { UGraphics.disableTexture2D() GL11.glPushMatrix() val realX1 = x1 - if (canDrawEssentialIndicator(entity)) 10 else 0 - GL11.glTranslated((realX1 + x2) / 2f, 3.5, 0.01) + GL11.glTranslated((realX1 + x2) / 2f, 3.5, 0.0) GL11.glBegin(GL11.GL_TRIANGLE_FAN) with(PolyNametagConfig.backgroundColor) { GL11.glColor4f(r / 255f, g / 255f, b / 255f, a.coerceAtMost(63) / 255f) } - val halfWidth = (x2 - realX1) / 2f + PolyNametagConfig.paddingX - val radius = if (PolyNametagConfig.rounded) PolyNametagConfig.cornerRadius.coerceAtMost(4.5f + PolyNametagConfig.paddingY).coerceAtMost(halfWidth.toFloat()) else 0f + val halfWidth = (x2 - realX1) / 2f + PolyNametagConfig.paddingX.coerceIn(0f, 10f) + val radius = if (PolyNametagConfig.rounded) PolyNametagConfig.cornerRadius.coerceIn(0f, 10f).coerceAtMost(4.5f + PolyNametagConfig.paddingY.coerceIn(0f, 10f)).coerceAtMost(halfWidth.toFloat()) else 0f val width = halfWidth - radius val distanceFromPlayer = entity.getDistanceToEntity(mc.thePlayer) val quality = ((distanceFromPlayer * 4 + 10).coerceAtMost(350f) / 4f).toInt() @@ -68,7 +67,7 @@ object NametagRenderer { val (transX, transY) = translate[a] val (pointX, pointY) = points[a] val x = pointX * width - val y = pointY * (4.5 + PolyNametagConfig.paddingY - radius) + val y = pointY * (4.5 + PolyNametagConfig.paddingY.coerceIn(0f, 10f) - radius) if (PolyNametagConfig.rounded) { for (b in 0 until 90 / quality) { val angle = Math.toRadians((a * 90 + b * quality).toDouble()) diff --git a/src/main/kotlin/org/polyfrost/polynametag/PolyNametagConfig.kt b/src/main/kotlin/org/polyfrost/polynametag/PolyNametagConfig.kt index 7703fa5..c41052a 100644 --- a/src/main/kotlin/org/polyfrost/polynametag/PolyNametagConfig.kt +++ b/src/main/kotlin/org/polyfrost/polynametag/PolyNametagConfig.kt @@ -21,7 +21,7 @@ object PolyNametagConfig : Config("nametag.json", "/polynametag.svg", PolyNameta get() = field.coerceIn(-0.5f, 0.5f) @Slider(title = "Scale", min = 0f, max = 1f, description = "How much to scale the nametag") - var scale = 1f + var scale = 1f //todo get() = field.coerceIn(0f, 1f) @Switch(title = "Rounded Corners") @@ -29,15 +29,12 @@ object PolyNametagConfig : Config("nametag.json", "/polynametag.svg", PolyNameta @Slider(title = "Corner Radius", min = 0f, max = 10f) var cornerRadius = 0f - get() = field.coerceIn(0f, 10f) @Slider(title = "Padding X", min = 0f, max = 10f) var paddingX = 0f - get() = field.coerceIn(0f, 10f) @Slider(title = "Padding Y", min = 0f, max = 10f) var paddingY = 0f - get() = field.coerceIn(0f, 10f) @Dropdown(title = "Text Type", options = ["No Shadow", "Shadow", "Full Shadow"], description = "The type of shadow to render") var textType = 0 @@ -62,9 +59,6 @@ object PolyNametagConfig : Config("nametag.json", "/polynametag.svg", PolyNameta @Color(title = "Background color", description = "The color of the background") var backgroundColor = rgba(0, 0, 0, 0.247F) // 0,0,0,63 - @Switch(title = "Offset Essential Indicator", description = "Offset nametag to center if the player has essential indicator drawn") - var essentialOffset = true - /* @CustomOption @Transient @@ -92,9 +86,6 @@ object PolyNametagConfig : Config("nametag.json", "/polynametag.svg", PolyNameta addDependency("cornerRadius", "rounded") addDependency("showInInventory", "showOwnNametag") - // TODO - //hideIf("essentialOffset") { !PolyNametag.isEssential } - if (!hasMigratedPatcher) { try { Class.forName("club.sk1er.patcher.config.OldPatcherConfig")