baritone/src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java

41 lines
1.2 KiB
Java
Raw Normal View History

package baritone.launch.mixins;
2018-08-02 01:46:51 +00:00
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) {
2018-08-02 01:46:51 +00:00
ChatEvent event = new ChatEvent(msg);
Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event);
if (event.isCancelled())
ci.cancel();
}
2018-08-05 02:58:32 +00:00
@Inject(
method = "onUpdate",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/client/entity/AbstractClientPlayer;onUpdate()V"
)
)
2018-08-05 05:25:08 +00:00
private void onUpdate(CallbackInfo ci) {
Baritone.INSTANCE.getGameEventHandler().onPlayerUpdate();
2018-08-05 02:58:32 +00:00
}
}