forked from lambda-client/lambda-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMixinGuiChat.java
More file actions
31 lines (26 loc) · 1.27 KB
/
MixinGuiChat.java
File metadata and controls
31 lines (26 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.lambda.mixin.gui;
import com.lambda.client.command.CommandManager;
import com.lambda.client.gui.mc.LambdaGuiChat;
import com.lambda.client.util.Wrapper;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiChat.class)
public abstract class MixinGuiChat extends GuiScreen {
@Shadow protected GuiTextField inputField;
@Shadow private String historyBuffer;
@Shadow private int sentHistoryCursor;
@Inject(method = "keyTyped(CI)V", at = @At("RETURN"))
public void returnKeyTyped(char typedChar, int keyCode, CallbackInfo info) {
GuiScreen currentScreen = Wrapper.getMinecraft().currentScreen;
if (currentScreen instanceof GuiChat && !(currentScreen instanceof LambdaGuiChat)
&& inputField.getText().startsWith(CommandManager.INSTANCE.getPrefix())) {
Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiChat(inputField.getText(), historyBuffer, sentHistoryCursor));
}
}
}