0

我正在为 Minecraft(一个游戏)编写一个力场模型。

到目前为止,这是我的代码:

    if (Camb.killaura)
    {      
        for(final int i= 0; i < mc.theWorld.loadedEntityList.size(); i++){
            if((Entity)mc.theWorld.loadedEntityList.get(i) != this && getDistanceSqToEntity((Entity)mc.theWorld.loadedEntityList.get(i)) < 19.5D){
                if(((Entity)mc.theWorld.loadedEntityList.get(i) instanceof EntityPlayer)){
                        mc.playerController.attackEntity(this, (Entity)mc.theWorld.loadedEntityList.get(i));
                            swingItem();
                    }

            }

一切正常,但问题是大多数服务器只允许您每秒攻击实体 8 次。所以我的问题是,如何每 0.125 秒执行一次以下操作?我问了几个模组制作者,他们说他们使用纳秒,我该怎么做?

这是唯一需要延迟的代码:

mc.playerController.attackEntity(this, (Entity)mc.theWorld.loadedEntityList.get(i));
                        swingItem();
4

0 回答 0