package baritone.launch.mixins; import baritone.bot.Baritone; import baritone.bot.event.events.ChatEvent; import net.minecraft.client.entity.EntityPlayerSP; 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; /** * @author Brady * @since 8/1/2018 5:06 PM */ @Mixin(EntityPlayerSP.class) public class MixinEntityPlayerSP { @Inject( method = "sendChatMessage", at = @At("HEAD"), cancellable = true ) private void sendChatMessage(String msg, CallbackInfo ci) { ChatEvent event = new ChatEvent(msg); Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event); if (event.isCancelled()) ci.cancel(); } @Inject( method = "onUpdate", at = @At( value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;onUpdate()V" ) ) private void onUpdate(CallbackInfo ci) { Baritone.INSTANCE.getGameEventHandler().onPlayerUpdate(); } }