-2

これが数秒で経過するまで待機するようなJava関数を作成したい場合、アクションを実行する可能性があります..これが私が持っているものです:

    if(Minecraft.getMinecraft().gameSettings.keyBindJump.pressed)
        hasTimePassedS(2);
        Minecraft.getMinecraft().thePlayer.motionY = + 8;


    private boolean hasTimePassedS(int i) {
    long t0 = 0,t1 = 1;
     do{
     }
     while (t1-t0<1000);
    return false;

注: これらは 2 つの異なるサンプルであり、正しい { } 形式は使用/考慮されていません。

トップコードがアクティブになってからもう一度押すまでに 2 秒の遅延が必要です。

ありがとう!

4

1 に答える 1

0

を作成 (およびstart)できますTimer。また、私はあなたが+= 8(ではない= +8)のようなものを意味していたと確信しています。

if (Minecraft.getMinecraft().gameSettings.keyBindJump.pressed) {
  Timer t = new Timer(2000, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Minecraft.getMinecraft().thePlayer.motionY += 8;
    }
  });
  t.start();
}
于 2016-01-22T04:10:17.540 に答える