Fix custom chat commands not cancelling
This commit is contained in:
parent
cbe2677fb4
commit
bc7cd2efcc
@ -0,0 +1,32 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.util.ChatCommand;
|
||||
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;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
try {
|
||||
if (ChatCommand.message(msg))
|
||||
ci.cancel();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,10 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.bot.Baritone;
|
||||
import baritone.util.ChatCommand;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import java.util.List;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@ -34,16 +27,4 @@ public class MixinGuiScreen {
|
||||
private static boolean isKeyDown(int keyCode) {
|
||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
||||
}
|
||||
|
||||
@Inject(method="sendChatMessage",at=@At("HEAD"))
|
||||
public void sendChatMessage(String msg, CallbackInfo cir)
|
||||
{
|
||||
try {
|
||||
ChatCommand.message(msg);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"verbose": false,
|
||||
"client": [
|
||||
"MixinEntityPlayerSP",
|
||||
"MixinGameSettings",
|
||||
"MixinGuiContainer",
|
||||
"MixinGuiOverlayDebug",
|
||||
|
Loading…
x
Reference in New Issue
Block a user