EAA_MOD/src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java

28 lines
974 B
Java

package net.saltymc.eaa.mixin;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.saltymc.eaa.commands.CommandHandler;
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;
/*
@Mixin(TitleScreen.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
System.out.println("This line is printed by an example mod mixin!");
}
}
*/
@Mixin(ClientPlayerEntity.class)
public class ExampleMixin { //ClientPlayerEntityMixin
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void onSendChatMessage(String message, CallbackInfo info) {
System.out.println("in onSendChatMessage");
if (CommandHandler.executeCommand(message)) {
info.cancel();
}
}
}