java—在forge的1.16版本中是否有playerentity.getposition的等价物

siotufzp  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(301)

我正在尝试创建一双 Boot ,允许用户在熔岩上行走。我的代码:

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 返回一个向量,但我不知道如何在函数中使用它。

wxclj1h5

wxclj1h51#

如果你的 player 工具 ICommandSender 那么你应该能够使用以下

ChunkCoordinates coords = player.getPlayerCoordinates();

之后你就可以 coords.posX / coords.posY / coords.posZ .
有关更多信息,请查看此来源

相关问题