有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java就是一种游戏性。getPosition在1.16版本的Forge中

我正在尝试制作一双靴子,允许用户在熔岩上行走。我的代码:

if (world.getFluidState(player.getPosition().down()).getFluid() == Fluids.LAVA) { // Check if lava is below the player
    Vector3d motion = player.getMotion();
    if (motion.y < 0)
        motion = motion.mul(1, 0, 1); // Stop the player from falling into the lava
    player.setMotion(motion);
}

然而,函数.getPosition似乎被弃用了。Forge的1.16版本中是否有此功能的等效版本?.getPositionVec返回一个向量,但我不确定如何在函数中使用它


共 (1) 个答案

  1. # 1 楼答案

    如果您的player实现了ICommandSender,那么您应该能够使用以下

    ChunkCoordinates coords = player.getPlayerCoordinates();
    

    之后,您可以访问coords.posX/coords.posY/coords.posZ

    有关更多信息,请查看this source