Skip to content

Commit

Permalink
Emojicord tweak follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Aug 22, 2024
1 parent 375034f commit de95e13
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class UniversalTweaks
+ "after:effortlessbuilding;"
+ "after:element;"
+ "after:elenaidodge2;"
+ "after:emojicord;"
+ "after:enderio;"
+ "after:epicsiegemod;"
+ "after:erebus;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

public class EmojiFontRendererContext
{

public static boolean isChatInput;
public static boolean isChatMessage;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@

import java.util.EnumSet;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

import mod.acgaming.universaltweaks.mods.emojicord.emojicontext.EmojiFontRendererContext;
import net.teamfruit.emojicord.EmojicordConfig;
import net.teamfruit.emojicord.emoji.EmojiContext;
import net.teamfruit.emojicord.emoji.EmojiContext.EmojiContextAttribute;
import net.teamfruit.emojicord.emoji.EmojiFontRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(value = EmojiFontRenderer.class, remap = false)
public class UTEmojiFontRendererMixin
{

@Shadow(remap = false)
private static EmojiContext CurrentContext;

/**
* @author Meldexun
* @reason Emojicord tweak
*/
@Overwrite(remap = false)
public static String updateEmojiContext(final String text)
{
if (EmojicordConfig.spec.isAvailable() && EmojicordConfig.RENDER.renderEnabled.get())
{
final EnumSet<EmojiContextAttribute> attributes = EnumSet.noneOf(EmojiContextAttribute.class);
if (EmojiFontRendererContext.isChatInput)
attributes.add(EmojiContextAttribute.CHAT_INPUT);
if (EmojiFontRendererContext.isChatMessage)
attributes.add(EmojiContextAttribute.CHAT_MESSAGE);
if (EmojiFontRendererContext.isChatInput) attributes.add(EmojiContextAttribute.CHAT_INPUT);
if (EmojiFontRendererContext.isChatMessage) attributes.add(EmojiContextAttribute.CHAT_MESSAGE);
CurrentContext = EmojiContext.EmojiContextCache.instance.getContext(text, attributes);
return CurrentContext.text;
}
CurrentContext = null;
return text;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin;

import net.minecraft.client.gui.GuiChat;

import mod.acgaming.universaltweaks.mods.emojicord.emojicontext.EmojiFontRendererContext;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import mod.acgaming.universaltweaks.mods.emojicord.emojicontext.EmojiFontRendererContext;
import net.minecraft.client.gui.GuiChat;

@Mixin(GuiChat.class)
public class UTGuiChatMixin
{

@ModifyVariable(method = "drawScreen", at = @At("HEAD"), index = 3, ordinal = 0, name = "partialTicks")
private float pre_drawScreen(float partialTicks)
@ModifyVariable(method = "drawScreen", at = @At("HEAD"), index = 3, ordinal = 0, name = "partialTicks", argsOnly = true)
private float utEmojicordPreDrawScreen(float partialTicks)
{
EmojiFontRendererContext.isChatInput = true;
return partialTicks;
}

@ModifyVariable(method = "drawScreen", at = @At("RETURN"), index = 3, ordinal = 0, name = "partialTicks")
private float post_drawScreen(float partialTicks)
@ModifyVariable(method = "drawScreen", at = @At("RETURN"), index = 3, ordinal = 0, name = "partialTicks", argsOnly = true)
private float utEmojicordPostDrawScreen(float partialTicks)
{
EmojiFontRendererContext.isChatInput = false;
return partialTicks;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin;

import net.minecraft.client.gui.GuiNewChat;

import mod.acgaming.universaltweaks.mods.emojicord.emojicontext.EmojiFontRendererContext;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import mod.acgaming.universaltweaks.mods.emojicord.emojicontext.EmojiFontRendererContext;
import net.minecraft.client.gui.GuiNewChat;

@Mixin(GuiNewChat.class)
public class UTGuiNewChatMixin
{

@ModifyVariable(method = "drawChat", at = @At("HEAD"), index = 1, ordinal = 0, name = "updateCounter")
private int pre_drawChat(int updateCounter)
@ModifyVariable(method = "drawChat", at = @At("HEAD"), index = 1, ordinal = 0, name = "updateCounter", argsOnly = true)
private int utEmojicordPreDrawChat(int updateCounter)
{
EmojiFontRendererContext.isChatMessage = true;
return updateCounter;
}

@ModifyVariable(method = "drawChat", at = @At("RETURN"), index = 1, ordinal = 0, name = "updateCounter")
private int post_drawChat(int updateCounter)
@ModifyVariable(method = "drawChat", at = @At("RETURN"), index = 1, ordinal = 0, name = "updateCounter", argsOnly = true)
private int utEmojicordPostDrawChat(int updateCounter)
{
EmojiFontRendererContext.isChatMessage = false;
return updateCounter;
}

}
}

0 comments on commit de95e13

Please sign in to comment.