[全民写端]#4添加Event和Module

简介: 在EntityPlayerSP类里面找到onUpdate方法 在第一行写 new EventUpdate().call();

首发于Enaium的个人博客


一. 添加Event

  1. 下载Event解压到你想要的目录
  2. 修改Event

    4-1

二. 钩子

  1. EntityPlayerSP类里面找到onUpdate方法 在第一行写 new EventUpdate().call();
  2. Minecraft类里找到runTick方法 找到Keyboard.next()循环 在if (k == 62 && this.entityRenderer != null)下面写 new EventKeyboard(k).call();
    ```java
    [...]
    public void onUpdate()
    {
    new EventUpdate().call();
[...]

```java
[...]
if (k == 62 && this.entityRenderer != null)
{
    this.entityRenderer.switchUseShader();
}

    new EventKeyboard(k).call();

    if (this.currentScreen != null)
    [...]

三. 写Category枚举

package cn.enaium.coreium.module;

public enum Category {
   
   
    COMBAT,
    RENDER,
    MOVEMENT,
    PLAYER,
    OTHER
}

四. 写Module类

package cn.enaium.coreium.module;

import cn.enaium.coreium.Coreium;

public class Module {
   
   
    private boolean toggle;
    private String name;
    private int keyCode;
    private Category category;

    public Module(String name, int keyCode, Category category) {
   
   
        this.toggle = false;
        this.name = name;
        this.keyCode = keyCode;
        this.category = category;
    }

    public boolean isToggle() {
   
   
        return toggle;
    }

    public void setToggle(boolean toggle) {
   
   
        this.toggle = toggle;
    }

    public String getName() {
   
   
        return name;
    }

    public void setName(String name) {
   
   
        this.name = name;
    }

    public int getKeyCode() {
   
   
        return keyCode;
    }

    public void setKeyCode(int keyCode) {
   
   
        this.keyCode = keyCode;
    }

    public Category getCategory() {
   
   
        return category;
    }

    public void setCategory(Category category) {
   
   
        this.category = category;
    }

    public void toggle()
    {
   
   
        this.toggle = !this.toggle;
        if(this.toggle) onEnable(); else onDisable();
    }

    public void onEnable() {
   
   
        Coreium.INSTANCE.eventManager.register(this);
    }

    public void onDisable() {
   
   
        Coreium.INSTANCE.eventManager.unregister(this);
    }
}

五. 写ModuleManager类

package cn.enaium.coreium.module;

import cn.enaium.coreium.Coreium;
import cn.enaium.coreium.event.EventTarget;
import cn.enaium.coreium.event.events.EventKeyboard;

import java.util.ArrayList;

public class ModuleManager {
   
   
    private ArrayList<Module> modules;

    public ModuleManager() {
   
   
        this.modules = new ArrayList();
        Coreium.INSTANCE.eventManager.register(this);
    }

    public void loadMods() {
   
   

    }


    private void addModule(Module m) {
   
   
        modules.add(m);
    }

    @EventTarget
    public void onKey(EventKeyboard eventKeyBoard) {
   
   
        for (Module mod : modules) {
   
   
            if (mod.getKeyCode() == eventKeyBoard.getKey())
                mod.toggle();
        }
    }

    public ArrayList<Module> getModules() {
   
   
        return modules;
    }
}

六. 在Start添加

    public void start() {
   
   
        eventManager = new EventManager();
        moduleManager = new ModuleManager();
        Display.setTitle("Coreium");
        moduleManager.loadMods();
    }
目录
相关文章
|
开发工具 git 开发者
Git Pull vs. Git Fetch:深度解析
【2月更文挑战第29天】
2761 0
Git Pull vs. Git Fetch:深度解析
go 换源 国内源
go 换源 国内源
1198 0
|
算法 数据处理 C++
【C++ 20 新特性 算法和迭代器库的扩展和泛化 Ranges】深入浅出C++ Ranges库 (Exploring the C++ Ranges Library)
【C++ 20 新特性 算法和迭代器库的扩展和泛化 Ranges】深入浅出C++ Ranges库 (Exploring the C++ Ranges Library)
1481 1
|
3月前
|
SQL 存储 消息中间件
Trino权威指南
Trino(原Presto SQL)是一款开源分布式SQL查询引擎,专为大数据联邦查询设计。它支持秒级查询PB级数据,可无缝对接Hive、MySQL、Kafka等20+异构数据源。其核心特性包括高速查询、弹性扩展和低成本使用,适合交互式分析与BI场景。Trino采用无共享架构,通过列式内存格式和动态代码生成优化性能,并提供丰富的连接器实现计算存储分离,最大化下推优化以提升效率。
阿里云服务器购买后,怎么申请开具发票?
阿里云用户可在用户中心的发票管理页面开具电子或纸质发票。首次开票需设置发票抬头,支持个人或企业,可选增值税普通或专用发票。个人账号无法直接开企业发票,需变更实名认证。发票税率因产品而异,通常为6%或13%。发票抬头可修改,纸质发票邮寄费用由阿里云承担(特殊情况除外)。电子发票同样可报销。更多详情见阿里云帮助中心。
667 106
|
前端开发 数据可视化 JavaScript
知识图谱(Knowledge Graph)- Neo4j 5.10.0 使用 - Python 操作
知识图谱(Knowledge Graph)- Neo4j 5.10.0 使用 - Python 操作
221 0
|
监控 数据挖掘 数据安全/隐私保护
ERP系统中的客户投诉管理与解决方案解析
【7月更文挑战第25天】 ERP系统中的客户投诉管理与解决方案解析
893 1
|
API
uView route 路由跳转
uView route 路由跳转
225 0
|
Docker 容器
Docker服务启动失败报错:Job for docker.service failed because the control process exited with error code.
Docker服务启动失败报错:Job for docker.service failed because the control process exited with error code.
|
安全 网络安全 网络架构
OpenWRT软路由web界面如何远程访问
OpenWRT软路由web界面如何远程访问

热门文章

最新文章