Add a temporary patch for Chat message validation failed

This commit is contained in:
chipmunk 2023-01-29 20:00:09 -05:00
parent a91b5ac1f0
commit 92612c6b32
3 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,18 @@
package land.chipmunk.chipmunkmod.mixin;
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.CallbackInfo;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.text.Text;
@Mixin(net.minecraft.network.ClientConnection.class)
public class ClientConnectionMixin {
@Inject(at = @At("HEAD"), method = "disconnect", cancellable = true)
public void disconnect (Text disconnectReason, CallbackInfo ci) {
if (disconnectReason == ClientPlayNetworkHandlerAccessor.chatValidationFailedText()) {
ci.cancel();
}
}
}

View file

@ -0,0 +1,11 @@
package land.chipmunk.chipmunkmod.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.text.Text;
@Mixin(net.minecraft.client.network.ClientPlayNetworkHandler.class)
public interface ClientPlayNetworkHandlerAccessor {
@Accessor("CHAT_VALIDATION_FAILED_TEXT")
public static Text chatValidationFailedText () { throw new AssertionError(); }
}

View file

@ -7,7 +7,9 @@
],
"client": [
"ChatScreenMixin",
"ChatInputSuggestorMixin"
"ChatInputSuggestorMixin",
"ClientPlayNetworkHandlerAccessor",
"ClientConnectionMixin"
],
"injectors": {
"defaultRequire": 1