diff options
author | RoseGoldIsntGay <yoavkau@gmail.com> | 2022-02-05 22:27:18 +0200 |
---|---|---|
committer | RoseGoldIsntGay <yoavkau@gmail.com> | 2022-02-05 22:27:18 +0200 |
commit | 8c9e6e4a9047f07afe9e478c3ef6808a31e2c30c (patch) | |
tree | de490b00effd594065f9b11356e6f2ee84ff9a3e /src/main/java/rosegoldaddons/mixins/MixinEntity.java | |
parent | 5e484b169e736408ada925d9cdcea9ac6df7374a (diff) | |
download | RGA-8c9e6e4a9047f07afe9e478c3ef6808a31e2c30c.tar.gz RGA-8c9e6e4a9047f07afe9e478c3ef6808a31e2c30c.tar.bz2 RGA-8c9e6e4a9047f07afe9e478c3ef6808a31e2c30c.zip |
Better Custom Name Mixins
Added better mixins for custom names
Fixed [if or and] mistake in hardstone nuker
Diffstat (limited to 'src/main/java/rosegoldaddons/mixins/MixinEntity.java')
-rw-r--r-- | src/main/java/rosegoldaddons/mixins/MixinEntity.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/rosegoldaddons/mixins/MixinEntity.java b/src/main/java/rosegoldaddons/mixins/MixinEntity.java new file mode 100644 index 0000000..3319fc1 --- /dev/null +++ b/src/main/java/rosegoldaddons/mixins/MixinEntity.java @@ -0,0 +1,33 @@ +package rosegoldaddons.mixins; + +import net.minecraft.entity.Entity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +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 rosegoldaddons.Main; + +import java.util.Map; + +@Mixin(Entity.class) +public class MixinEntity { + @Inject(method = "getDisplayName", at = @At(value = "RETURN"), cancellable = true) + public void getFormattedText(CallbackInfoReturnable<IChatComponent> cir) { + if(Main.pauseCustom || Main.configFile.nameRenderType == 0) return; + if (Main.init && Main.configFile.alchsleep != 63 || Main.configFile.skiblock != 263) { + IChatComponent ict = new ChatComponentText(""); + ict.setChatStyle(cir.getReturnValue().getChatStyle()); + String text = cir.getReturnValue().getFormattedText(); + for (Map.Entry<String, String> entry : Main.nameCache.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + + text = text.replace(key, value); + } + ict.appendText(text); + cir.setReturnValue(ict); + } + } +} |