HTTPS
https://git.nageyqma.icu/nageyqma/odin_next.git
SSH
git@git.nageyqma.icu:nageyqma/odin_next.git
HTTPS 链接可直接 git clone;推送代码请使用 SSH。
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
package com.odtheking.mixin.mixins;
import com.odtheking.odin.features.impl.render.CustomNameReplacer;
import net.minecraft.client.gui.Font;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.util.FormattedCharSequence;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(Font.class)
public class FontMixin {
@ModifyVariable(method = "prepareText(Ljava/lang/String;FFIZI)Lnet/minecraft/client/gui/Font$PreparedText;", at = @At("HEAD"), argsOnly = true, name = "text")
private String onPrepareTextString(String text) {
if (!CustomNameReplacer.isEnabled()) return text;
return CustomNameReplacer.replaceStringIfNeeded(text);
}
@ModifyVariable(method = "prepareText(Lnet/minecraft/util/FormattedCharSequence;FFIZZI)Lnet/minecraft/client/gui/Font$PreparedText;", at = @At("HEAD"), argsOnly = true, name = "text")
private FormattedCharSequence onPrepareTextSequence(FormattedCharSequence text) {
if (!CustomNameReplacer.isEnabled()) return text;
return CustomNameReplacer.replaceSequenceIfNeeded(text);
}
@ModifyVariable(method = "width(Ljava/lang/String;)I", at = @At("HEAD"), argsOnly = true, name = "str")
private String onWidthString(String text) {
if (!CustomNameReplacer.isEnabled()) return text;
return CustomNameReplacer.replaceStringIfNeeded(text);
}
@ModifyVariable(method = "width(Lnet/minecraft/network/chat/FormattedText;)I", at = @At("HEAD"), argsOnly = true, name = "text")
private FormattedText onWidthFormattedText(FormattedText text) {
if (!CustomNameReplacer.isEnabled()) return text;
if (text instanceof Component component) {
Component replaced = CustomNameReplacer.replaceComponentIfNeeded(component);
if (replaced != null) return replaced;
}
return text;
}
@ModifyVariable(method = "width(Lnet/minecraft/util/FormattedCharSequence;)I", at = @At("HEAD"), argsOnly = true, name = "text")
private FormattedCharSequence onWidthSequence(FormattedCharSequence text) {
if (!CustomNameReplacer.isEnabled()) return text;
return CustomNameReplacer.replaceSequenceIfNeeded(text);
}
}