Java 在每次勾选时将数据存储到ArrayList中

Java 在每次勾选时将数据存储到ArrayList中,java,Java,不确定是否有人能在这里帮助我,但我目前正在努力为一个游戏做一些东西。这里有一些简单的解释我想做什么 @SubscribeEvent public void onTick(TickEvent.RenderTickEvent e) { // RECORDING // on every tick, save xyz of myplayer // save yaw and pitch // capture

不确定是否有人能在这里帮助我,但我目前正在努力为一个游戏做一些东西。这里有一些简单的解释我想做什么

    @SubscribeEvent
    public void onTick(TickEvent.RenderTickEvent e) {
        
        // RECORDING

        // on every tick, save xyz of myplayer
        // save yaw and pitch
        // capture if player is sprinting, walking forward and shifting.


        // REPLAYING

        // Check if my_XYZ current tick if not the same with a 0.5 threshhold, then its not longer replaying properly.
        // if xyz and yaw is the same, set current player yaw, and pitch to corresponding yaw/pitch and then just override all the movements.

    }
我每次都要保存播放器的XYZ跳线,我觉得最好的方法是将其存储在arraylist中,但我不确定如何执行此操作

如果有人能为我指出正确的方向,我将不胜感激

经过进一步的测试,我已经走得更远了,但仍然有一些困难

ArrayList<Double> posX = new ArrayList<Double>(); // Create an ArrayList object

posX.add(mc.thePlayer.posX);

System.out.println(posX);
System.out.println(posX.size());
ArrayList posX=new ArrayList();//创建ArrayList对象
add(mc.thePlayer.posX);
系统输出打印LN(posX);
System.out.println(posX.size());

每次单击时,它都会覆盖数组中当前的内容。

将posX arraylist移出onTick(…)方法。如果你把这份清单标为最终清单会更好