WarmRhombus
1.16.5forge实现取消视角切换功能,以下写法没有效果,还请各位大佬指点下,没有报错,是不是代码有问题







无敌三脚猫
看着也没错啊……可能枚举类就是有些不一样吧,你不如去改GameSettings类的getCameraType

WarmRhombus
无敌三脚猫 发表于 2023-9-15 08:33
看着也没错啊……可能枚举类就是有些不一样吧,你不如去改GameSettings类的getCameraType或者setCameraType ...

这样吗,还是没效果,不太会写,是不是哪里配置错了
  1. @Mixin(GameSettings.class)
  2. public class MixinMinecraft {
  3.     @Inject(method = "getCameraType", at = @At("HEAD"), cancellable = true)
  4.     private void onGetCameraType(CallbackInfoReturnable<GameType> info) {
  5.          info.setReturnValue(GameType.SURVIVAL);
  6.     }
  7. }
复制代码



无敌三脚猫
WarmRhombus 发表于 2023-9-15 13:20
这样吗,还是没效果,不太会写,是不是哪里配置错了

嗯?获取视角,结果你返回一个生存模式?
怎么着也应该是
  1.     @Inject(method = "getCameraType", at = @At("HEAD"), cancellable = true)
  2.     private void onGetCameraType(CallbackInfoReturnable<PointOfView> info) {
  3.          info.setReturnValue(PointOfView.FIRST_PERSON);
  4.     }
复制代码

WarmRhombus
无敌三脚猫 发表于 2023-9-15 13:44
嗯?获取视角,结果你返回一个生存模式?
怎么着也应该是

找到问题了,构建出来就有效果了,内置的客户端测试的时候没效果