= 创作分享 =
编程开发
1.18.2如何禁用其他模组的部分功能
6371peter

1.18.2如何禁用其他模组的部分功能

6371peter 于 2024-2-14 23:26 ( 2月前 ) [复制链接] [显示全部楼层] [打印]
371 0
C江秋
你的意思是取消handleArrowLooseEvent(ArrowLooseEvent event)的执行?一般情况下我选择修改源码,一个return就解决了,但不修改的除了mixin外或许可以尝试自己编写个AOP试一下
  1. import org.aopalliance.intercept.MethodInterceptor;
  2. import org.aopalliance.intercept.MethodInvocation;

  3. public class MyMethodInterceptor implements MethodInterceptor {
  4.     @Override
  5.     public Object invoke(MethodInvocation invocation) throws Throwable {
  6.         String methodName = invocation.getMethod().getName();
  7.         if ("handleArrowLooseEvent".equals(methodName)) {
  8.             // 返回null,取消原方法的执行
  9.             return null;
  10.         }
  11.       
  12.         return invocation.proceed();
  13.     }
  14. }
复制代码
始终在征程上。
发表于 2024-2-14 23:26:08 | 显示全部楼层

回复 | 举报

百科目前不允许匿名发帖哦~ 请先 [ 登陆 ][ 注册 ] 吧~

本版积分规则

发新帖
  • 回复
  • 点评
  • 评分

[ MC百科(mcmod.cn) 除另有声明,所有开放公共编辑的内容均使用 BY-NC-SA 3.0 协议 ]

Minecraft百科CC协议
快速回复 返回顶部 返回列表