Skip to content

Commit

Permalink
Chest Tracker integration return
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Dec 24, 2024
1 parent 96e1955 commit 64c4f18
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 84 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ public WhereIsIt() {
.build()
);

public final Setting<SettingColor> visible_text_color = defaultGroup.add(new ColorSetting.Builder()
.name("Visible-text-color")
.visible(() -> !suport_color_symbols.get())
.build()
);

public final Setting<SettingColor> notvisible_text_color = defaultGroup.add(new ColorSetting.Builder()
.name("not-visible-text-color")
public final Setting<SettingColor> text_color = defaultGroup.add(new ColorSetting.Builder()
.name("text-color")
.visible(() -> !suport_color_symbols.get())
.build()
);
Expand All @@ -45,13 +39,4 @@ public WhereIsIt() {
.sliderRange(-15, 15)
.build()
);

public final Setting<Double> text_scale = defaultGroup.add(new DoubleSetting.Builder()
.name("text-scale")
.defaultValue(1)
.max(15)
.min(0)
.sliderRange(0, 15)
.build()
);
}
102 changes: 37 additions & 65 deletions src/main/java/nekiplay/meteorplus/mixin/whereisit/RenderingMixin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nekiplay/meteorplus/utils/ColorRemover.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 64c4f18

Please sign in to comment.