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

60 lines
1.9 KiB
Java
Raw Normal View History

2018-08-08 03:16:53 +00:00
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
2018-08-08 03:16:53 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
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(
2018-08-06 23:56:57 +00:00
value = "INVOKE",
target = "net/minecraft/client/entity/EntityPlayerSP.isRiding()Z",
shift = At.Shift.BY,
by = -3
2018-08-05 02:58:32 +00:00
)
)
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
}
}