Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 95e5f1c

Browse files
committed
fix name shadow rendering while sneaking
1 parent 805555d commit 95e5f1c

File tree

6 files changed

+28
-37
lines changed

6 files changed

+28
-37
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public abstract class EntityRendererMixin<T extends Entity> {
104104
}
105105
}
106106

107-
@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLnet/minecraft/util/math/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;ZII)I"), index = 4)
107+
@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLnet/minecraft/util/math/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;ZII)I", ordinal = 1), index = 4)
108108
public boolean axolotlclient$enableShadows(boolean shadow) {
109109
return AxolotlClient.CONFIG.useShadows.get();
110110
}

1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,9 @@ public abstract class EntityRendererMixin<T extends Entity> {
119119
}
120120
}
121121

122-
@ModifyArg(method = "renderLabelIfPresent", 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", ordinal = 0), index = 4)
123-
private boolean enableShadows$sneaking(boolean par5, @Local Matrix4f matrix4f, @Local boolean notSneaking) {
124-
matrix4f.scale(1, 1, -1);
125-
return !notSneaking && AxolotlClient.CONFIG.useShadows.get();
126-
}
127-
128122
@ModifyArg(method = "renderLabelIfPresent", 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", ordinal = 1), index = 4)
129123
private boolean enableShadows(boolean par5, @Local Matrix4f matrix4f) {
124+
matrix4f.scale(1, 1, -1);
130125
return AxolotlClient.CONFIG.useShadows.get();
131126
}
132127

1.21.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public abstract class EntityRendererMixin<T extends Entity, S extends EntityRend
9595
}
9696
}
9797

98-
@ModifyArg(method = "renderNameTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;drawInBatch(Lnet/minecraft/network/chat/Component;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;II)I"), index = 4)
98+
@ModifyArg(method = "renderNameTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;drawInBatch(Lnet/minecraft/network/chat/Component;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;II)I", ordinal = 1), index = 4)
9999
public boolean axolotlclient$enableShadows(boolean shadow) {
100100
return AxolotlClient.CONFIG.useShadows.get();
101101
}

1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package io.github.axolotlclient.mixin;
2424

25+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
26+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2527
import com.mojang.blaze3d.platform.GlStateManager;
2628
import com.mojang.blaze3d.vertex.BufferBuilder;
2729
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
@@ -69,10 +71,12 @@ public abstract class EntityRendererMixin<T extends Entity> {
6971
BadgeRenderer.renderNametagBadge(entity);
7072
}
7173

72-
@Redirect(method = "renderNameTag(Lnet/minecraft/entity/Entity;Ljava/lang/String;DDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/TextRenderer;draw(Ljava/lang/String;III)I"))
73-
public int axolotlclient$forceShadows(TextRenderer instance, String text, int x, int y, int color) {
74-
instance.draw(text, x, y, color, AxolotlClient.CONFIG.useShadows.get());
75-
return 0;
74+
@WrapOperation(method = "renderNameTag(Lnet/minecraft/entity/Entity;Ljava/lang/String;DDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/TextRenderer;draw(Ljava/lang/String;III)I", ordinal = 1))
75+
public int axolotlclient$forceShadows(TextRenderer instance, String string, int x, int y, int color, Operation<Integer> original, Entity entity) {
76+
if (AxolotlClient.CONFIG.useShadows.get() && !entity.isSneaking()) {
77+
return instance.draw(string, x, y, color, true);
78+
}
79+
return original.call(instance, string, x, y, color);
7680
}
7781

7882
@Inject(method = "renderNameTag(Lnet/minecraft/entity/Entity;Ljava/lang/String;DDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/TextRenderer;draw(Ljava/lang/String;III)I", ordinal = 1))

common/src/main/java/io/github/axolotlclient/api/API.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
import java.net.URI;
2727
import java.net.http.*;
2828
import java.util.*;
29-
import java.util.concurrent.CompletableFuture;
30-
import java.util.concurrent.ExecutionException;
31-
import java.util.concurrent.TimeUnit;
32-
import java.util.concurrent.TimeoutException;
29+
import java.util.concurrent.*;
3330
import java.util.stream.Collectors;
3431

3532
import io.github.axolotlclient.AxolotlClientCommon;
@@ -72,6 +69,8 @@ public class API {
7269
private AccountSettings settings;
7370
private HttpClient client;
7471
private CompletableFuture<?> restartingFuture;
72+
private Future<?> statusUpdateFuture;
73+
private final ScheduledExecutorService statusUpdateExecutor;
7574
private static final List<BiContainer<Runnable, ListenerType>> afterStartupListeners = new ArrayList<>();
7675

7776
public API(Logger logger, TranslationProvider translationProvider,
@@ -91,6 +90,7 @@ public API(Logger logger, TranslationProvider translationProvider,
9190
handlers.add(new StatusUpdateHandler());
9291
handlers.add(new ChannelInviteHandler());
9392
Instance = this;
93+
statusUpdateExecutor = Executors.newSingleThreadScheduledExecutor();
9494
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
9595
}
9696

@@ -295,6 +295,10 @@ public void shutdown() {
295295
restartingFuture.cancel(true);
296296
restartingFuture = null;
297297
}
298+
if (statusUpdateFuture != null) {
299+
statusUpdateFuture.cancel(true);
300+
statusUpdateFuture = null;
301+
}
298302
if (isAuthenticated()) {
299303
logger.debug("Shutting down API");
300304
if (isSocketConnected()) {
@@ -445,27 +449,15 @@ private void startupAPI() {
445449

446450
private void startStatusUpdateThread() {
447451
statusUpdateProvider.initialize();
448-
new Thread("Status Update Thread") {
449-
@Override
450-
public void run() {
451-
try {
452-
Thread.sleep(50);
453-
} catch (InterruptedException ignored) {
454-
}
455-
while (API.getInstance().isAuthenticated()) {
456-
Request request = statusUpdateProvider.getStatus();
457-
if (request != null) {
458-
post(request);
459-
}
460-
try {
461-
//noinspection BusyWait
462-
Thread.sleep(Constants.STATUS_UPDATE_DELAY * 1000);
463-
} catch (InterruptedException ignored) {
464-
465-
}
466-
}
452+
if (statusUpdateFuture != null) {
453+
statusUpdateFuture.cancel(true);
454+
}
455+
statusUpdateFuture = statusUpdateExecutor.scheduleAtFixedRate(() -> {
456+
Request request = statusUpdateProvider.getStatus();
457+
if (request != null) {
458+
post(request);
467459
}
468-
}.start();
460+
}, 50, Constants.STATUS_UPDATE_DELAY * 1000, TimeUnit.MILLISECONDS);
469461
}
470462

471463
public String sanitizeUUID(String uuid) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=3.1.1-rc.17
9+
version=3.1.1-rc.18
1010

1111
maven_group=io.github.axolotlclient
1212

0 commit comments

Comments
 (0)