-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added override option to Meteor's Nametags module to force rendering …
…nametags with the default font
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package dev.stardust.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.jetbrains.annotations.Nullable; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import meteordevelopment.meteorclient.settings.Setting; | ||
import meteordevelopment.meteorclient.settings.BoolSetting; | ||
import meteordevelopment.meteorclient.settings.SettingGroup; | ||
import meteordevelopment.meteorclient.systems.modules.Module; | ||
import meteordevelopment.meteorclient.systems.modules.Category; | ||
import meteordevelopment.meteorclient.renderer.text.TextRenderer; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import meteordevelopment.meteorclient.systems.modules.render.Nametags; | ||
import meteordevelopment.meteorclient.renderer.text.VanillaTextRenderer; | ||
|
||
/** | ||
* @author Tas [@0xTas] <[email protected]> | ||
* Allows use of default font for Nametags even when custom font is chosen in the global config. | ||
**/ | ||
@Mixin(value = Nametags.class, remap = false) | ||
public abstract class NametagsMixin extends Module { | ||
@Shadow | ||
@Final | ||
private SettingGroup sgGeneral; | ||
|
||
public NametagsMixin(Category category, String name, String description) { | ||
super(category, name, description); | ||
} | ||
|
||
@Unique | ||
private @Nullable Setting<Boolean> forceDefaultFont = null; | ||
|
||
@Inject(method = "<init>", at = @At(value = "FIELD", target = "Lmeteordevelopment/meteorclient/systems/modules/render/Nametags;scale:Lmeteordevelopment/meteorclient/settings/Setting;", shift = At.Shift.AFTER)) | ||
private void addDefaultFontSettings(CallbackInfo ci) { | ||
forceDefaultFont = sgGeneral.add( | ||
new BoolSetting.Builder() | ||
.name("force-default-font") | ||
.description("Force nametags to render using the default font, even if a custom GUI font is selected in your Meteor config.") | ||
.defaultValue(false) | ||
.build() | ||
); | ||
} | ||
|
||
@Inject(method = "renderNametagPlayer", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/systems/modules/render/Nametags;drawBg(DDDD)V")) | ||
private void injectDefaultFontForPlayerNametags(CallbackInfo ci, @Local LocalRef<TextRenderer> text) { | ||
if (forceDefaultFont != null && forceDefaultFont.get()) { | ||
text.set(VanillaTextRenderer.INSTANCE); | ||
} | ||
} | ||
|
||
@Inject(method = "renderNametagItem", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/systems/modules/render/Nametags;drawBg(DDDD)V")) | ||
private void injectDefaultFontForItemNametags(CallbackInfo ci, @Local LocalRef<TextRenderer> text) { | ||
if (forceDefaultFont != null && forceDefaultFont.get()) { | ||
text.set(VanillaTextRenderer.INSTANCE); | ||
} | ||
} | ||
|
||
@Inject(method = "renderGenericNametag", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/systems/modules/render/Nametags;drawBg(DDDD)V")) | ||
private void injectDefaultFontForGenericNametags(CallbackInfo ci, @Local LocalRef<TextRenderer> text) { | ||
if (forceDefaultFont != null && forceDefaultFont.get()) { | ||
text.set(VanillaTextRenderer.INSTANCE); | ||
} | ||
} | ||
|
||
@Inject(method = "renderTntNametag", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/systems/modules/render/Nametags;drawBg(DDDD)V")) | ||
private void injectDefaultFontForTNTNametags(CallbackInfo ci, @Local LocalRef<TextRenderer> text) { | ||
if (forceDefaultFont != null && forceDefaultFont.get()) { | ||
text.set(VanillaTextRenderer.INSTANCE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters