diff --git a/gradle.properties b/gradle.properties index 74c3e79..dd6fa27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ litematica_fileid=4946471 litematica_projectid=308892 # Where Is It (https://modrinth.com/mod/where-is-it/versions) -where_is_it_version=2.4.3+1.20.6 +where_is_it_version=2.6.4+1.21.2 # YetAnotherConfigLib (https://github.com/JackFred2/WhereIsIt/blob/1.20.6/gradle.properties) yacl_version=3.3.2+1.20.4+update.1.20.5-SNAPSHOT+update.1.20.5-SNAPSHOT diff --git a/src/main/java/nekiplay/meteorplus/features/modules/integrations/WhereIsIt.java b/src/main/java/nekiplay/meteorplus/features/modules/integrations/WhereIsIt.java index 632d0b5..257a39c 100644 --- a/src/main/java/nekiplay/meteorplus/features/modules/integrations/WhereIsIt.java +++ b/src/main/java/nekiplay/meteorplus/features/modules/integrations/WhereIsIt.java @@ -24,14 +24,8 @@ public WhereIsIt() { .build() ); - public final Setting visible_text_color = defaultGroup.add(new ColorSetting.Builder() - .name("Visible-text-color") - .visible(() -> !suport_color_symbols.get()) - .build() - ); - - public final Setting notvisible_text_color = defaultGroup.add(new ColorSetting.Builder() - .name("not-visible-text-color") + public final Setting text_color = defaultGroup.add(new ColorSetting.Builder() + .name("text-color") .visible(() -> !suport_color_symbols.get()) .build() ); @@ -45,13 +39,4 @@ public WhereIsIt() { .sliderRange(-15, 15) .build() ); - - public final Setting text_scale = defaultGroup.add(new DoubleSetting.Builder() - .name("text-scale") - .defaultValue(1) - .max(15) - .min(0) - .sliderRange(0, 15) - .build() - ); } diff --git a/src/main/java/nekiplay/meteorplus/mixin/whereisit/RenderingMixin.java b/src/main/java/nekiplay/meteorplus/mixin/whereisit/RenderingMixin.java index 38bf349..00fc9d1 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/whereisit/RenderingMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/whereisit/RenderingMixin.java @@ -1,96 +1,68 @@ package nekiplay.meteorplus.mixin.whereisit; -import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.systems.modules.Modules; import nekiplay.meteorplus.features.modules.integrations.WhereIsIt; import nekiplay.meteorplus.utils.ColorRemover; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3d; -import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import red.jackf.whereisit.client.render.Rendering; -import red.jackf.whereisit.config.WhereIsItConfig; + +import static meteordevelopment.meteorclient.MeteorClient.mc; @Mixin(Rendering.class) public class RenderingMixin { @Unique private static WhereIsIt whereIsIt; - @Inject(method = "renderLabel", at = @At("HEAD"), cancellable = true) - private static void renderLabel(Vec3d pos, Text name, MatrixStack pose, Camera camera, VertexConsumerProvider consumers, CallbackInfo ci) { + @ModifyArgs(method = "renderLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I")) + private static void changeColor(Args args) { if (whereIsIt == null) { whereIsIt = Modules.get().get(WhereIsIt.class); } - if (whereIsIt != null && whereIsIt.isActive()) { - pose.push(); - - - pos = pos.subtract(camera.getPos()); - - - pose.translate(pos.x, pos.y + whereIsIt.y_offset.get(), pos.z); - pose.multiply(camera.getRotation()); - var factor = 0.025f * whereIsIt.text_scale.get().floatValue(); - pose.scale(-factor, -factor, factor); - var matrix4f = pose.peek().getPositionMatrix(); - String text2 = name.getString(); + if (whereIsIt != null && whereIsIt.isActive()) { + Text text1 = args.get(0); + String text2 = text1.getString(); if (whereIsIt.suport_color_symbols.get()) { - text2 = ColorRemover.GetVerbatimAll(text2); - } + String text3 = ColorRemover.GetVerbatim(text2); + args.set(0, Text.of(text3)); - var width = MinecraftClient.getInstance().textRenderer.getWidth(text2); - float x = (float) -width / 2; + int width = mc.textRenderer.getWidth(text3); + float x = (float)(-width) / 2.0F; - if (whereIsIt.background.get()) { - var bgBuffer = consumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough()); - var bgColour = ((int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255F)) << 24; - bgBuffer.vertex(matrix4f, x - 1, -1f, 0).color(bgColour).light(LightmapTextureManager.MAX_LIGHT_COORDINATE); - bgBuffer.vertex(matrix4f, x - 1, 10f, 0).color(bgColour).light(LightmapTextureManager.MAX_LIGHT_COORDINATE); - bgBuffer.vertex(matrix4f, x + width, 10f, 0).color(bgColour).light(LightmapTextureManager.MAX_LIGHT_COORDINATE); - bgBuffer.vertex(matrix4f, x + width, -1f, 0).color(bgColour).light(LightmapTextureManager.MAX_LIGHT_COORDINATE); + args.set(1, x); + args.set(3, getColor(text2)); } + else { + args.set(3, whereIsIt.text_color.get().getPacked()); + } + } + } - RenderSystem.disableDepthTest(); - RenderSystem.depthMask(false); - RenderSystem.depthFunc(GL11.GL_ALWAYS); - RenderSystem.enableBlend(); - RenderSystem.depthMask(true); - - String text = name.getString(); - if (!whereIsIt.suport_color_symbols.get()) { - MinecraftClient.getInstance().textRenderer.draw(text, x, 0, whereIsIt.notvisible_text_color.get().getPacked(), false, - matrix4f, consumers, TextRenderer.TextLayerType.SEE_THROUGH, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); - MinecraftClient.getInstance().textRenderer.draw(text, x, 0, whereIsIt.visible_text_color.get().getPacked(), false, - matrix4f, consumers, TextRenderer.TextLayerType.NORMAL, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); - } else { - int color = getColor(text); - - text = ColorRemover.GetVerbatimAll(text); + @ModifyArgs(method = "renderLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;translate(DDD)V")) + private static void translatePosition(Args args) { + if (whereIsIt == null) { + whereIsIt = Modules.get().get(WhereIsIt.class); + } - MinecraftClient.getInstance().textRenderer.draw(text, x, 0, color, false, - matrix4f, consumers, TextRenderer.TextLayerType.SEE_THROUGH, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); - MinecraftClient.getInstance().textRenderer.draw(text, x, 0, color, false, - matrix4f, consumers, TextRenderer.TextLayerType.NORMAL, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); + if (whereIsIt != null && whereIsIt.isActive()) { - } - RenderSystem.depthFunc(GL11.GL_LEQUAL); - RenderSystem.enableDepthTest(); - RenderSystem.enableBlend(); + args.set(1, (double)args.get(1) + whereIsIt.y_offset.get()); + } + } - pose.pop(); + @ModifyArgs(method = "renderLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexConsumer;vertex(Lorg/joml/Matrix4f;FFF)Lnet/minecraft/client/render/VertexConsumer;")) + private static void backgroundModifer(Args args) { + if (whereIsIt == null) { + whereIsIt = Modules.get().get(WhereIsIt.class); + } - ci.cancel(); + if (whereIsIt != null && whereIsIt.isActive() && !whereIsIt.background.get()) { + args.set(1, 0f); + args.set(2, 0f); } } diff --git a/src/main/java/nekiplay/meteorplus/utils/ColorRemover.java b/src/main/java/nekiplay/meteorplus/utils/ColorRemover.java index 1360c3c..65f0219 100644 --- a/src/main/java/nekiplay/meteorplus/utils/ColorRemover.java +++ b/src/main/java/nekiplay/meteorplus/utils/ColorRemover.java @@ -7,7 +7,7 @@ public static String GetVerbatim(String text) var data = new char[text.length()]; for ( int i = 0; i < text.length(); i++ ) - if ( text.charAt(i) != '§' ) + if ( text.charAt(i) != '§' && text.charAt(i) != '&') data[idx++] = text.charAt(i); else i++;