【问题标题】:How to get the coordinates of an item that the player is holding in Minecraft? Using MinecraftForge如何获取玩家在 Minecraft 中持有的物品的坐标?使用 MinecraftForge
【发布时间】:2016-01-30 20:34:40
【问题描述】:

我正在使用 Minecraft Forge,我想知道如何获取玩家拿着或查看的方块或物品的坐标。或者它也可能只是玩家刚刚打破的一个方块。在任何情况下,我都需要获取这些坐标,以便能够以使 y=Sin(x) 的方式更改它们,并且我将继续循环和生成同一项目的副本,以便绘制 Sinus 函数。 我真的很感激你的帮助。我被这个困住了好几天。 最好的,

【问题讨论】:

    标签: coordinates minecraft minecraft-forge spawning


    【解决方案1】:

    要获取玩家正在查看的方块:

    MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(200, 1.0F);
    if(mop != null)
    {
    int blockHitSide = mop.sideHit;
    Block blockLookingAt = worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) ;
    }
    

    块变量是blockLookingAt

    另外,您可能想查看http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/

    【讨论】:

    • 我尝试使用 renderViewEntity 但它不想工作,我不知道他们为什么不让我使用它。因此我使用了 objectMOuseOver: MovingObjectPosition mop= Minecraft.getMinecraft().objectMouseOver; int x=mop.getBlockPos().getX(); int y=mop.getBlockPos().getY();诠释 c=y - 20*x;诠释我; for(i=x;i
    猜你喜欢
    • 1970-01-01
    • 2020-09-17
    • 2016-05-20
    • 2014-04-21
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2021-11-24
    • 1970-01-01
    相关资源
    最近更新 更多