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

38 lines
1.1 KiB
Java
Raw Normal View History

2021-05-21 18:18:32 +02:00
package net.saltymc.eaa.mixin;
2021-05-20 22:26:46 +02:00
2021-05-21 22:51:30 +02:00
import net.minecraft.client.network.ClientPlayerEntity;
import net.saltymc.eaa.EaaMod;
import net.saltymc.eaa.handler.CommandHandler;
import net.saltymc.eaa.util.ResponseEntity;
2021-05-20 22:26:46 +02:00
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;
2021-05-21 22:51:30 +02:00
/*
2021-05-20 22:26:46 +02:00
@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!");
}
}
2021-05-21 22:51:30 +02:00
*/
@Mixin(ClientPlayerEntity.class)
public class ExampleMixin extends MixinInterface { //ClientPlayerEntityMixin
public ExampleMixin(final EaaMod eaaMod){
super(eaaMod);
}
2021-05-21 22:51:30 +02:00
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void onSendChatMessage(String message, CallbackInfo info) {
System.out.println("in onSendChatMessage");
ResponseEntity responseEntity = eaaMod.onEvent(message);
if (responseEntity.isInterceptEvent())
2021-05-21 22:51:30 +02:00
info.cancel();
2021-05-21 22:51:30 +02:00
}
}