This commit is contained in:
Chayapak 2023-05-05 19:17:16 +07:00
parent d1dc686c4a
commit 536fcdf62d

View file

@ -1,15 +1,20 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.modules.CustomChat;
import net.minecraft.client.gui.widget.TextFieldWidget;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.client.MinecraftClient;
import land.chipmunk.chipmunkmod.command.CommandManager;
@Mixin(net.minecraft.client.gui.screen.ChatScreen.class)
public class ChatScreenMixin {
@Shadow protected TextFieldWidget chatField;
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
if (chatText.startsWith(CommandManager.prefix)) {
@ -26,4 +31,9 @@ public class ChatScreenMixin {
cir.setReturnValue(true);
}
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;setMaxLength(I)V"), method = "init")
public void init (CallbackInfo ci) {
chatField.setMaxLength(Integer.MAX_VALUE);
}
}