一. 把第一季的源码复制过来

二. 注入

  1. 注入run 和 top img
@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();
    }
}
  1. 注入EventUpdate EventKeyboard EventRender2D

img

@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();
    }
}

img

@Mixin(EntityPlayerSP.class)
public class EntityPlayerSPMixin {
    @Inject(at = @At("HEAD"), method = "onUpdate")
    private void onUpdate(CallbackInfo info) {
        new EventUpdate(Event.Type.PRE).call();
    }
}

img

@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();
    }
}
  1. 注入Command

img

@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();
        }
    }
}
  1. 加入到mixin.json

img

完成