Minecraft 1.15 Forge Mod 开发笔记

事件系统

事件分两种:一种是 FML Mod 加载事件,在 FMLJavaModLoadingContext.get().getModEventBus() 中注册;另一种是游戏内事件,在 MinecraftForge.EVENT_BUS 中注册。

在事件总线上注册监听器

监听器需要在 Mod 的构造函数中注册。具体接口的用法去看 net.minecraftforge.eventbus.api.IEventBus 的注释吧,咱就不在这里赘述了。

FML Mod 加载事件

这类事件都是在进入游戏主界面前触发的事件,多用于注册各种对象。这里的事件发布于 FMLJavaModLoadingContext.get().getModEventBus() 上。

Mod 加载顺序(从 Log 里面读出来的,如有错误还烦请指正):

  • LifeCycleEvent:CONSTRUCT (不能监听)
    • 这里是执行你的 Mod 主类的构造函数
    • 用来注册事件侦听器
    • Mod.EventBusSubscriber 注解的事件侦听器也是在这时候被注册的
    • 在这里注册 Mod 的 配置文件
  • RegistryEvent.NewRegistry
    • 用于新建 Registry
  • RegistryEvent.Register<T>
    • 这里 T 是注册项的基类
    • 具体顺序:引用自 Forge 文档
    • RegistryEvents are currently supported for the following types: Block, Item, Potion, Biome, SoundEvent, PotionType, Enchantment, IRecipe, VillagerProfession, EntityEntry

    • 最后是 Mod 自定义的 Registry
    • 不建议用事件的 register 方法注册,建议使用 DeferredRegister 注册
    • DeferredRegister<T> 开始注册,并为 RegistryObject<T> 填充实例
  • 生成、读取 Mod 配置文件(无事件)
    • 先生成 Client 的配置文件
    • 后生成 Common 的配置文件
  • FMLCommonSetupEvent
    • Capability 在这时注册
  • LifecycleEvent:SIDED_SETUP
    • 这里区分启动的端,如果是服务端,则触发 FMLDedicatedServerSetupEvent
    • 如果是客户端,则触发 FMLClientSetupEvent
  • Forge Version Check
    • 这里会检查 Forge 和 Mod 的版本是否为最新
  • InterModEnque
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
This module provides the following functionality... * 'C' style interface The Tuxedo perl module gives you access to almost all of the tuxedo 8.1 apis from perl. In most cases you can take the C API you already familiar with, apply perl semantics to it, and write working tuxedo programs in perl. * Object wrapping of C structures Many tuxedo functions take pointers to C structures as function parameters. To preserve the C interface, this module provides perl objects that encapsulate the C structures used by tuxedo. These objects allow the user to create and manipulate the elements of these C structures, and these objects are then passed as parameters to the perl version of these tuxedo C functions. * buffer management Perl classes exist for each buffer type to allow for easy manipulation of buffer contents and automatic memory cleanup when no more references to the buffer exist. * callback subs perl subs can be registered as unsolicited message handlers and signal handlers. * FML/FML32 field table support This module includes the mkfldpm32.pl script that is the perl equivalent of the tuxedo mkfldhdr32 program. It accepts a field table file as input and produces a *.pm file that can be included in a perl script, so field identifiers can be referenced by id. * perl tuxedo services You can now write tuxedo services in perl. When you build the Tuxedo module, it should create a tuxedo server called PERLSVR. This is a tuxedo server that contains an embedded perl interpretor for executing perl tuxedo services. When PERLSVR boots up, it parses the perlsvr.pl script, which at the moment it expects to find in its working directory. The location of perlsvr.pl will be configurable in a future version. The perlsvr.pl script is run as the tpsvrinit routine. You can modify perlsvr.pl to define any subs you want to be tuxedo services and advertise these subs.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值