diff --git a/src/main/java/com/minecrafttas/tasmod/TASmod.java b/src/main/java/com/minecrafttas/tasmod/TASmod.java index c0ead5bd..85a7d32a 100644 --- a/src/main/java/com/minecrafttas/tasmod/TASmod.java +++ b/src/main/java/com/minecrafttas/tasmod/TASmod.java @@ -25,6 +25,7 @@ import com.minecrafttas.tasmod.commands.CommandSavestate; import com.minecrafttas.tasmod.commands.CommandTickrate; import com.minecrafttas.tasmod.commands.TabCompletionUtils; +import com.minecrafttas.tasmod.handlers.PlayUntilHandler; import com.minecrafttas.tasmod.playback.PlaybackControllerServer; import com.minecrafttas.tasmod.playback.metadata.builtin.StartpositionMetadataExtension; import com.minecrafttas.tasmod.registries.TASmodPackets; @@ -78,6 +79,8 @@ public class TASmod implements ModInitializer, EventServerInit, EventServerStop public static final CommandFileCommand commandFileCommand = new CommandFileCommand(); + public static final PlayUntilHandler playUntil = new PlayUntilHandler(); + @Override public void onInitialize() { @@ -117,6 +120,8 @@ public void onInitialize() { SavestateMotionStorage motionStorage = new SavestateMotionStorage(); PacketHandlerRegistry.register(motionStorage); EventListenerRegistry.register(motionStorage); + PacketHandlerRegistry.register(playUntil); + EventListenerRegistry.register(playUntil); } @Override diff --git a/src/main/java/com/minecrafttas/tasmod/commands/CommandPlayUntil.java b/src/main/java/com/minecrafttas/tasmod/commands/CommandPlayUntil.java index 21d93cd5..d34be78e 100644 --- a/src/main/java/com/minecrafttas/tasmod/commands/CommandPlayUntil.java +++ b/src/main/java/com/minecrafttas/tasmod/commands/CommandPlayUntil.java @@ -10,7 +10,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; -public class CommandPlayUntil extends CommandBase{ +public class CommandPlayUntil extends CommandBase { @Override public String getName() { @@ -24,7 +24,7 @@ public String getUsage(ICommandSender sender) { @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { - if(args.length==1) { + if (args.length == 1) { int i = 0; try { i = Integer.parseInt(args[0]); @@ -36,10 +36,8 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args } catch (Exception e) { e.printStackTrace(); } - } - else { + } else { sender.sendMessage(new TextComponentString("Stops the next playback one tick before the specified tick and lets you record from there:\n\n/playuntil 10, runs the playback until tick 9 and will record from there. Useful when you can't savestate")); } } - } diff --git a/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java b/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java index bc476933..c9f66e3e 100644 --- a/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java +++ b/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java @@ -2,8 +2,8 @@ import com.minecrafttas.mctcommon.events.EventListenerRegistry.EventBase; import com.minecrafttas.tasmod.playback.PlaybackControllerClient; -import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate; import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer; +import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate; public interface EventPlaybackClient { @@ -65,10 +65,10 @@ public interface EventRecordTick extends EventBase { public interface EventPlaybackTick extends EventBase { /** - * Fired when a tick is being recorded + * Fired when a tick is played back * - * @param index The index of the tick that is being recorded - * @param container The {@link InputContainer} that is being recorded + * @param index The index of the tick that is played back + * @param container The {@link InputContainer} that is played back */ public void onPlaybackTick(long index, InputContainer container); } @@ -84,4 +84,33 @@ public interface EventRecordClear extends EventBase { */ public void onRecordingClear(); } + + /** + * Fired when an input is deleted + */ + @FunctionalInterface + public interface EventInputDelete extends EventBase { + + /** + * Fired when an input is deleted + * + * @param The index of the input + */ + public void onInputDelete(long index); + } + + /** + * Fired when a tick is being played back before reading the inputs + */ + @FunctionalInterface + public interface EventPlaybackTickPre extends EventBase { + + /** + * Fired when a tick is being played back before reading the inputs + * + * @param index The index of the tick that is played back + * @param container The {@link InputContainer} that is played back + */ + public void onPlaybackTickPre(long index); + } } diff --git a/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java b/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java deleted file mode 100644 index fe1b9be0..00000000 --- a/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.minecrafttas.tasmod.handlers; - -import com.minecrafttas.mctcommon.events.EventClient.EventCamera; -import com.minecrafttas.tasmod.TASmodClient; -import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer; - -import net.minecraft.client.Minecraft; -import net.minecraft.util.math.MathHelper; - -/** - * Adds interpolation to the camera - * - * @author Pancake - * - */ -@Deprecated -public class InterpolationHandler implements EventCamera { - - public static float rotationPitch = 0f; - public static float rotationYaw = 0f; - - @Override - public CameraData onCameraEvent(CameraData dataIn) { - if (TASmodClient.controller.isPlayingback() /*&& ControlByteHandler.shouldInterpolate*/) { - InputContainer input = TASmodClient.controller.get(); - if (input == null) - return dataIn; - float nextPitch = input.getCameraAngle().getPitch(); - float nextYaw = input.getCameraAngle().getYaw(); - dataIn.pitch = (float) MathHelper.clampedLerp(rotationPitch, nextPitch, Minecraft.getMinecraft().timer.renderPartialTicks); - dataIn.yaw = (float) MathHelper.clampedLerp(rotationYaw, nextYaw + 180, Minecraft.getMinecraft().timer.renderPartialTicks); - } else { - dataIn.pitch = rotationPitch; - dataIn.yaw = rotationYaw; - } - return dataIn; - } -} diff --git a/src/main/java/com/minecrafttas/tasmod/handlers/PlayUntilHandler.java b/src/main/java/com/minecrafttas/tasmod/handlers/PlayUntilHandler.java new file mode 100644 index 00000000..51bd3a7d --- /dev/null +++ b/src/main/java/com/minecrafttas/tasmod/handlers/PlayUntilHandler.java @@ -0,0 +1,87 @@ +package com.minecrafttas.tasmod.handlers; + +import java.nio.ByteBuffer; + +import com.minecrafttas.mctcommon.networking.ByteBufferBuilder; +import com.minecrafttas.mctcommon.networking.Client.Side; +import com.minecrafttas.mctcommon.networking.exception.PacketNotImplementedException; +import com.minecrafttas.mctcommon.networking.exception.WrongSideException; +import com.minecrafttas.mctcommon.networking.interfaces.ClientPacketHandler; +import com.minecrafttas.mctcommon.networking.interfaces.PacketID; +import com.minecrafttas.mctcommon.networking.interfaces.ServerPacketHandler; +import com.minecrafttas.tasmod.TASmod; +import com.minecrafttas.tasmod.TASmodClient; +import com.minecrafttas.tasmod.events.EventPlaybackClient; +import com.minecrafttas.tasmod.networking.TASmodBufferBuilder; +import com.minecrafttas.tasmod.playback.PlaybackControllerClient; +import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate; +import com.minecrafttas.tasmod.registries.TASmodPackets; + +/** + * Feature for starting a recording after playing back a certain number of ticks + * + * @author Scribble + */ +public class PlayUntilHandler implements ClientPacketHandler, ServerPacketHandler, EventPlaybackClient.EventPlaybackTickPre { + + /** + * If not null, play until a certain point + */ + private Integer playUntil = null; + + @Override + public void onPlaybackTickPre(long index) { + /* Playuntil logic */ + if (playUntil != null && playUntil == index) { + TASmodClient.tickratechanger.pauseGame(true); + PlaybackControllerClient controller = TASmodClient.controller; + controller.setTASState(TASstate.NONE); + controller.setIndex(controller.index() - 1); + for (long i = controller.size() - 1; i >= index; i--) { + controller.remove(i); + } + controller.setTASState(TASstate.RECORDING); + playUntil = null; + } + } + + public boolean isActive() { + return playUntil != null; + } + + public void setPlayUntil(int until) { + this.playUntil = until; + } + + @Override + public PacketID[] getAcceptedPacketIDs() { + return new TASmodPackets[] { TASmodPackets.PLAYBACK_PLAYUNTIL }; + } + + @Override + public void onClientPacket(PacketID id, ByteBuffer buf, String username) throws PacketNotImplementedException, WrongSideException, Exception { + TASmodPackets packet = (TASmodPackets) id; + + switch (packet) { + case PLAYBACK_PLAYUNTIL: + int until = ByteBufferBuilder.readInt(buf); + setPlayUntil(until); + break; + default: + throw new PacketNotImplementedException(packet, this.getClass(), Side.SERVER); + } + } + + @Override + public void onServerPacket(PacketID id, ByteBuffer buf, String username) throws PacketNotImplementedException, WrongSideException, Exception { + TASmodPackets packet = (TASmodPackets) id; + + switch (packet) { + case PLAYBACK_PLAYUNTIL: + TASmod.server.sendToAll(new TASmodBufferBuilder(buf)); + break; + default: + throw new PacketNotImplementedException(packet, this.getClass(), Side.SERVER); + } + } +} diff --git a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java index 8914165a..4b3e1714 100644 --- a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java +++ b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java @@ -5,7 +5,6 @@ import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_FULLPLAY; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_FULLRECORD; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_LOAD; -import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_PLAYUNTIL; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_RESTARTANDPLAY; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_SAVE; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_STATE; @@ -17,7 +16,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; import java.util.List; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; import org.apache.logging.log4j.Logger; import org.lwjgl.input.Mouse; @@ -39,6 +42,7 @@ import com.minecrafttas.tasmod.events.EventPlaybackClient.EventControllerStateChange; import com.minecrafttas.tasmod.events.EventPlaybackClient.EventPlaybackJoinedWorld; import com.minecrafttas.tasmod.events.EventPlaybackClient.EventPlaybackTick; +import com.minecrafttas.tasmod.events.EventPlaybackClient.EventPlaybackTickPre; import com.minecrafttas.tasmod.events.EventPlaybackClient.EventRecordTick; import com.minecrafttas.tasmod.events.EventVirtualInput; import com.minecrafttas.tasmod.networking.TASmodBufferBuilder; @@ -142,8 +146,6 @@ public class PlaybackControllerClient implements // ===================================================================================================== - private Integer playUntil = null; // TODO Replace with event - public PlaybackControllerClient() { tasFileDirectory = TASmodClient.tasfiledirectory; @@ -491,21 +493,11 @@ private void playbackNextTick() { index++; // Increase the index and load the next inputs - /* Playuntil logic */ - if (playUntil != null && playUntil == index) { - TASmodClient.tickratechanger.pauseGame(true); - playUntil = null; - setTASState(TASstate.NONE); - for (long i = inputs.size() - 1; i >= index; i--) { - inputs.remove(i); - } - index--; - setTASState(TASstate.RECORDING); - return; - } + EventListenerRegistry.fireEvent(EventPlaybackTickPre.class, index); /* Stop condition */ if (index == inputs.size() || inputs.isEmpty()) { + index--; unpressContainer(); setTASState(TASstate.NONE); } @@ -517,7 +509,6 @@ private void playbackNextTick() { this.camera = container.getCameraAngle().clone(); EventListenerRegistry.fireEvent(EventPlaybackTick.class, index, container); } - } // ===================================================================================================== // Methods to manipulate inputs @@ -534,6 +525,11 @@ public long index() { return index; } + public void remove(long index) { + inputs.remove(index); + EventListenerRegistry.fireEvent(EventPlaybackClient.EventInputDelete.class, index); + } + public BigArrayList getInputs() { return inputs; } @@ -597,18 +593,19 @@ public void clear() { } /** - * Used for serializing the input container + * Used for displaying the rought contents of the input container */ @Override public String toString() { if (inputs.isEmpty()) { return "null"; } - String out = ""; + List out = new LinkedList<>(); for (int i = 0; i < inputs.size(); i++) { - out = out.concat(inputs.get(i).toString() + "\n"); + InputContainer input = inputs.get(i); + out.add(input.toString(i)); } - return out; + return String.join("\n", out); } // ============================================================== @@ -624,12 +621,6 @@ public void unpressContainer() { // ============================================================== - public void setPlayUntil(int until) { - this.playUntil = until; - } - - // ============================================================== - /** * Storage class which stores the keyboard, mouse, subticks and comments of a given tick. * @@ -663,8 +654,48 @@ public InputContainer() { @Override public String toString() { - String.join("\n// ", comments.inlineComments); - return keyboard.toString() + "|" + mouse.toString() + "|" + cameraAngle.toString() + "\t\t// " + comments.endlineComments; + return toString(-1); + } + + public String toString(int tick) { + List out = new LinkedList<>(); + out.addAll(comments.inlineComments); + + Queue keyboardQueue = new LinkedBlockingQueue<>(Arrays.asList(keyboard.toString().split("\n"))); + Queue mouseQueue = new LinkedBlockingQueue<>(Arrays.asList(mouse.toString().split("\n"))); + Queue cameraAngleQueue = new LinkedBlockingQueue<>(Arrays.asList(cameraAngle.toString().split("\n"))); + Queue endlineCommentQueue = new LinkedBlockingQueue<>(comments.endlineComments); + + String kb = getOrEmpty(keyboardQueue.poll()); + String ms = getOrEmpty(mouseQueue.poll()); + String ca = getOrEmpty(cameraAngleQueue.poll()); + + String elc = getOrEmpty(endlineCommentQueue.poll()); + if (!elc.isEmpty()) { + elc = "\t\t" + elc; + } + + out.add(String.format("%s|%s|%s|%s%s", tick == -1 ? "undefined" : tick, kb, ms, ca, elc)); + + // Add subtick lines, indented + int currentSubtick = 0; + while (!keyboardQueue.isEmpty() || !mouseQueue.isEmpty() || !cameraAngleQueue.isEmpty()) { + currentSubtick++; + kb = getOrEmpty(keyboardQueue.poll()); + ms = getOrEmpty(mouseQueue.poll()); + ca = getOrEmpty(cameraAngleQueue.poll()); + elc = getOrEmpty(endlineCommentQueue.poll()); + if (!elc.isEmpty()) { + elc = "\t\t" + elc; + } + + out.add(String.format("\t%s|%s|%s|%s%s", currentSubtick, kb, ms, ca, elc)); + } + return String.join("\n", out); + } + + private String getOrEmpty(String string) { + return string != null ? string : ""; } public VirtualKeyboard getKeyboard() { @@ -837,7 +868,6 @@ public PacketID[] getAcceptedPacketIDs() { PLAYBACK_FULLPLAY, PLAYBACK_FULLRECORD, PLAYBACK_RESTARTANDPLAY, - PLAYBACK_PLAYUNTIL, PLAYBACK_CLEAR_INPUTS, PLAYBACK_STATE @@ -949,11 +979,6 @@ public void onClientPacket(PacketID id, ByteBuffer buf, String username) throws }); break; - case PLAYBACK_PLAYUNTIL: - int until = ByteBufferBuilder.readInt(buf); - TASmodClient.controller.setPlayUntil(until); - break; - case PLAYBACK_CLEAR_INPUTS: TASmodClient.controller.clear(); break; diff --git a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerServer.java b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerServer.java index 889a5647..2ef2fe2d 100644 --- a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerServer.java +++ b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerServer.java @@ -5,7 +5,6 @@ import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_FULLPLAY; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_FULLRECORD; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_LOAD; -import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_PLAYUNTIL; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_RESTARTANDPLAY; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_SAVE; import static com.minecrafttas.tasmod.registries.TASmodPackets.PLAYBACK_STATE; @@ -36,6 +35,7 @@ public class PlaybackControllerServer implements ServerPacketHandler { @Override public PacketID[] getAcceptedPacketIDs() { + //@formatter:off return new TASmodPackets[] { PLAYBACK_STATE, @@ -43,10 +43,10 @@ public PacketID[] getAcceptedPacketIDs() { PLAYBACK_FULLPLAY, PLAYBACK_FULLRECORD, PLAYBACK_RESTARTANDPLAY, - PLAYBACK_PLAYUNTIL, PLAYBACK_SAVE, PLAYBACK_LOAD }; + //@formatter:on } @Override @@ -67,12 +67,11 @@ public void onServerPacket(PacketID id, ByteBuffer buf, String username) throws case PLAYBACK_FULLPLAY: case PLAYBACK_FULLRECORD: case PLAYBACK_RESTARTANDPLAY: - case PLAYBACK_PLAYUNTIL: case PLAYBACK_SAVE: case PLAYBACK_LOAD: TASmod.server.sendToAll(new TASmodBufferBuilder(buf)); break; - + default: throw new PacketNotImplementedException(packet, this.getClass(), Side.SERVER); } diff --git a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/DesyncMonitorFileCommandExtension.java b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/DesyncMonitorFileCommandExtension.java index 13d42617..b035c66a 100644 --- a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/DesyncMonitorFileCommandExtension.java +++ b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/DesyncMonitorFileCommandExtension.java @@ -28,7 +28,7 @@ * * @author Scribble */ -public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtension implements EventPlaybackClient.EventControllerStateChange { +public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtension implements EventPlaybackClient.EventControllerStateChange, EventPlaybackClient.EventInputDelete { /** * List containing {@link MonitorContainer MonitorContainers} in a TASfile @@ -72,6 +72,7 @@ public void onControllerStateChange(TASstate newstate, TASstate oldstate) { if (newstate == TASstate.RECORDING && monitorContainer.isEmpty()) { recordNull(0); } + currentValues = null; } @Override @@ -189,7 +190,7 @@ public String getStatus(EntityPlayerSP player) { private String lastPos = ""; public String getPos() { - if (currentValues != null && !TASmodClient.controller.isNothingPlaying()) { + if (currentValues != null && TASmodClient.controller.isPlayingback()) { EntityPlayerSP player = Minecraft.getMinecraft().player; String[] values = new String[3]; values[0] = getFormattedString(player.posX - currentValues.values[0]); @@ -204,7 +205,7 @@ public String getPos() { private String lastMotion = ""; public String getMotion() { - if (currentValues != null && !TASmodClient.controller.isNothingPlaying()) { + if (currentValues != null && TASmodClient.controller.isPlayingback()) { EntityPlayerSP player = Minecraft.getMinecraft().player; String[] values = new String[3]; values[0] = getFormattedString(player.motionX - currentValues.values[3]); @@ -365,4 +366,9 @@ public void onClear() { lastPos = ""; lastMotion = ""; } + + @Override + public void onInputDelete(long index) { + monitorContainer.remove(index); + } } \ No newline at end of file diff --git a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java index ec182f8e..937af70d 100644 --- a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java +++ b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java @@ -751,7 +751,7 @@ protected void mergeInputs(BigArrayList out, List serialisedKeyb // Add tick line, not indented out.add(mergeInput(currentTick, kb, ms, ca, elc)); - // Add subtick lines, not indented + // Add subtick lines, indented currentSubtick = 0; while (!keyboardQueue.isEmpty() || !mouseQueue.isEmpty() || !cameraAngleQueue.isEmpty()) { currentSubtick++; diff --git a/src/main/java/com/minecrafttas/tasmod/registries/TASmodKeybinds.java b/src/main/java/com/minecrafttas/tasmod/registries/TASmodKeybinds.java index 6743870c..2c828cf0 100644 --- a/src/main/java/com/minecrafttas/tasmod/registries/TASmodKeybinds.java +++ b/src/main/java/com/minecrafttas/tasmod/registries/TASmodKeybinds.java @@ -39,7 +39,7 @@ public enum TASmodKeybinds { // } catch (Exception e) { // e.printStackTrace(); // } - TASmodClient.controller.setTASState(TASstate.PLAYBACK); +// TASmodClient.controller.setTASState(TASstate.PLAYBACK); }, VirtualKeybindings::isKeyDown); private Keybind keybind; diff --git a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualCameraAngle.java b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualCameraAngle.java index be4ee087..60558537 100644 --- a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualCameraAngle.java +++ b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualCameraAngle.java @@ -216,7 +216,7 @@ public String toString() { } public String toString2() { - return String.format("%s;%s", pitch, yaw); + return String.format("%s;%s", yaw, pitch); } /** diff --git a/src/test/java/tasmod/virtual/VirtualCameraAngleTest.java b/src/test/java/tasmod/virtual/VirtualCameraAngleTest.java index fc77a122..50984279 100644 --- a/src/test/java/tasmod/virtual/VirtualCameraAngleTest.java +++ b/src/test/java/tasmod/virtual/VirtualCameraAngleTest.java @@ -118,26 +118,26 @@ void testGetStates() { test.updateFromEvent(1f, 1f); test.updateFromEvent(1f, 1f); test.updateFromEvent(1f, 1f); - + List actual = new ArrayList<>(); - + // Test get states on a subtick, should result in an empty array VirtualCameraAngle test2 = new VirtualCameraAngle(0f, 0f); - + test2.getStates(actual); - + assertTrue(actual.isEmpty()); - + actual.clear(); - + test.getStates(actual); - + List expected = new ArrayList<>(); - + expected.add(new VirtualCameraAngle(1f, 1f)); expected.add(new VirtualCameraAngle(2f, 2f)); expected.add(new VirtualCameraAngle(3f, 3f)); - + assertIterableEquals(expected, actual); } @@ -149,26 +149,26 @@ void testCopyFrom() { VirtualCameraAngle expected = new VirtualCameraAngle(0f, 0f, true); expected.updateFromEvent(1f, 2f); expected.updateFromEvent(3f, 4f); - + VirtualCameraAngle actual = new VirtualCameraAngle(0f, 0f, true); - + actual.moveFrom(expected); - + // Test pitch and yaw assertEquals(expected.getPitch(), actual.getPitch()); assertEquals(expected.getYaw(), actual.getYaw()); - + // Test subticks List expected2 = new ArrayList<>(); expected2.add(new VirtualCameraAngle(1f, 2f)); expected2.add(new VirtualCameraAngle(4f, 6f)); - + assertIterableEquals(expected2, actual.getAll()); // Test expected subticks being cleared - + assertTrue(expected.getSubticks().isEmpty()); } - + /** * Test clearing the camera angle */ @@ -179,9 +179,9 @@ void testClear() { actual.updateFromEvent(1f, 1f); actual.updateFromEvent(1f, 1f); actual.updateFromEvent(1f, 1f); - + actual.clear(); - + assertNull(actual.getPitch()); assertNull(actual.getYaw()); assertTrue(actual.getSubticks().isEmpty()); @@ -197,7 +197,7 @@ void testToString() { VirtualCameraAngle actual = new VirtualCameraAngle(x, y); - assertEquals("1.0;2.0", actual.toString()); + assertEquals("2.0;1.0", actual.toString()); } /** @@ -210,7 +210,7 @@ void testToStringSubticks() { actual.updateFromEvent(3f, 4f); actual.updateFromEvent(5f, 6f); - assertEquals("1.0;2.0\n4.0;6.0\n9.0;12.0", actual.toString()); + assertEquals("2.0;1.0\n6.0;4.0\n12.0;9.0", actual.toString()); } /** @@ -228,7 +228,7 @@ void testShallowClone() { assertEquals(1f, actual.getPitch()); assertEquals(2f, actual.getYaw()); } - + // DeepCloning /**