Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameTags fixes #798

Merged
merged 8 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/java/net/wurstclient/hacks/NameTagsHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@ public final class NameTagsHack extends Hack
private final CheckboxSetting seeThrough = new CheckboxSetting(
"See-through mode",
"Renders nametags on the see-through text layer. This makes them"
+ " easier to read behind walls, but harder to read behind water"
+ " and other transparent things.",
+ " easier to read behind walls, but causes some graphical glitches"
+ " with water and other transparent things.",
false);

private final CheckboxSetting forceNametags = new CheckboxSetting(
"Force nametags",
"Forces nametags of all players to be visible, even your own.", false);

private final CheckboxSetting forceMobNametags =
new CheckboxSetting("Force mob nametags",
"Forces nametags of all mobs to be visible.", false);

public NameTagsHack()
{
super("NameTags");
setCategory(Category.RENDER);
addSetting(unlimitedRange);
addSetting(seeThrough);
addSetting(forceNametags);
addSetting(forceMobNametags);
}

public boolean isUnlimitedRange()
Expand All @@ -54,6 +59,11 @@ public boolean shouldForceNametags()
return isEnabled() && forceNametags.isChecked();
}

// See LivingEntityRendererMixin and
public boolean shouldForceMobNametags()
{
return isEnabled() && forceMobNametags.isChecked();
}

// See LivingEntityRendererMixin, MobEntityRendererMixin, and
// EntityRendererMixin.wurstRenderLabelIfPresent()
}
4 changes: 2 additions & 2 deletions src/main/java/net/wurstclient/mixin/EntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ protected void wurstRenderLabelIfPresent(T entity, Text text,

// draw background
tr.draw(text, labelX, labelY, 0x20FFFFFF, false, matrix,
vertexConsumers,
notSneaky ? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL,
vertexConsumers, notSneaky && !nameTags.isSeeThrough()
? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL,
bgColor, light);

// use the see-through layer for text if configured in NameTags
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/net/wurstclient/mixin/MobEntityRendererMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.mixin;

import org.objectweb.asm.Opcodes;
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.callback.CallbackInfoReturnable;

import net.minecraft.client.render.entity.MobEntityRenderer;
import net.wurstclient.WurstClient;

@Mixin(MobEntityRenderer.class)
public abstract class MobEntityRendererMixin
{
/**
* Makes name-tagged mobs always show their name tags.
*/
@Inject(at = @At(value = "FIELD",
target = "Lnet/minecraft/client/render/entity/EntityRenderDispatcher;targetedEntity:Lnet/minecraft/entity/Entity;",
opcode = Opcodes.GETFIELD,
ordinal = 0),
method = "hasLabel(Lnet/minecraft/entity/mob/MobEntity;)Z",
cancellable = true)
private void shouldForceLabel(CallbackInfoReturnable<Boolean> cir)
{
// return true if mob has custom name
if(WurstClient.INSTANCE.getHax().nameTagsHack.shouldForceMobNametags())
cir.setReturnValue(true);
}
}
1 change: 1 addition & 0 deletions src/main/resources/wurst.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"LanguageManagerMixin",
"LivingEntityRendererMixin",
"MinecraftClientMixin",
"MobEntityRendererMixin",
"MouseMixin",
"MultiplayerScreenMixin",
"PackScreenMixin",
Expand Down