Skip to content

Commit 5bf744b

Browse files
committed
Finished Merge of 1.21.10 Updates
1 parent b08a97f commit 5bf744b

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.mixin;
9+
10+
import java.util.List;
11+
12+
import org.jetbrains.annotations.Nullable;
13+
import org.spongepowered.asm.mixin.Final;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Pseudo;
16+
import org.spongepowered.asm.mixin.Shadow;
17+
import org.spongepowered.asm.mixin.injection.At;
18+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
19+
20+
import com.llamalad7.mixinextras.injector.ModifyReceiver;
21+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23+
24+
import net.minecraft.client.util.math.MatrixStack;
25+
import net.minecraft.text.Text;
26+
import net.minecraft.util.math.Vec3d;
27+
import net.wurstclient.WurstClient;
28+
import net.wurstclient.hacks.NameTagsHack;
29+
30+
@Pseudo
31+
@Mixin(
32+
targets = "net.minecraft.client.render.command.LabelCommandRenderer$Commands",
33+
remap = false)
34+
public class LabelCommandRendererMixin
35+
{
36+
@Shadow(remap = false)
37+
@Final
38+
List<?> seethroughLabels;
39+
40+
@Shadow(remap = false)
41+
@Final
42+
List<?> normalLabels;
43+
44+
@WrapOperation(
45+
at = @At(value = "INVOKE",
46+
target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V"),
47+
method = "add(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Vec3d;ILnet/minecraft/text/Text;ZIDLnet/minecraft/client/render/state/CameraRenderState;)V")
48+
private void wrapLabelScale(MatrixStack matrices, float x, float y, float z,
49+
Operation<Void> original, MatrixStack matrices2, @Nullable Vec3d vec3d,
50+
int i, Text text, boolean bl, int j, double d, Object state)
51+
{
52+
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;
53+
if(!nameTags.isEnabled())
54+
{
55+
original.call(matrices, x, y, z);
56+
return;
57+
}
58+
59+
float scale = 0.025F * nameTags.getScale();
60+
double distance = Math.sqrt(d);
61+
if(distance > 10)
62+
scale *= distance / 10;
63+
64+
original.call(matrices, scale, -scale, scale);
65+
}
66+
67+
/**
68+
* Modifies the notSneaking parameter to force labels to show when NameTags
69+
* is enabled.
70+
*/
71+
@ModifyVariable(at = @At("HEAD"),
72+
method = "add(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Vec3d;ILnet/minecraft/text/Text;ZIDLnet/minecraft/client/render/state/CameraRenderState;)V",
73+
argsOnly = true)
74+
private boolean forceNotSneaking(boolean notSneaking)
75+
{
76+
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;
77+
return nameTags.isEnabled() || notSneaking;
78+
}
79+
80+
/**
81+
* Swaps the target list for the first add() call
82+
* (normalLabels -> seethroughLabels) if NameTags is enabled in
83+
* see-through mode.
84+
*/
85+
@ModifyReceiver(
86+
at = @At(value = "INVOKE",
87+
target = "Ljava/util/List;add(Ljava/lang/Object;)Z",
88+
ordinal = 0),
89+
method = "add(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Vec3d;ILnet/minecraft/text/Text;ZIDLnet/minecraft/client/render/state/CameraRenderState;)V")
90+
private List<?> swapFirstList(List<?> originalList, Object labelCommand)
91+
{
92+
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;
93+
94+
if(nameTags.isEnabled() && nameTags.isSeeThrough())
95+
if(originalList == normalLabels)
96+
return seethroughLabels;
97+
98+
return originalList;
99+
}
100+
101+
/**
102+
* Swaps the target list for the second add() call
103+
* (seethroughLabels -> normalLabels) if NameTags is enabled in
104+
* see-through mode.
105+
*/
106+
@ModifyReceiver(
107+
at = @At(value = "INVOKE",
108+
target = "Ljava/util/List;add(Ljava/lang/Object;)Z",
109+
ordinal = 1),
110+
method = "add(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Vec3d;ILnet/minecraft/text/Text;ZIDLnet/minecraft/client/render/state/CameraRenderState;)V")
111+
private List<?> swapSecondList(List<?> originalList, Object labelCommand)
112+
{
113+
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;
114+
115+
if(nameTags.isEnabled() && nameTags.isSeeThrough())
116+
if(originalList == seethroughLabels)
117+
return normalLabels;
118+
119+
return originalList;
120+
}
121+
}

0 commit comments

Comments
 (0)