diff --git a/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ChatScreenMixin.java b/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ChatScreenMixin.java deleted file mode 100644 index f085912678..0000000000 --- a/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ChatScreenMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package vazkii.botania.fabric.mixin.client; - -import net.minecraft.client.gui.screens.ChatScreen; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; - -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.CallbackInfoReturnable; - -import vazkii.botania.common.block.block_entity.corporea.CorporeaIndexBlockEntity; - -@Mixin(value = ChatScreen.class) -public abstract class ChatScreenMixin extends Screen { - private ChatScreenMixin(Component title) { - super(title); - throw new IllegalStateException(); - } - - @Inject(at = @At("HEAD"), method = "handleChatInput", cancellable = true) - public void onChat(String input, boolean addToRecentChat, CallbackInfoReturnable cir) { - if (CorporeaIndexBlockEntity.ClientHandler.onChat(this.minecraft.player, input)) { - cir.setReturnValue(true); - } - } -} diff --git a/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ClientPacketListenerMixin.java b/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ClientPacketListenerMixin.java new file mode 100644 index 0000000000..4241164965 --- /dev/null +++ b/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ClientPacketListenerMixin.java @@ -0,0 +1,22 @@ +package vazkii.botania.fabric.mixin.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientPacketListener; + +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 vazkii.botania.common.block.block_entity.corporea.CorporeaIndexBlockEntity; + +@Mixin(ClientPacketListener.class) +public class ClientPacketListenerMixin { + @Inject(at = @At("HEAD"), method = "sendChat", cancellable = true) + private void onChat(String message, CallbackInfo ci) { + var player = Minecraft.getInstance().player; + if (CorporeaIndexBlockEntity.ClientHandler.onChat(player, message)) { + ci.cancel(); + } + } +} diff --git a/Fabric/src/main/resources/botania_fabric.mixins.json b/Fabric/src/main/resources/botania_fabric.mixins.json index 4495083924..a0393ce131 100644 --- a/Fabric/src/main/resources/botania_fabric.mixins.json +++ b/Fabric/src/main/resources/botania_fabric.mixins.json @@ -30,7 +30,7 @@ "client.AbstractTextureFabricMixin", "client.BlockModelDeserializerFabricMixin", "client.BossHealthOverlayFabricMixin", - "client.ChatScreenMixin", + "client.ClientPacketListenerMixin", "client.DebugScreenOverlayFabricMixin", "client.GuiGraphicsFabricMixin", "client.KeyboardHandlerFabricMixin",