-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
130 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
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
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
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
9 changes: 9 additions & 0 deletions
9
...va/mod/acgaming/universaltweaks/mods/emojicord/emojicontext/EmojiFontRendererContext.java
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,9 @@ | ||
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext; | ||
|
||
public class EmojiFontRendererContext | ||
{ | ||
|
||
public static boolean isChatInput; | ||
public static boolean isChatMessage; | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
.../acgaming/universaltweaks/mods/emojicord/emojicontext/mixin/UTEmojiFontRendererMixin.java
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,39 @@ | ||
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin; | ||
|
||
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; | ||
|
||
@Mixin(value = EmojiFontRenderer.class, remap = false) | ||
public class UTEmojiFontRendererMixin | ||
{ | ||
|
||
@Shadow(remap = false) | ||
private static EmojiContext CurrentContext; | ||
|
||
@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); | ||
CurrentContext = EmojiContext.EmojiContextCache.instance.getContext(text, attributes); | ||
return CurrentContext.text; | ||
} | ||
CurrentContext = null; | ||
return text; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...n/java/mod/acgaming/universaltweaks/mods/emojicord/emojicontext/mixin/UTGuiChatMixin.java
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,28 @@ | ||
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin; | ||
|
||
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) | ||
{ | ||
EmojiFontRendererContext.isChatInput = true; | ||
return partialTicks; | ||
} | ||
|
||
@ModifyVariable(method = "drawScreen", at = @At("RETURN"), index = 3, ordinal = 0, name = "partialTicks") | ||
private float post_drawScreen(float partialTicks) | ||
{ | ||
EmojiFontRendererContext.isChatInput = false; | ||
return partialTicks; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ava/mod/acgaming/universaltweaks/mods/emojicord/emojicontext/mixin/UTGuiNewChatMixin.java
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,28 @@ | ||
package mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin; | ||
|
||
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) | ||
{ | ||
EmojiFontRendererContext.isChatMessage = true; | ||
return updateCounter; | ||
} | ||
|
||
@ModifyVariable(method = "drawChat", at = @At("RETURN"), index = 1, ordinal = 0, name = "updateCounter") | ||
private int post_drawChat(int updateCounter) | ||
{ | ||
EmojiFontRendererContext.isChatMessage = false; | ||
return updateCounter; | ||
} | ||
|
||
} |
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
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,7 @@ | ||
{ | ||
"package": "mod.acgaming.universaltweaks.mods.emojicord.emojicontext.mixin", | ||
"refmap": "universaltweaks.refmap.json", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": ["UTEmojiFontRendererMixin", "UTGuiChatMixin", "UTGuiNewChatMixin"] | ||
} |