一. 把第一季的源码复制过来
二. 注入
@Mixin(Minecraft.class)
public class MinecraftMixin {
@Inject(at = @At("RETURN"), method = "startGame")
private void startGame(CallbackInfo info) {
FoxBase.instance.run();
}
@Inject(at = @At("HEAD"), method = "shutdownMinecraftApplet")
private void stop(CallbackInfo info) {
FoxBase.instance.stop();
}
}
EventUpdate
EventKeyboard
EventRender2D
@Mixin(Minecraft.class)
public class MinecraftMixin {
@Inject(at = @At("RETURN"), method = "dispatchKeypresses")
private void dispatchKeypresses(CallbackInfo info) {
if (Keyboard.getEventKeyState() && Minecraft().getMinecraft().currentScreen == null)
new EventKeyboard(Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard,getEventKey()).call();
}
}
@Mixin(EntityPlayerSP.class)
public class EntityPlayerSPMixin {
@Inject(at = @At("HEAD"), method = "onUpdate")
private void onUpdate(CallbackInfo info) {
new EventUpdate(Event.Type.PRE).call();
}
}
@Mixin(GuiIngame.class)
public class GuiIngameMixin {
@Inject(at = @At("HEAD"), method = "renderTooltip")
private void renderTooltip(ScaleResolution prenderTooltio_1_,float prenderTooltio_2_,CallbackInfo info) {
new EventRender2D(Event.Type.PRE).call();
}
}
Command
@Mixin(EntityPlayerSP.class)
public class EntityPlayerSPMixin {
@Inject(at = @At("HEAD"), method = "sendChatMessage", cancellabke = true)
private void sendChatMessage(String p_sendChatMessage_1_,CallbackInfo info) {
if (Coreium.instance.commandManager.processCommand(p_sendChatMessage_1_)) {
info.cancel();
}
}
}
mixin.json
完成