diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5832f754..f94b742a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - name: Set up JDK 17 for x64
+ - name: Set up JDK 23 for x64
uses: actions/setup-java@v4
with:
- java-version: '17'
+ java-version: '23'
distribution: 'temurin'
architecture: x64
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
- gradle-version: 8.10.2
+ gradle-version: 8.13
- name: Build TASmod with Gradle
run: gradle build
- name: Upload Test Report
diff --git a/.github/workflows/buildandupload.yml b/.github/workflows/buildandupload.yml
index 7e34c890..d0fd1f96 100644
--- a/.github/workflows/buildandupload.yml
+++ b/.github/workflows/buildandupload.yml
@@ -11,16 +11,16 @@ jobs:
if: github.repository == 'MinecraftTAS/TASmod'
steps:
- uses: actions/checkout@v4
- - name: Set up JDK 17 for x64
+ - name: Set up JDK 23 for x64
uses: actions/setup-java@v4
with:
- java-version: '17'
+ java-version: '23'
distribution: 'temurin'
architecture: x64
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
- gradle-version: 8.10.2
+ gradle-version: 8.13
- name: Build TASmod with Gradle
run: gradle build
- name: Upload artifact
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6bb9cb2d..03d6faac 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -10,13 +10,13 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
- java-version: '22'
+ java-version: '23'
distribution: 'temurin'
architecture: x64
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
- gradle-version: 8.10.2
+ gradle-version: 8.13
- name: Setup workspace
run: gradle build -Prelease=true
- name: Upload assets
diff --git a/gradle.properties b/gradle.properties
index 01525f8f..c135d3d1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx3G
# Fabric properties
minecraft_version=1.12.2
-loader_version=0.16.9
-loom_version=1.8-SNAPSHOT
+loader_version=0.16.10
+loom_version=1.10-SNAPSHOT
# Mod properties
mod_name=Tool-Assisted Speedrun Mod
diff --git a/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java b/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java
index 8608d9d1..45013823 100644
--- a/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java
+++ b/src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java
@@ -3,7 +3,7 @@
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.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
public interface EventPlaybackClient {
@@ -53,9 +53,9 @@ public interface EventRecordTick extends EventBase {
* Fired when a tick is being recorded
*
* @param index The index of the tick that is being recorded
- * @param container The {@link TickContainer} that is being recorded
+ * @param container The {@link InputContainer} that is being recorded
*/
- public void onRecordTick(long index, TickContainer container);
+ public void onRecordTick(long index, InputContainer container);
}
/**
@@ -68,9 +68,9 @@ public interface EventPlaybackTick extends EventBase {
* Fired when a tick is being recorded
*
* @param index The index of the tick that is being recorded
- * @param container The {@link TickContainer} that is being recorded
+ * @param container The {@link InputContainer} that is being recorded
*/
- public void onPlaybackTick(long index, TickContainer container);
+ public void onPlaybackTick(long index, InputContainer container);
}
/**
diff --git a/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java b/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java
index cafe1ed5..fe1b9be0 100644
--- a/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java
+++ b/src/main/java/com/minecrafttas/tasmod/handlers/InterpolationHandler.java
@@ -2,7 +2,7 @@
import com.minecrafttas.mctcommon.events.EventClient.EventCamera;
import com.minecrafttas.tasmod.TASmodClient;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
@@ -22,7 +22,7 @@ public class InterpolationHandler implements EventCamera {
@Override
public CameraData onCameraEvent(CameraData dataIn) {
if (TASmodClient.controller.isPlayingback() /*&& ControlByteHandler.shouldInterpolate*/) {
- TickContainer input = TASmodClient.controller.get();
+ InputContainer input = TASmodClient.controller.get();
if (input == null)
return dataIn;
float nextPitch = input.getCameraAngle().getPitch();
diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiContainer.java b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiContainer.java
index 97dbf995..8602da33 100644
--- a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiContainer.java
+++ b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiContainer.java
@@ -13,7 +13,7 @@
@Mixin(GuiContainer.class)
public class MixinGuiContainer {
-
+
/**
* Redirects the check for {@link VirtualKey#LSHIFT} and {@link VirtualKey#RSHIFT} in mouseClicked
* @param i The keycode to check for
@@ -41,7 +41,7 @@ private boolean redirectIsKeyDown2(int i) {
@Redirect(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V"))
public void redirectCloseScreen(EntityPlayerSP player) {
Minecraft mc = Minecraft.getMinecraft();
- if(TASmodClient.virtual.isKeyDown(mc.gameSettings.keyBindInventory.getKeyCode()) && ((GuiContainer)(Object)this).isFocused()) {
+ if (TASmodClient.virtual.isKeyDown(mc.gameSettings.keyBindInventory.getKeyCode()) && ((GuiContainer) (Object) this).isFocused()) {
return;
}
player.closeScreen();
diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiScreen.java b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiScreen.java
index f0e73cb6..9fb9d566 100644
--- a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiScreen.java
+++ b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiScreen.java
@@ -1,12 +1,10 @@
package com.minecrafttas.tasmod.mixin.playbackhooks;
+import org.lwjgl.input.Mouse;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.At.Shift;
-import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.util.Ducks.GuiScreenDuck;
@@ -19,16 +17,6 @@
@Mixin(GuiScreen.class)
public class MixinGuiScreen implements GuiScreenDuck {
- /**
- * Run at the start of run handleInput. Runs every tick.
- * @see VirtualInput.VirtualKeyboardInput#nextKeyboardTick()
- * @param ci CBI
- */
- @Inject(method = "handleInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;isCreated()Z", shift = Shift.AFTER, remap = false))
- public void injectAfterKeyboardCreated(CallbackInfo ci) {
- TASmodClient.virtual.KEYBOARD.nextKeyboardTick();
- }
-
/**
* Redirects a {@link org.lwjgl.input.Keyboard#next()}. Starts running every tick and continues as long as there are {@link VirtualKeyboardEvent}s in {@link VirtualInput}
* @see VirtualInput.VirtualKeyboardInput#nextKeyboardSubtick()
@@ -60,13 +48,6 @@ public boolean redirectGetEventState() {
// =====================================================================================================================================
- @Inject(method = "handleInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;isCreated()Z", shift = Shift.AFTER, remap = false))
- public void injectAfterMouseCreated(CallbackInfo ci) {
- TASmodClient.virtual.MOUSE.nextMouseTick();
- }
-
- // =====================================================================================================================================
-
@Redirect(method = "handleInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;next()Z", remap = false))
public boolean redirectMouseNext() {
return TASmodClient.virtual.MOUSE.nextMouseSubtick();
@@ -84,7 +65,7 @@ public int redirectGetEventButton() {
@Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButtonState()Z", remap = false))
public boolean redirectGetEventButtonState() {
if (TASmodClient.controller.isPlayingback()) { // TODO replace with event
- org.lwjgl.input.Mouse.setCursorPosition(rescaleX(TASmodClient.virtual.MOUSE.getEventCursorX()), rescaleY(TASmodClient.virtual.MOUSE.getEventCursorY()));
+ Mouse.setCursorPosition(rescaleX(TASmodClient.virtual.MOUSE.getEventCursorX()), rescaleY(TASmodClient.virtual.MOUSE.getEventCursorY()));
}
return TASmodClient.virtual.MOUSE.getEventMouseState();
}
diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiSlot.java b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiSlot.java
index 3f566e6e..1eae5724 100644
--- a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiSlot.java
+++ b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinGuiSlot.java
@@ -10,19 +10,22 @@
@Mixin(GuiSlot.class)
public class MixinGuiSlot {
- @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE",target = "Lorg/lwjgl/input/Mouse;getEventButtonState()Z",ordinal = 0, remap = false))
+ @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButtonState()Z", ordinal = 0, remap = false))
public boolean redirectHandleMouseInput() {
return TASmodClient.virtual.MOUSE.getEventMouseState();
}
- @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE",target = "Lorg/lwjgl/input/Mouse;getEventButton()I",ordinal = 0, remap = false))
+
+ @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButton()I", ordinal = 0, remap = false))
public int redirectHandleMouseInput2() {
return TASmodClient.virtual.MOUSE.getEventMouseKey();
}
- @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE",target = "Lorg/lwjgl/input/Mouse;isButtonDown(I)Z",ordinal = 0, remap = false))
+
+ @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;isButtonDown(I)Z", ordinal = 0, remap = false))
public boolean redirectHandleMouseInput3(int i) {
return TASmodClient.virtual.isKeyDown(-100);
}
- @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE",target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I",ordinal = 0, remap = false))
+
+ @Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I", ordinal = 0, remap = false))
public int redirectHandleMouseInput4() {
return TASmodClient.virtual.MOUSE.getEventMouseScrollWheel();
}
diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinMinecraft.java b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinMinecraft.java
index e0dafeb5..9fca7861 100644
--- a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinMinecraft.java
+++ b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinMinecraft.java
@@ -9,6 +9,7 @@
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.virtual.VirtualInput;
+import com.minecrafttas.tasmod.virtual.VirtualInput.VirtualKeyboardInput;
import com.minecrafttas.tasmod.virtual.VirtualInput.VirtualMouseInput;
import com.minecrafttas.tasmod.virtual.event.VirtualKeyboardEvent;
import com.minecrafttas.tasmod.virtual.event.VirtualMouseEvent;
@@ -23,7 +24,7 @@ public class MixinMinecraft {
private GuiScreen currentScreen;
/**
- * Runs every frame.
+ *
Runs every frame.
* @see VirtualInput#update(GuiScreen)
* @param ci CBI
*/
@@ -32,30 +33,29 @@ public void playback_injectRunGameLoop(CallbackInfo ci) {
TASmodClient.virtual.update(currentScreen);
}
- // ============================ Keyboard
-
/**
- * Run at the start of run tick keyboard. Runs every tick.
- * @see VirtualInput.VirtualKeyboardInput#nextKeyboardTick()
+ *
Runs every tick.
+ *
+ *
Fills the keyboard and the mouse with the inputs that will be
+ * executed in {@link #playback_redirectKeyboardNext()} and {@link #playback_redirectMouseNext()} respectively.
+ * @see VirtualKeyboardInput#nextKeyboardTick()
+ * @see VirtualMouseInput#nextMouseTick()
* @param ci CBI
*/
- @Inject(method = "runTickKeyboard", at = @At(value = "HEAD"))
- public void playback_injectRunTickKeyboard(CallbackInfo ci) {
+ @Inject(method = "runTick", at = @At(value = "HEAD"))
+ public void playback_injectRunTick(CallbackInfo ci) {
/*
- * This "currentScreen == null" (and the one in runTickMouse) fixes
- * a particularly interesting bug where subticks are not recorded in GuiScreens...
- *
- * The reason this failed is because nextKeyboardTick is called twice in a row,
- * when a gui screen is open. The subticks are cleared after calling this
- * once, so having it be called twice essentially removes subticks alltogether.
+ * Both of these were previously in injectRunTickKeyboard/Mouse
+ * but moved to the beginning of runTick to fix #224
*/
- if (currentScreen == null) {
- TASmodClient.virtual.KEYBOARD.nextKeyboardTick();
- }
+ TASmodClient.virtual.KEYBOARD.nextKeyboardTick();
+ TASmodClient.virtual.MOUSE.nextMouseTick();
}
+ // ============================ Keyboard
+
/**
- * Redirects a {@link org.lwjgl.input.Keyboard#next()}. Starts running every tick and continues as long as there are {@link VirtualKeyboardEvent}s in {@link VirtualInput}
+ *
Redirects a {@link org.lwjgl.input.Keyboard#next()}. Starts running every tick and continues as long as there are {@link VirtualKeyboardEvent}s in {@link VirtualInput}
* @see VirtualInput.VirtualKeyboardInput#nextKeyboardSubtick()
* @return If {@link VirtualKeyboardEvent}s are present in {@link VirtualInput}
*/
@@ -124,18 +124,6 @@ public char playback_redirectGetEventCharacterDPK() {
// ============================ Mouse
- /**
- * Run at the start of run tick mouse. Runs every tick.
- * @see VirtualInput.VirtualMouseInput#nextMouseTick()
- * @param ci CBI
- */
- @Inject(method = "runTickMouse", at = @At(value = "HEAD"))
- public void playback_injectRunTickMouse(CallbackInfo ci) {
- if (currentScreen == null) {
- TASmodClient.virtual.MOUSE.nextMouseTick();
- }
- }
-
/**
* Redirects a {@link org.lwjgl.input.Mouse#next()}. Starts running every tick and continues as long as there are {@link VirtualMouseEvent}s in {@link VirtualInput}
* @see VirtualInput.VirtualMouseInput#nextMouseSubtick()
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java
index 683f5473..3c8261a6 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java
@@ -119,7 +119,7 @@ public class PlaybackControllerClient implements ClientPacketHandler, EventClien
/**
* The place where all inputs get stored
*/
- private BigArrayList inputs;
+ private BigArrayList inputs;
// private long startSeed = TASmod.ktrngHandler.getGlobalSeedClient(); // TODO Replace with Metadata extension
@@ -130,7 +130,7 @@ public class PlaybackControllerClient implements ClientPacketHandler, EventClien
public PlaybackControllerClient() {
tasFileDirectory = TASmodClient.tasfiledirectory;
- inputs = new BigArrayList(tasFileDirectory.resolve("temp").toAbsolutePath().toString());
+ inputs = new BigArrayList(tasFileDirectory.resolve("temp").toAbsolutePath().toString());
}
/**
@@ -263,7 +263,7 @@ private void startRecording() {
Float yaw = CAMERA_ANGLE.getCurrentYaw();
this.camera.set(pitch, yaw);
- inputs.add(new TickContainer());
+ inputs.add(new InputContainer());
}
}
@@ -417,7 +417,7 @@ public void onClientTickPost(Minecraft mc) {
private void recordNextTick() {
index++;
- TickContainer container = new TickContainer(keyboard.clone(), mouse.clone(), camera.clone());
+ InputContainer container = new InputContainer(keyboard.clone(), mouse.clone(), camera.clone());
if (inputs.size() <= index) {
if (inputs.size() < index) {
LOGGER.warn("Index is {} inputs bigger than the container!", index - inputs.size());
@@ -460,7 +460,7 @@ private void playbackNextTick() {
}
/* Continue condition */
else {
- TickContainer container = inputs.get(index); // Loads the new inputs from the container
+ InputContainer container = inputs.get(index); // Loads the new inputs from the container
this.keyboard = container.getKeyboard().clone();
this.mouse = container.getMouse().clone();
this.camera = container.getCameraAngle().clone();
@@ -483,21 +483,21 @@ public long index() {
return index;
}
- public BigArrayList getInputs() {
+ public BigArrayList getInputs() {
return inputs;
}
- public void setInputs(BigArrayList inputs) {
+ public void setInputs(BigArrayList inputs) {
this.setInputs(inputs, 0);
}
- public void setInputs(BigArrayList inputs, long index) {
+ public void setInputs(BigArrayList inputs, long index) {
try {
this.inputs.clearMemory();
} catch (IOException e) {
e.printStackTrace();
}
- this.inputs = new BigArrayList(tasFileDirectory + File.separator + "temp");
+ this.inputs = new BigArrayList(tasFileDirectory + File.separator + "temp");
SerialiserFlavorBase.addAll(this.inputs, inputs);
setIndex(index);
}
@@ -506,30 +506,30 @@ public void setIndex(long index) throws IndexOutOfBoundsException {
if (index <= size()) {
this.index = index;
if (state == TASstate.PLAYBACK) {
- TickContainer tickcontainer = inputs.get(index);
- this.keyboard = tickcontainer.getKeyboard();
- this.mouse = tickcontainer.getMouse();
- this.camera = tickcontainer.getCameraAngle();
+ InputContainer inputcontainer = inputs.get(index);
+ this.keyboard = inputcontainer.getKeyboard();
+ this.mouse = inputcontainer.getMouse();
+ this.camera = inputcontainer.getCameraAngle();
}
} else {
throw new IndexOutOfBoundsException("Index is bigger than the container");
}
}
- public TickContainer get(long index) {
- TickContainer tickcontainer = null;
+ public InputContainer get(long index) {
+ InputContainer inputcontainer = null;
try {
- tickcontainer = inputs.get(index);
+ inputcontainer = inputs.get(index);
} catch (IndexOutOfBoundsException e) {
return null;
}
- return tickcontainer;
+ return inputcontainer;
}
/**
- * @return The {@link TickContainer} at the current index
+ * @return The {@link InputContainer} at the current index
*/
- public TickContainer get() {
+ public InputContainer get() {
return get(index);
}
@@ -541,7 +541,7 @@ public void clear() {
} catch (IOException e) {
e.printStackTrace();
}
- inputs = new BigArrayList(tasFileDirectory + File.separator + "temp");
+ inputs = new BigArrayList(tasFileDirectory + File.separator + "temp");
index = 0;
}
@@ -585,7 +585,7 @@ public void setPlayUntil(int until) {
* @author Scribble
*
*/
- public static class TickContainer implements Serializable {
+ public static class InputContainer implements Serializable {
private VirtualKeyboard keyboard;
@@ -595,18 +595,18 @@ public static class TickContainer implements Serializable {
private CommentContainer comments;
- public TickContainer(VirtualKeyboard keyboard, VirtualMouse mouse, VirtualCameraAngle subticks) {
+ public InputContainer(VirtualKeyboard keyboard, VirtualMouse mouse, VirtualCameraAngle subticks) {
this(keyboard, mouse, subticks, new CommentContainer());
}
- public TickContainer(VirtualKeyboard keyboard, VirtualMouse mouse, VirtualCameraAngle camera, CommentContainer comments) {
+ public InputContainer(VirtualKeyboard keyboard, VirtualMouse mouse, VirtualCameraAngle camera, CommentContainer comments) {
this.keyboard = keyboard;
this.mouse = mouse;
this.cameraAngle = camera;
this.comments = comments;
}
- public TickContainer() {
+ public InputContainer() {
this(new VirtualKeyboard(), new VirtualMouse(), new VirtualCameraAngle());
}
@@ -639,14 +639,14 @@ public CommentContainer getComments() {
}
@Override
- public TickContainer clone() {
- return new TickContainer(keyboard, mouse, cameraAngle);
+ public InputContainer clone() {
+ return new InputContainer(keyboard, mouse, cameraAngle);
}
@Override
public boolean equals(Object other) {
- if (other instanceof TickContainer) {
- TickContainer container = (TickContainer) other;
+ if (other instanceof InputContainer) {
+ InputContainer container = (InputContainer) other;
return keyboard.equals(container.keyboard) && mouse.equals(container.mouse) && cameraAngle.equals(container.cameraAngle) && comments.equals(container.comments);
}
return super.equals(other);
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommand.java b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommand.java
index a34beee4..6d081494 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommand.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommand.java
@@ -12,7 +12,7 @@
import com.minecrafttas.mctcommon.file.AbstractDataFile;
import com.minecrafttas.mctcommon.registry.Registerable;
import com.minecrafttas.tasmod.TASmodClient;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
public class PlaybackFileCommand {
@@ -99,24 +99,24 @@ public void onDisable() {
public void onClear() {
};
- public void onRecord(long tick, TickContainer tickContainer) {
+ public void onRecord(long tick, InputContainer inputContainer) {
};
- public void onPlayback(long tick, TickContainer tickContainer) {
+ public void onPlayback(long tick, InputContainer inputContainer) {
};
- public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, TickContainer tickContainer) {
+ public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, InputContainer inputContainer) {
return null;
}
- public PlaybackFileCommandContainer onSerialiseEndlineComment(long currentTick, TickContainer tickContainer) {
+ public PlaybackFileCommandContainer onSerialiseEndlineComment(long currentTick, InputContainer inputContainer) {
return null;
}
- public void onDeserialiseInlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseInlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
}
- public void onDeserialiseEndlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseEndlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
}
public boolean isEnabled() {
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommandsRegistry.java b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommandsRegistry.java
index 29d472df..42737cf6 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommandsRegistry.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommandsRegistry.java
@@ -8,7 +8,7 @@
import com.minecrafttas.mctcommon.Configuration;
import com.minecrafttas.mctcommon.registry.AbstractRegistry;
import com.minecrafttas.tasmod.events.EventPlaybackClient;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
import com.minecrafttas.tasmod.registries.TASmodConfig;
@@ -93,7 +93,7 @@ public List getAll() {
}
@Override
- public void onRecordTick(long index, TickContainer container) {
+ public void onRecordTick(long index, InputContainer container) {
enabledExtensions.forEach(extension -> {
if (extension.isEnabled()) {
extension.onRecord(index, container);
@@ -102,7 +102,7 @@ public void onRecordTick(long index, TickContainer container) {
}
@Override
- public void onPlaybackTick(long index, TickContainer container) {
+ public void onPlaybackTick(long index, InputContainer container) {
enabledExtensions.forEach(extension -> {
if (extension.isEnabled()) {
extension.onPlayback(index, container);
@@ -110,7 +110,7 @@ public void onPlaybackTick(long index, TickContainer container) {
});
}
- public PlaybackFileCommandContainer handleOnSerialiseInline(long currentTick, TickContainer container) {
+ public PlaybackFileCommandContainer handleOnSerialiseInline(long currentTick, InputContainer container) {
PlaybackFileCommandContainer out = new PlaybackFileCommandContainer();
for (PlaybackFileCommandExtension extension : enabledExtensions) {
PlaybackFileCommandContainer extensionContainer = extension.onSerialiseInlineComment(currentTick, container);
@@ -121,7 +121,7 @@ public PlaybackFileCommandContainer handleOnSerialiseInline(long currentTick, Ti
return out;
}
- public PlaybackFileCommandContainer handleOnSerialiseEndline(long currentTick, TickContainer container) {
+ public PlaybackFileCommandContainer handleOnSerialiseEndline(long currentTick, InputContainer container) {
PlaybackFileCommandContainer out = new PlaybackFileCommandContainer();
for (PlaybackFileCommandExtension extension : enabledExtensions) {
PlaybackFileCommandContainer extensionContainer = extension.onSerialiseEndlineComment(currentTick, container);
@@ -132,7 +132,7 @@ public PlaybackFileCommandContainer handleOnSerialiseEndline(long currentTick, T
return out;
}
- public void handleOnDeserialiseInline(long currentTick, TickContainer deserialisedContainer, List> inlineFileCommands) {
+ public void handleOnDeserialiseInline(long currentTick, InputContainer deserialisedContainer, List> inlineFileCommands) {
PlaybackFileCommandContainer fileCommandContainer = new PlaybackFileCommandContainer(inlineFileCommands);
for (PlaybackFileCommandExtension extension : enabledExtensions) {
String[] fileCommandNames = extension.getFileCommandNames();
@@ -140,7 +140,7 @@ public void handleOnDeserialiseInline(long currentTick, TickContainer deserialis
}
}
- public void handleOnDeserialiseEndline(long currentTick, TickContainer deserialisedContainer, List> endlineFileCommands) {
+ public void handleOnDeserialiseEndline(long currentTick, InputContainer deserialisedContainer, List> endlineFileCommands) {
PlaybackFileCommandContainer fileCommandContainer = new PlaybackFileCommandContainer(endlineFileCommands);
for (PlaybackFileCommandExtension extension : enabledExtensions) {
String[] fileCommandNames = extension.getFileCommandNames();
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 ae6c25e7..f637fd63 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
@@ -12,7 +12,7 @@
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.events.EventPlaybackClient;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
@@ -75,7 +75,7 @@ public void onControllerStateChange(TASstate newstate, TASstate oldstate) {
}
@Override
- public void onRecord(long tick, TickContainer tickContainer) {
+ public void onRecord(long tick, InputContainer inputContainer) {
EntityPlayerSP player = Minecraft.getMinecraft().player;
MonitorContainer values = null;
if (player != null) {
@@ -97,7 +97,7 @@ public void onDisable() {
}
@Override
- public PlaybackFileCommandContainer onSerialiseEndlineComment(long currentTick, TickContainer tickContainer) {
+ public PlaybackFileCommandContainer onSerialiseEndlineComment(long currentTick, InputContainer inputContainer) {
PlaybackFileCommandContainer out = new PlaybackFileCommandContainer();
MonitorContainer monitoredValues = monitorContainer.get(currentTick);
PlaybackFileCommand command = new PlaybackFileCommand("desyncMonitor", monitoredValues.toStringArray());
@@ -108,7 +108,7 @@ public PlaybackFileCommandContainer onSerialiseEndlineComment(long currentTick,
}
@Override
- public void onDeserialiseEndlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseEndlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
List commandsEndline = fileCommandContainer.get("desyncMonitor");
if (commandsEndline == null || commandsEndline.isEmpty()) {
recordNull(tick);
@@ -128,7 +128,7 @@ public void recordNull(long tick) {
}
@Override
- public void onPlayback(long tick, TickContainer tickContainer) {
+ public void onPlayback(long tick, InputContainer inputContainer) {
currentValues = get(tick - 1);
}
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/LabelFileCommandExtension.java b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/LabelFileCommandExtension.java
index d2f880b5..8ebfe785 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/LabelFileCommandExtension.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/LabelFileCommandExtension.java
@@ -4,7 +4,7 @@
import java.nio.file.Path;
import com.dselent.bigarraylist.BigArrayList;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
@@ -43,7 +43,7 @@ public String[] getFileCommandNames() {
}
@Override
- public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, TickContainer tickContainer) {
+ public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, InputContainer inputContainer) {
PlaybackFileCommandContainer fileCommandContainer = new PlaybackFileCommandContainer();
if (label.size() != 0 && label.get(tick).get("label") != null) {
fileCommandContainer = label.get(tick);
@@ -52,14 +52,14 @@ public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, TickCont
}
@Override
- public void onDeserialiseInlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseInlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
if (fileCommandContainer.containsKey("label")) {
label.add(fileCommandContainer.split("label"));
}
}
@Override
- public void onPlayback(long tick, TickContainer tickContainer) {
+ public void onPlayback(long tick, InputContainer inputContainer) {
if (label.size() <= tick) {
return;
}
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/OptionsFileCommandExtension.java b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/OptionsFileCommandExtension.java
index 8923ab2b..48480334 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/OptionsFileCommandExtension.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/OptionsFileCommandExtension.java
@@ -5,7 +5,7 @@
import com.dselent.bigarraylist.BigArrayList;
import com.minecrafttas.tasmod.TASmod;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
@@ -45,7 +45,7 @@ public String[] getFileCommandNames() {
}
@Override
- public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, TickContainer tickContainer) {
+ public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, InputContainer inputContainer) {
PlaybackFileCommandContainer fileCommandContainer = new PlaybackFileCommandContainer();
if (hud.size() != 0 && hud.get(tick).get("hud") != null) {
fileCommandContainer = hud.get(tick);
@@ -54,14 +54,14 @@ public PlaybackFileCommandContainer onSerialiseInlineComment(long tick, TickCont
}
@Override
- public void onDeserialiseInlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseInlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
if (fileCommandContainer.containsKey("hud")) {
hud.add(fileCommandContainer.split("hud"));
}
}
@Override
- public void onPlayback(long tick, TickContainer tickContainer) {
+ public void onPlayback(long tick, InputContainer inputContainer) {
if (hud.size() <= tick) {
return;
}
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiser.java b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiser.java
index a110cbad..06e838d3 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiser.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiser.java
@@ -11,7 +11,7 @@
import com.dselent.bigarraylist.BigArrayList;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackLoadException;
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackSaveException;
import com.minecrafttas.tasmod.playback.tasfile.flavor.SerialiserFlavorBase;
@@ -56,32 +56,32 @@ public static void saveToFile(Path file, PlaybackControllerClient controller, St
}
/**
- * Saves a BigArrayList of {@link TickContainer TickContainers} to a file
+ * Saves a BigArrayList of {@link InputContainer InputContainers} to a file
*
* @param file The file to save the serialised inputs to
- * @param container The list of {@link TickContainer TickContainers} to use
+ * @param container The list of {@link InputContainer InputContainers} to use
* @param flavorName The name of the {@link SerialiserFlavorBase flavor} to use for the tasfile
* @throws PlaybackSaveException When a saving operation fails
*/
- public static void saveToFile(Path file, BigArrayList container, String flavorName) throws PlaybackSaveException {
+ public static void saveToFile(Path file, BigArrayList container, String flavorName) throws PlaybackSaveException {
saveToFile(file, container, flavorName, -1);
}
/**
- * Saves a BigArrayList of {@link TickContainer TickContainers} partially to a file
+ * Saves a BigArrayList of {@link InputContainer InputContainers} partially to a file
* @param path The file to save the serialised inputs to
- * @param container The list of {@link TickContainer TickContainers} to use
+ * @param container The list of {@link InputContainer InputContainers} to use
* @param flavorName The name of the {@link SerialiserFlavorBase flavor} to use for the tasfile
* @param stopIndex The index at which the serialiser stops. Use -1L to parse the entire file
* @throws PlaybackSaveException When a saving operation fails
*/
- public static void saveToFile(Path path, BigArrayList container, String flavorName, long stopIndex) throws PlaybackSaveException {
+ public static void saveToFile(Path path, BigArrayList container, String flavorName, long stopIndex) throws PlaybackSaveException {
if (path == null) {
throw new PlaybackSaveException("Save to file failed. No file specified");
}
if (container == null) {
- throw new PlaybackSaveException("Save to file failed. No tickcontainer list specified");
+ throw new PlaybackSaveException("Save to file failed. No inputcontainer list specified");
}
if (flavorName == null || flavorName.isEmpty()) {
@@ -120,19 +120,19 @@ public static void saveToFile(Path path, BigArrayList container,
}
/**
- * Loads a BigArrayList of {@link TickContainer TickContainers} from a file.
+ * Loads a BigArrayList of {@link InputContainer InputContainers} from a file.
* Tries to determine the {@link SerialiserFlavorBase flavor} by reading the header of the TASfile
*
* @param file The file to load from
- * @return The loaded BigArrayList of {@link TickContainer TickContainers}
+ * @return The loaded BigArrayList of {@link InputContainer InputContainers}
* @throws PlaybackLoadException If the file contains errors
* @throws IOException If the file could not be read
*/
- public static BigArrayList loadFromFile(Path file) throws PlaybackLoadException, IOException {
+ public static BigArrayList loadFromFile(Path file) throws PlaybackLoadException, IOException {
return loadFromFile(file, true);
}
- public static BigArrayList loadFromFile(Path file, boolean processExtensions) throws PlaybackLoadException, IOException {
+ public static BigArrayList loadFromFile(Path file, boolean processExtensions) throws PlaybackLoadException, IOException {
if (file == null) {
throw new PlaybackLoadException("Load from file failed. No file specified");
}
@@ -148,19 +148,19 @@ public static BigArrayList loadFromFile(Path file, boolean proces
}
/**
- * Loads a BigArrayList of {@link TickContainer TickContainers} from a file, with a specific flavor
+ * Loads a BigArrayList of {@link InputContainer InputContainers} from a file, with a specific flavor
*
* @param file The file to load from
* @param flavorName The name of the {@link SerialiserFlavorBase flavor} to use. If the detected flavor in the TASfile mismatches, a {@link PlaybackLoadException} is thrown
- * @return The loaded BigArrayList of {@link TickContainer TickContainers}
+ * @return The loaded BigArrayList of {@link InputContainer InputContainers}
* @throws PlaybackLoadException If the file contains errors
* @throws IOException If the file could not be read
*/
- public static BigArrayList loadFromFile(Path file, String flavorName) throws PlaybackLoadException, IOException {
+ public static BigArrayList loadFromFile(Path file, String flavorName) throws PlaybackLoadException, IOException {
return loadFromFile(file, flavorName, true);
}
- public static BigArrayList loadFromFile(Path file, String flavorName, boolean processExtensions) throws PlaybackLoadException, IOException {
+ public static BigArrayList loadFromFile(Path file, String flavorName, boolean processExtensions) throws PlaybackLoadException, IOException {
// If the flavor is null or empty, try to determine the flavor by reading the header
if (flavorName == null || flavorName.isEmpty()) {
@@ -186,15 +186,15 @@ public static BigArrayList loadFromFile(Path file, String flavorN
}
/**
- * Loads a BigArrayList of {@link TickContainer TickContainers} from a file, with a specific flavor
+ * Loads a BigArrayList of {@link InputContainer InputContainers} from a file, with a specific flavor
*
* @param file The file to load from
* @param flavor The {@link SerialiserFlavorBase flavor} to use. If the detected flavor in the TASfile mismatches, a {@link PlaybackLoadException} is thrown
- * @return The loaded BigArrayList of {@link TickContainer TickContainers}
+ * @return The loaded BigArrayList of {@link InputContainer InputContainers}
* @throws PlaybackLoadException If the file contains errors
* @throws IOException If the file could not be read
*/
- public static BigArrayList loadFromFile(Path file, SerialiserFlavorBase flavor) throws PlaybackLoadException, IOException {
+ public static BigArrayList loadFromFile(Path file, SerialiserFlavorBase flavor) throws PlaybackLoadException, IOException {
if (file == null) {
throw new PlaybackLoadException("Load from file failed. No file specified");
}
@@ -220,7 +220,7 @@ public static BigArrayList loadFromFile(Path file, SerialiserFlav
flavor.deserialiseHeader(headerLines);
// Deserialise main data
- BigArrayList deserialisedContainers = flavor.deserialise(lines, headerLines.size());
+ BigArrayList deserialisedContainers = flavor.deserialise(lines, headerLines.size());
return deserialisedContainers;
}
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiserOld.java b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiserOld.java
deleted file mode 100644
index 7aac7671..00000000
--- a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiserOld.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package com.minecrafttas.tasmod.playback.tasfile;
-
-import static com.minecrafttas.tasmod.TASmod.LOGGER;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-
-import com.dselent.bigarraylist.BigArrayList;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
-import com.minecrafttas.tasmod.playback.filecommands.builtin.DesyncMonitorFileCommandExtension;
-import com.minecrafttas.tasmod.util.FileThread;
-import com.minecrafttas.tasmod.util.LoggerMarkers;
-import com.minecrafttas.tasmod.virtual.VirtualCameraAngle;
-import com.minecrafttas.tasmod.virtual.VirtualKeyboard;
-import com.minecrafttas.tasmod.virtual.VirtualMouse;
-
-/**
- * Saves a given {@linkplain PlaybackControllerClient} to a file. Is also able to read an input container from a file.
- *
- * I plan to be backwards compatible so all the save functions have a V1 in their name by the time of writing this
- *
- * It also serializes the {@linkplain DesyncMonitorFileCommandExtension} from the input container
- *
- * Side: Client
- *
- * @author ScribbleLP
- *
- */
-@Deprecated
-public class PlaybackSerialiserOld {
-
- /**
- * A list of sections to check for in the playback file
- * @author ScribbleLP
- *
- */
- public enum SectionsV1 {
- TICKS("Ticks", ""),
- KEYBOARD("Keyboard", "(\\|Keyboard:)"),
- MOUSE("Mouse", "(\\|Mouse:)"),
- CAMERA("Camera", "(\\|Camera:)");
-
- private String name;
- private String regex;
-
- private SectionsV1(String nameIn, String regexIn) {
- name = nameIn;
- regex = regexIn;
- }
-
- public String getName() {
- return name;
- }
-
- public String getRegex() {
- return regex;
- }
-
- public static String getRegexString() {
- String out = "";
- for (SectionsV1 section : values()) {
- if (!section.getRegex().isEmpty()) {
- String seperator = "|";
- if (values().length - 1 == section.ordinal()) {
- seperator = "";
- }
- out = out.concat(section.getRegex() + seperator);
- }
- }
- return out;
- }
- }
-
- /**
- * Saves all inputs of the input container
- * @param file Where to save the container
- * @param container The container to save
- * @throws IOException When the input container is empty
- */
- public void saveToFileV1(File file, PlaybackControllerClient container) throws IOException {
- saveToFileV1Until(file, container, -1);
- }
-
- /**
- * Saves inputs up to a certain index of the input container
- * @param file Where to save the container
- * @param container The container to save
- * @param index index until the inputs get saved
- * @throws IOException When the input container is empty
- */
- public void saveToFileV1Until(File file, PlaybackControllerClient container, long index) throws IOException {
- LOGGER.debug(LoggerMarkers.Playback, "Saving playback controller to file {}", file);
- if (container.size() == 0) {
- throw new IOException("There are no inputs to save to a file");
- }
- FileThread fileThread = new FileThread(file.toPath(), false);
-// FileThread monitorThread= new FileThread(new File(file, "../"+file.getName().replace(".mctas", "")+".mon"), false);
-
- fileThread.start();
-// monitorThread.start();
-
-// fileThread.addLine("################################################# TASFile ###################################################\n"
-// + "# Version:1 #\n"
-// + "# This file was generated using the Minecraft TASMod #\n"
-// + "# #\n"
-// + "# Any errors while reading this file will be printed out in the console and the chat #\n"
-// + "# #\n"
-// + "#------------------------------------------------ Header ---------------------------------------------------#\n"
-// + "#Author:" + container.getAuthors() + "\n"
-// + "# #\n"
-// + "#Title:" + container.getTitle() + "\n"
-// + "# #\n"
-// + "#Playing Time:" + container.getPlaytime() + "\n"
-// + "# #\n"
-// + "#Rerecords:"+container.getRerecords() + "\n"
-// + "# #\n"
-// + "#----------------------------------------------- Settings --------------------------------------------------#\n"
-// + "#StartPosition:"+container.getStartLocation()+"\n"
-// + "# #\n"
-// + "#StartSeed:" + container.getStartSeed() + "\n"
-// + "#############################################################################################################\n"
-// + "#Comments start with \"//\" at the start of the line, comments with # will not be saved\n");
-
- BigArrayList ticks = container.getInputs();
-// Map>> cbytes= container.getControlBytes();
-// Map> comments = container.getComments();
-
-// for (int i = 0; i < ticks.size(); i++) {
-// if(i==index) {
-// break;
-// }
-//
-// // Add comments
-// if(comments.containsKey(i)) {
-// List multiLine=comments.get(i);
-// multiLine.forEach(comment -> {
-// fileThread.addLine("//"+comment+"\n");
-// });
-// }
-
- // Add controlbytes
-// if(cbytes.containsKey(i)) {
-// List> cbytelist= cbytes.get(i);
-// String cbyteString= ControlByteHandler.toString(cbytelist);
-// if(!cbyteString.isEmpty()) {
-// fileThread.addLine(cbyteString);
-// }
-// }
-//
-// // Add a data line
-// TickContainer tickInput = ticks.get(i);
-// fileThread.addLine(tickInput.toString() + "~&\t\t\t\t//Monitoring:"+container.desyncMonitor.get(i)+"\n");
-// }
-// fileThread.close();
- }
-
- public int getFileVersion(File file) throws IOException {
- LOGGER.trace(LoggerMarkers.Playback, "Retrieving file version from {}", file);
- List lines = FileUtils.readLines(file, Charset.defaultCharset());
- for (String line : lines) {
- if (line.contains("Version")) {
- String trimmed = line.replaceAll("#|\t", "");
- int tick = 0;
- try {
- tick = Integer.parseInt(trimmed.split(":")[1]);
- } catch (NumberFormatException e) {
- throw new IOException("Can't read the file version: " + trimmed);
- }
- return tick;
- }
- }
- return 0;
- }
-
- public PlaybackControllerClient fromEntireFileV1(File file) throws IOException {
- LOGGER.debug(LoggerMarkers.Playback, "Loading playback controller to file {}", file);
- List lines = FileUtils.readLines(file, StandardCharsets.UTF_8);
-
- File monitorFile = new File(file, "../" + file.getName().replace(".mctas", "") + ".mon");
-
- List monitorLines = new ArrayList<>();
-
- // Read the legacy monitoring file system. Still reads the file but deletes it afterwards
- if (monitorFile.exists()) {
- monitorLines = FileUtils.readLines(monitorFile, StandardCharsets.UTF_8);
- monitorFile.delete();
- }
- boolean oldmonfileLoaded = !monitorLines.isEmpty();
-
- PlaybackControllerClient controller = new PlaybackControllerClient();
-
- String author = "Insert author here";
-
- String title = "Insert TAS category here";
-
- String playtime = "00:00.0";
-
- int rerecords = 0;
-
- // No default start location
- String startLocation = "";
-
- // Default the start seed to the current global ktrng seed. If KTRNG is not loaded, defaults to 0
- long startSeed/*=TASmod.ktrngHandler.getGlobalSeedClient()*/;
-
- // Clear the current container before reading new data
- controller.clear();
-
- int linenumber = 0; //The current line number
-
- for (String line : lines) {
- linenumber++;
- int tickcount = (int) controller.getInputs().size();
- // Read out header
- if (line.startsWith("#")) {
- // Read author tag
- if (line.startsWith("#Author:")) {
- author = line.split(":")[1];
- // Read title tag
- } else if (line.startsWith("#Title:")) {
- title = line.split(":")[1];
- // Read playtime
- } else if (line.startsWith("#Playing Time:")) {
- playtime = line.split("Playing Time:")[1];
- // Read rerecords
- } else if (line.startsWith("#Rerecords:")) {
- rerecords = Integer.parseInt(line.split(":")[1]);
- // Read start position
- } else if (line.startsWith("#StartPosition:")) {
- startLocation = line.replace("#StartPosition:", "");
- // Read start seed
- } else if (line.startsWith("#StartSeed:")) {
- startSeed = Long.parseLong(line.replace("#StartSeed:", ""));
- }
- // Read control bytes
- } else if (line.startsWith("$") && line.replace('$', ' ').trim().contains(" ")) {
- String[] sections = line.replace('$', ' ').trim().split(" ", 2);
- if (sections.length == 0)
- continue;
- String control = sections[0];
- String[] params = sections[1].split(" ");
-// List> cbytes = controller.getControlBytes().getOrDefault(tickcount, new ArrayList<>());
-// cbytes.add(Pair.of(control, params));
-// controller.getControlBytes().put(tickcount, cbytes);
- //Read comments
- } else if (line.startsWith("//")) {
-// List commentList = controller.getComments().getOrDefault(tickcount, new ArrayList<>());
-// commentList.add(line.replace("//", ""));
-// controller.getComments().put(tickcount, commentList);
- //Read data
- } else {
-
- // Splitting the line into a data- and commentPart, the comment part will most likely contain the Monitoring
- String dataPart = line;
- String commentPart = "";
- if (line.contains("~&")) {
- String[] splitComments = line.split("~&");
- dataPart = splitComments[0];
- commentPart = splitComments[1];
- }
- String[] sections = dataPart.split(SectionsV1.getRegexString());
-
- if (sections.length != SectionsV1.values().length) {
- throw new IOException("Error in line " + linenumber + ". Cannot read the line correctly");
- }
-
-// controller.getInputs().add(new TickInputContainer(readTicks(sections[0], linenumber), readKeyboard(sections[1], linenumber), readMouse(sections[2], linenumber), readSubtick(sections[3], linenumber)));
-
- if (!oldmonfileLoaded) {
- String[] commentData = commentPart.split("Monitoring:");
- if (commentData.length == 2) {
- monitorLines.add(commentData[1]);
- }
- }
- }
- }
-// controller.setAuthors(author);
-// controller.setTitle(title);
-// controller.setPlaytime(playtime);
-// controller.setRerecords(rerecords);
-// controller.setStartLocation(startLocation);
-// controller.setStartSeed(startSeed);
- if (!monitorLines.isEmpty()) {
-// controller.desyncMonitor = new DesyncMonitoringFileCommand(controller, monitorLines);
- }
-
- //If an old monitoring file is loaded, save the file immediately to not loose any data.
- if (oldmonfileLoaded) {
- saveToFileV1(file, controller);
- }
-
- return controller;
- }
-
- private int readTicks(String section, int linenumber) throws IOException {
- int ticks = 0;
- try {
- ticks = Integer.parseInt(section);
- } catch (NumberFormatException e) {
- throw new IOException(section + " is not a recognised number in line " + linenumber);
- }
- return ticks;
- }
-
- private VirtualKeyboard readKeyboard(String section, int linenumber) throws IOException {
- VirtualKeyboard keyboard = new VirtualKeyboard();
-
- // Remove the prefix
- section = section.replace("Keyboard:", "");
-
- // Split in keys and characters
- String[] keys = section.split(";");
-
- // If there is nothing, return the empty keyboard
- if (keys.length == 0) {
- return keyboard;
- }
-
- // Check if the keylist is empty
- if (!keys[0].isEmpty()) {
-
- // Split multiple keys
- String[] splitKeys = keys[0].split(",");
-
- for (String key : splitKeys) {
-
-// VirtualKey vkey = null;
-// // Check if the key is a keycode
-// if (isNumeric(key)) {
-// vkey = keyboard.get(Integer.parseInt(key));
-// } else {
-// vkey = keyboard.get(key);
-// }
-//
-// if (vkey == null) {
-// throw new IOException(key + " is not a recognised keyboard key in line " + linenumber);
-// }
-//
-// vkey.setPressed(true);
- }
- }
-
- char[] chars = {};
- //Check if the characterlist is empty
- if (keys.length == 2) {
- chars = keys[1].replace("\\n", "\n").toCharArray(); //Replacing the "\n" in lines to the character \n
- }
-
- for (char onechar : chars) {
-// keyboard.addChar(onechar);
- }
- return keyboard;
- }
-
- private VirtualMouse readMouse(String section, int linenumber) throws IOException {
- VirtualMouse mouse = new VirtualMouse();
-
- // Remove the prefix
- section = section.replace("Mouse:", "");
-
- //Split into buttons and paths...
- String buttons = section.split(";")[0];
- String path = section.split(";")[1];
-
- //Check whether the button is empty
- if (!buttons.isEmpty()) {
-
- //Splitting multiple buttons
- String[] splitButtons = buttons.split(",");
- for (String button : splitButtons) {
-
-// VirtualKey vkey = null;
-// // Check if the key is a keycode
-// if (isNumeric(button)) {
-// vkey = mouse.get(Integer.parseInt(button));
-// } else {
-// vkey = mouse.get(button);
-// }
-// if (vkey == null) {
-// throw new IOException(button + " is not a recognised mouse key in line " + linenumber);
-// }
-// mouse.get(button).setPressed(true);
- }
- }
-// mouse.setPath(readPath(path, linenumber, mouse));
-
- return mouse;
- }
-
-// private List readPath(String section, int linenumber, VirtualMouse mouse) throws IOException {
-// List path = new ArrayList();
-//
-// section = section.replace("[", "").replace("]", "");
-// String[] pathNodes = section.split("->");
-//
-// for (String pathNode : pathNodes) {
-// String[] split = pathNode.split(",");
-//
-// int length=split.length;
-// int scrollWheel = 0;
-// int cursorX = 0;
-// int cursorY = 0;
-// try {
-// scrollWheel = Integer.parseInt(split[length-3]);
-// cursorX = Integer.parseInt(split[length-2]);
-// cursorY = Integer.parseInt(split[length-1]);
-// } catch (NumberFormatException e) {
-// throw new IOException("'" + pathNode + "' couldn't be read in line " + linenumber+": Something is not a number");
-// } catch (ArrayIndexOutOfBoundsException e) {
-// throw new IOException("'" + pathNode + "' couldn't be read in line " + linenumber+": Something is missing or is too much");
-// }
-// PathNode node = mouse.new PathNode();
-// for (int i=0; i out, LinkedHashMapTree
*
* serialise
- * └── {@link #serialiseContainer(BigArrayList, TickContainer)}
+ * └── {@link #serialiseContainer(BigArrayList, InputContainer)}
* ├── {@link #serialiseKeyboard(VirtualKeyboard)}
* │ └── {@link #serialiseKeyboardSubtick(VirtualKeyboard)}
* ├── {@link #serialiseMouse(VirtualMouse)}
@@ -307,9 +309,11 @@ protected void serialiseMetadataValues(List out, LinkedHashMap out, LinkedHashMap serialise(BigArrayList inputs, long toTick) {
+ public BigArrayList serialise(BigArrayList inputs, long toTick) {
BigArrayList out = new BigArrayList<>();
for (int i = 0; i < inputs.size(); i++) {
@@ -328,20 +332,20 @@ public BigArrayList serialise(BigArrayList inputs, long t
break;
}
currentTick = i;
- TickContainer container = inputs.get(i).clone();
+ InputContainer container = inputs.get(i).clone();
serialiseContainer(out, container);
- previousTickContainer = container;
+ previousInputContainer = container;
}
return out;
}
/**
- * Main serialising method of a single {@link TickContainer}
+ * Main serialising method of a single {@link InputContainer}
*
* @param out The list of serialised lines, passed in by reference
- * @param container The {@link TickContainer} to serialise
+ * @param container The {@link InputContainer} to serialise
*/
- protected void serialiseContainer(BigArrayList out, TickContainer container) {
+ protected void serialiseContainer(BigArrayList out, InputContainer container) {
currentLine = out.size() - 1;
List serialisedKeyboard = serialiseKeyboard(container.getKeyboard());
List serialisedMouse = serialiseMouse(container.getMouse());
@@ -549,6 +553,15 @@ protected List serialiseInlineComments(List inlineComments, List
return out;
}
+ /**
+ * Comment format for inline comments
+ *
Example
+ *
+ * // Inline comment
+ *
+ * @param comment Content in the comment
+ * @return The inline comment
+ */
protected String serialiseInlineComment(String comment) {
return String.format("// %s", comment);
}
@@ -613,6 +626,15 @@ protected List serialiseEndlineComments(List endlineComments, Li
return out;
}
+ /**
+ * Comment format for endline comments
+ *
Example
+ *
+ * // Endline comment
+ *
+ * @param comment Content in the comment
+ * @return The endline comment
+ */
protected String serialiseEndlineComment(String comment) {
return String.format("// %s", comment);
}
@@ -895,7 +917,7 @@ public List extractHeader(BigArrayList lines) {
/**
* Deserialise header lines
*
- * deserialiseHeader
+ * deserialiseHeader
* ├── {@link #deserialiseMetadata(List)}
* └── {@link #deserialiseFileCommandNames(List)}
*
@@ -977,14 +999,28 @@ protected void deserialiseFileCommandNames(List headerLines) {
}
/**
- * Deserialises the input part of the TASfile
+ * Deserialises the input part of the TASfile
*
- * @param lines The serialised lines of the TASfile
+ *
+ * deserialise
+ * ├── {@link #extractContainer(List, BigArrayList, long)}
+ * └── {@link #deserialiseContainer(BigArrayList, List)}
+ * ├── {@link #deserialiseMultipleInlineComments(List, List)}
+ * │ └── {@link #deserialiseInlineComment(String, List)}
+ * │ └── {@link #deserialiseFileCommandsInline(String, List)}
+ * ├── {@link #splitInputs(List, List, List, List, List, List)}
+ * │ └── {@link #deserialiseEndlineComment(String, List)}
+ * │ └── {@link #deserialiseFileCommandsEndline(String, List)}
+ * ├── {@link #deserialiseKeyboard(List)}
+ * ├── {@link #deserialiseMouse(List)}
+ * └── {@link #deserialiseCameraAngle(List)}
+ *
+ * @param lines The serialised lines of the TASfile
* @param startPos The position when the header ends and the inputs start
- * @return A list of {@link TickContainer TickContainers}
+ * @return A list of {@link InputContainer InputContainers}
*/
- public BigArrayList deserialise(BigArrayList lines, long startPos) {
- BigArrayList out = new BigArrayList<>();
+ public BigArrayList deserialise(BigArrayList lines, long startPos) {
+ BigArrayList out = new BigArrayList<>();
for (long i = startPos; i < lines.size(); i++) {
List container = new ArrayList<>();
// Extract the tick and set the index
@@ -994,13 +1030,13 @@ public BigArrayList deserialise(BigArrayList lines, long
deserialiseContainer(out, container);
currentTick++;
}
- previousTickContainer = null;
+ previousInputContainer = null;
return out;
}
protected enum ExtractPhases {
/**
- * InlineComment phase.
+ * Inline comment phase.
*
*
* ---
@@ -1029,8 +1065,12 @@ protected enum ExtractPhases {
* Subtick phase. Start with a tabulator, then a number, then a | character
*
*
- * --- 1||RC;0,1580,658|17.85;-202.74799\t\t// This is an endline comment
- * 2||;0,1580,658|17.85;-202.74799 --- Can have multiple subticks
+ * ---
+ * 1||RC;0,1580,658|17.85;-202.74799 // This is an endline comment
+ * 2||;0,1580,658|17.85;-202.74799
+ * ---
+ *
+ * Can have multiple subticks
*/
SUBTICK,
/**
@@ -1156,7 +1196,7 @@ protected long extractContainer(List extracted, BigArrayList lin
return startPos + counter - 1;
}
- protected void deserialiseContainer(BigArrayList out, List containerLines) {
+ protected void deserialiseContainer(BigArrayList out, List containerLines) {
List inlineComments = new ArrayList<>();
List tickLines = new ArrayList<>();
@@ -1180,20 +1220,20 @@ protected void deserialiseContainer(BigArrayList out, List keyboardStrings) {
String[] keys = matcher.group(1).split(",");
char[] chars = matcher.group(2).toCharArray();
- int[] keycodes = deserialiseVirtualKeyboardKey(keys);
+ Set keycodes = deserialiseVirtualKeyboardKey(keys);
out.updateFromState(keycodes, chars);
} else {
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Keyboard could not be read. Probably a missing semicolon: %s", line);
@@ -1305,8 +1345,8 @@ protected VirtualMouse deserialiseMouse(List mouseStrings) {
VirtualMouse out = new VirtualMouse();
currentSubtick = 0;
- Integer previousCursorX = previousTickContainer == null ? null : previousTickContainer.getMouse().getCursorX();
- Integer previousCursorY = previousTickContainer == null ? null : previousTickContainer.getMouse().getCursorY();
+ Integer previousCursorX = previousInputContainer == null ? null : previousInputContainer.getMouse().getCursorX();
+ Integer previousCursorY = previousInputContainer == null ? null : previousInputContainer.getMouse().getCursorY();
for (String line : mouseStrings) {
Matcher matcher = extract("(.*?);(.+)", line);
@@ -1314,7 +1354,7 @@ protected VirtualMouse deserialiseMouse(List mouseStrings) {
String[] buttons = matcher.group(1).split(",");
String[] functions = matcher.group(2).split(",");
- int[] keycodes = deserialiseVirtualMouseKey(buttons);
+ Set keycodes = deserialiseVirtualMouseKey(buttons);
int scrollwheel;
Integer cursorX;
Integer cursorY;
@@ -1340,11 +1380,11 @@ protected VirtualMouse deserialiseMouse(List mouseStrings) {
}
protected VirtualCameraAngle deserialiseCameraAngle(List cameraAngleStrings) {
- VirtualCameraAngle out = new VirtualCameraAngle();
+ VirtualCameraAngle out = new VirtualCameraAngle(null, null, false);
currentSubtick = 0;
- Float previousPitch = previousTickContainer == null ? null : previousTickContainer.getCameraAngle().getPitch();
- Float previousYaw = previousTickContainer == null ? null : previousTickContainer.getCameraAngle().getYaw();
+ Float previousYaw = previousInputContainer == null ? null : previousInputContainer.getCameraAngle().getYaw();
+ Float previousPitch = previousInputContainer == null ? null : previousInputContainer.getCameraAngle().getPitch();
for (String line : cameraAngleStrings) {
Matcher matcher = extract("(.+?);(.+)", line);
@@ -1363,6 +1403,9 @@ protected VirtualCameraAngle deserialiseCameraAngle(List cameraAngleStri
cameraPitch = deserialiseRelativeFloat("camera pitch", cameraPitchString, previousPitch);
out.updateFromState(cameraPitch, cameraYaw);
+
+ previousYaw = cameraYaw;
+ previousPitch = cameraPitch;
} else {
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Camera is missing a semicolon");
}
@@ -1371,42 +1414,51 @@ protected VirtualCameraAngle deserialiseCameraAngle(List cameraAngleStri
return out;
}
- protected int[] deserialiseVirtualKeyboardKey(String[] keyString) {
- int[] out = new int[keyString.length];
+ protected Set deserialiseVirtualKeyboardKey(String[] keyString) {
+ Set out = new HashSet<>();
for (int i = 0; i < keyString.length; i++) {
String key = keyString[i];
- out[i] = deserialiseVirtualKey(key, VirtualKey.ZERO, (vkey) -> {
+ Integer keycode = deserialiseVirtualKey(key, (vkey) -> {
if (vkey < 0) {
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Keyboard section contains a mouse key: %s", VirtualKey.get(vkey));
}
});
+
+ if (out.contains(keycode))
+ throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Keyboard has a duplicate key press");
+
+ if (keycode != null)
+ out.add(keycode);
}
return out;
}
- protected int[] deserialiseVirtualMouseKey(String[] keyString) {
- int[] out = new int[keyString.length];
+ protected Set deserialiseVirtualMouseKey(String[] keyString) {
+ Set out = new HashSet<>();
for (int i = 0; i < keyString.length; i++) {
String key = keyString[i];
- out[i] = deserialiseVirtualKey(key, VirtualKey.MOUSEMOVED, (vkey) -> {
+ Integer keycode = deserialiseVirtualKey(key, (vkey) -> {
if (vkey >= 0) {
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Mouse section contains a keyboard key: %s", VirtualKey.get(vkey));
}
});
+
+ if (out.contains(keycode))
+ throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Mouse has a duplicate key press");
+
+ if (keycode != null)
+ out.add(keycode);
}
return out;
}
- protected int deserialiseVirtualKey(String key, VirtualKey defaultKey, WrongKeyCheck keyValidator) {
+ protected Integer deserialiseVirtualKey(String key, WrongKeyCheck keyValidator) {
Integer vkey = null;
- /* If no key is pressed, then a zero key will be used for the state.
- * This zero key is either VirtualKey.ZERO on a keyboard or VirtualKey.MOUSEMOVED on a mouse,
- * hence the parameter */
if (key.isEmpty()) {
- vkey = defaultKey.getKeycode();
+ return null;
}
/* Instead of keynames such as W, A, S, KEY_1, NUMPAD3 you can also write the numerical keycodes
* into the tasfile, e.g. 17, 30, 31, 2, 81. This enables TASmod to support every current and future
@@ -1464,30 +1516,29 @@ protected float parseFloat(String name, String floatstring) {
}
protected Float deserialiseRelativeFloat(String name, String floatstring, Float previous) {
- if (floatstring == null) {
+ if (floatstring == null)
return null;
- }
float out = 0;
if (floatstring.startsWith("~")) {
floatstring = floatstring.replace("~", "");
float relative = parseFloat(name, floatstring);
- if (previous != null) {
+ if (previous != null)
out = previous + relative;
- } else {
+ else
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Can't process relative value ~%s in %s. Previous value for comparing is not available", floatstring, name);
- }
- } else {
+
+ } else
out = parseFloat(name, floatstring);
- }
+
return out;
}
protected void splitInputs(List lines, List serialisedKeyboard, List serialisedMouse, List serialisedCameraAngle, List commentsAtEnd, List> endlineFileCommands) {
String previousCamera = null;
- if (previousTickContainer != null) {
- VirtualCameraAngle camera = previousTickContainer.getCameraAngle();
+ if (previousInputContainer != null) {
+ VirtualCameraAngle camera = previousInputContainer.getCameraAngle();
previousCamera = String.format("%s;%s", camera.getYaw(), camera.getPitch());
}
@@ -1697,4 +1748,9 @@ protected String charListToString(List charList) {
}
return charString;
}
+
+ @Override
+ public String toString() {
+ return getExtensionName();
+ }
}
diff --git a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/builtin/AlphaFlavor.java b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/builtin/AlphaFlavor.java
index 81ced51b..5d73e12a 100644
--- a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/builtin/AlphaFlavor.java
+++ b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/builtin/AlphaFlavor.java
@@ -11,12 +11,14 @@
import static com.minecrafttas.tasmod.playback.metadata.builtin.StartpositionMetadataExtension.StartPositionFields.Z;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Set;
import java.util.regex.Matcher;
import com.dselent.bigarraylist.BigArrayList;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.metadata.PlaybackMetadata;
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackLoadException;
@@ -403,7 +405,7 @@ protected VirtualKeyboard deserialiseKeyboard(List keyboardStrings) {
String[] keys = matcher.group(1).split(",");
char[] chars = matcher.group(2).toCharArray();
- int[] keycodes = deserialiseVirtualKeyboardKey(keys);
+ Set keycodes = deserialiseVirtualKeyboardKey(keys);
out.updateFromState(keycodes, chars);
} else {
throw new PlaybackLoadException(currentLine, currentTick, currentSubtick, "Keyboard could not be read. Probably a missing semicolon: %s", line);
@@ -414,8 +416,8 @@ protected VirtualKeyboard deserialiseKeyboard(List keyboardStrings) {
}
@Override
- public BigArrayList deserialise(BigArrayList lines, long startPos) {
- BigArrayList out = new BigArrayList<>();
+ public BigArrayList deserialise(BigArrayList lines, long startPos) {
+ BigArrayList out = new BigArrayList<>();
for (long i = startPos; i < lines.size(); i++) {
if (lines.get(i).startsWith("#")) {
@@ -429,7 +431,7 @@ public BigArrayList deserialise(BigArrayList lines, long
deserialiseContainer(out, container);
currentTick++;
}
- previousTickContainer = null;
+ previousInputContainer = null;
return out;
}
@@ -450,8 +452,8 @@ protected VirtualMouse deserialiseMouse(List mouseStrings) {
//Splitting multiple buttons
String[] splitButtons = buttons.split(",");
- int[] keys = deserialiseVirtualMouseKey(splitButtons);
- mouse.updateFromState(keys, 0, 0, 0);
+ Set keycodes = deserialiseVirtualMouseKey(splitButtons);
+ mouse.updateFromState(keycodes, 0, 0, 0);
}
readPath(path, mouse);
@@ -479,7 +481,7 @@ protected void readPath(String section, VirtualMouse mouse) {
} catch (ArrayIndexOutOfBoundsException e) {
throw new PlaybackLoadException("'" + pathNode + "' couldn't be read in line " + currentLine + ": Something is missing or is too much");
}
- List keyList = new ArrayList<>();
+ Set keyList = new HashSet<>();
for (int i = 0; i < length - 3; i++) {
String key = split[i];
Integer keyCode = VirtualKey.getKeycode(key);
@@ -488,11 +490,7 @@ protected void readPath(String section, VirtualMouse mouse) {
}
keyList.add(keyCode);
}
- int[] keyListArray = new int[keyList.size()];
- for (int i = 0; i < keyList.size(); i++) {
- keyListArray[i] = keyList.get(i);
- }
- mouse.updateFromState(keyListArray, scrollWheel, cursorX, cursorY);
+ mouse.updateFromState(keyList, scrollWheel, cursorX, cursorY);
}
}
@@ -501,8 +499,8 @@ protected VirtualCameraAngle deserialiseCameraAngle(List cameraAngleStri
VirtualCameraAngle out = new VirtualCameraAngle();
currentSubtick = 0;
- Float previousPitch = previousTickContainer == null ? null : previousTickContainer.getCameraAngle().getPitch();
- Float previousYaw = previousTickContainer == null ? null : previousTickContainer.getCameraAngle().getYaw();
+ Float previousPitch = previousInputContainer == null ? null : previousInputContainer.getCameraAngle().getPitch();
+ Float previousYaw = previousInputContainer == null ? null : previousInputContainer.getCameraAngle().getYaw();
for (String line : cameraAngleStrings) {
Matcher matcher = extract("Camera:(.+?);(.+)", line);
diff --git a/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java b/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java
index 85b2f581..c2d1d98d 100644
--- a/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java
+++ b/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java
@@ -20,7 +20,7 @@
import com.minecrafttas.tasmod.networking.TASmodBufferBuilder;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.tasfile.PlaybackSerialiser;
import com.minecrafttas.tasmod.registries.TASmodAPIRegistry;
import com.minecrafttas.tasmod.registries.TASmodPackets;
@@ -166,7 +166,7 @@ public static void loadstate(String nameOfSavestate) throws Exception {
File targetfile = new File(savestateDirectory, nameOfSavestate + ".mctas");
- BigArrayList savestateContainerList;
+ BigArrayList savestateContainerList;
if (targetfile.exists()) {
savestateContainerList = PlaybackSerialiser.loadFromFile(targetfile.toPath(), state != TASstate.PLAYBACK);
@@ -254,8 +254,8 @@ public static void loadstate(String nameOfSavestate) throws Exception {
});
}
- private static void preload(BigArrayList containerList, long index) {
- TickContainer containerToPreload = containerList.get(index);
+ private static void preload(BigArrayList containerList, long index) {
+ InputContainer containerToPreload = containerList.get(index);
TASmodClient.virtual.preloadInput(containerToPreload.getKeyboard(), containerToPreload.getMouse(), containerToPreload.getCameraAngle());
TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.onPlaybackTick(index, containerToPreload);
diff --git a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualInput.java b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualInput.java
index 63272b5e..a2bd6a16 100644
--- a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualInput.java
+++ b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualInput.java
@@ -271,7 +271,7 @@ public void updateNextKeyboard(int keycode, boolean keystate, char character, bo
* Used to load {@link #nextKeyboard} into {@link #currentKeyboard}, creating
* {@link VirtualKeyboardEvent}s in the process.
*
- * @see MixinMinecraft#playback_injectRunTickKeyboard(org.spongepowered.asm.mixin.injection.callback.CallbackInfo)
+ * @see MixinMinecraft#playback_injectRunTick(CallbackInfo)
*/
public void nextKeyboardTick() {
nextKeyboard.deepCopyFrom((VirtualKeyboard) EventListenerRegistry.fireEvent(EventVirtualInput.EventVirtualKeyboardTick.class, nextKeyboard));
@@ -431,7 +431,7 @@ public void updateNextMouse(int keycode, boolean keystate, int scrollwheel, int
* Used to load {@link #nextMouse} into {@link #currentMouse}, creating
* {@link VirtualMouseEvent}s in the process.
*
- * @see MixinMinecraft#playback_injectRunTickMouse(org.spongepowered.asm.mixin.injection.callback.CallbackInfo)
+ * @see MixinMinecraft#playback_injectRunTick(CallbackInfo)
*/
public void nextMouseTick() {
nextMouse.deepCopyFrom((VirtualMouse) EventListenerRegistry.fireEvent(EventVirtualInput.EventVirtualMouseTick.class, nextMouse));
diff --git a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualKeyboard.java b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualKeyboard.java
index dbfd6da0..b35260cc 100644
--- a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualKeyboard.java
+++ b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualKeyboard.java
@@ -159,17 +159,15 @@ public void updateFromEvent(VirtualKey key, boolean keystate, char keycharacter,
* updateFromState is used when creating a VirtualKeyboard by deserialising the TASfile,
* as the inputs in the TASfile are stored in states.
*
- * @param keycodes An array of keycodes, that replaces {@link Subtickable#pressedKeys}
+ * @param keycodes A set of keycodes, that replaces {@link Subtickable#pressedKeys}
* @param chars An array of characters, that replaces {@link #charList}
* @see SerialiserFlavorBase#deserialiseKeyboard
*/
- public void updateFromState(int[] keycodes, char[] chars) {
+ public void updateFromState(Set keycodes, char[] chars) {
createSubtick();
this.pressedKeys.clear();
- for (int i : keycodes) {
- this.pressedKeys.add(i);
- }
+ this.pressedKeys.addAll(keycodes);
this.charList.clear();
for (char c : chars) {
diff --git a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualMouse.java b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualMouse.java
index 3d4efab5..76bfc0f0 100644
--- a/src/main/java/com/minecrafttas/tasmod/virtual/VirtualMouse.java
+++ b/src/main/java/com/minecrafttas/tasmod/virtual/VirtualMouse.java
@@ -132,19 +132,17 @@ public void updateFromEvent(VirtualKey key, boolean keystate, int scrollwheel, i
* updateFromState is used when creating a VirtualMouse by deserialising the TASfile,
* as the inputs in the TASfile are stored in states.
*
- * @param keycodes An array of keycodes, that replaces {@link Subtickable#pressedKeys pressedKeys}
+ * @param keycodes A set of keycodes, that replaces {@link Subtickable#pressedKeys pressedKeys}
* @param scrollwheel The scroll wheel of this mouse state
* @param cursorX The pointer location in the x axis
* @param cursorY The pointer location in the y axis
* @see SerialiserFlavorBase#deserialiseMouse
*/
- public void updateFromState(int[] keycodes, int scrollwheel, int cursorX, int cursorY) {
+ public void updateFromState(Set keycodes, int scrollwheel, int cursorX, int cursorY) {
createSubtick();
this.pressedKeys.clear();
- for (int i : keycodes) {
- this.pressedKeys.add(i);
- }
+ this.pressedKeys.addAll(keycodes);
this.scrollWheel = scrollwheel;
this.cursorX = cursorX;
diff --git a/src/test/java/tasmod/playback/tasfile/PlaybackSerialiserTest.java b/src/test/java/tasmod/playback/tasfile/PlaybackSerialiserTest.java
index e2678aba..bb192afa 100644
--- a/src/test/java/tasmod/playback/tasfile/PlaybackSerialiserTest.java
+++ b/src/test/java/tasmod/playback/tasfile/PlaybackSerialiserTest.java
@@ -21,7 +21,7 @@
import com.dselent.bigarraylist.BigArrayList;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.CommentContainer;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
@@ -98,12 +98,12 @@ public String getExtensionName() {
}
@Override
- public void onDeserialiseInlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseInlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
inline.add(fileCommandContainer.split("testKey"));
}
@Override
- public void onDeserialiseEndlineComment(long tick, TickContainer container, PlaybackFileCommandContainer fileCommandContainer) {
+ public void onDeserialiseEndlineComment(long tick, InputContainer container, PlaybackFileCommandContainer fileCommandContainer) {
endline.add(fileCommandContainer.split("endlineKey"));
}
@@ -151,7 +151,7 @@ static void unregister() {
@Test
void testSerialiser() {
- BigArrayList expected = new BigArrayList<>();
+ BigArrayList expected = new BigArrayList<>();
file = Paths.get("src/test/resources/serialiser/PlaybackSerialiserTest.mctas");
@@ -174,7 +174,7 @@ void testSerialiser() {
angle1.set(0, 0);
angle1.updateFromEvent(10, 10);
- expected.add(new TickContainer(keyboard1, mouse1, angle1));
+ expected.add(new InputContainer(keyboard1, mouse1, angle1));
// Tick 2
@@ -195,7 +195,7 @@ void testSerialiser() {
angle2.deepCopyFrom(angle1);
angle2.updateFromEvent(-10, -10);
- expected.add(new TickContainer(keyboard2, mouse2, angle2));
+ expected.add(new InputContainer(keyboard2, mouse2, angle2));
try {
PlaybackSerialiser.saveToFile(file, expected, "Test");
@@ -210,7 +210,7 @@ void testSerialiser() {
}
try {
- BigArrayList actual = PlaybackSerialiser.loadFromFile(file, testFlavor);
+ BigArrayList actual = PlaybackSerialiser.loadFromFile(file, testFlavor);
assertBigArrayList(expected, actual);
assertEquals("testing", testMetadata.actual);
} catch (PlaybackLoadException | IOException e) {
@@ -243,9 +243,9 @@ void testDeserialiser() throws PlaybackLoadException, IOException {
e.printStackTrace();
}
- BigArrayList actual = PlaybackSerialiser.loadFromFile(file);
+ BigArrayList actual = PlaybackSerialiser.loadFromFile(file);
- BigArrayList expected = new BigArrayList<>();
+ BigArrayList expected = new BigArrayList<>();
VirtualKeyboard keyboard = new VirtualKeyboard();
keyboard.updateFromEvent(VirtualKey.W, true, 'w');
@@ -255,7 +255,7 @@ void testDeserialiser() throws PlaybackLoadException, IOException {
container.addInlineComment("This is a regular comment");
container.addInlineComment(null);
container.addEndlineComment("test");
- expected.add(new TickContainer(keyboard, new VirtualMouse(), new VirtualCameraAngle(), container));
+ expected.add(new InputContainer(keyboard, new VirtualMouse(), new VirtualCameraAngle(), container));
VirtualKeyboard keyboard2 = new VirtualKeyboard();
keyboard2.updateFromEvent(VirtualKey.W, true, 'w');
@@ -266,7 +266,7 @@ void testDeserialiser() throws PlaybackLoadException, IOException {
VirtualCameraAngle cameraAngle2 = new VirtualCameraAngle();
cameraAngle2.set(1f, 1f);
- expected.add(new TickContainer(keyboard2, mouse2, cameraAngle2));
+ expected.add(new InputContainer(keyboard2, mouse2, cameraAngle2));
VirtualMouse mouse3 = new VirtualMouse();
mouse3.updateFromEvent(VirtualKey.MOUSEMOVED, false, 0, 2, 2);
@@ -274,8 +274,9 @@ void testDeserialiser() throws PlaybackLoadException, IOException {
VirtualCameraAngle cameraAngle3 = new VirtualCameraAngle();
cameraAngle3.updateFromState(2f, 2f);
+ cameraAngle3.updateFromState(3f, 3f);
- expected.add(new TickContainer(new VirtualKeyboard(), mouse3, cameraAngle3));
+ expected.add(new InputContainer(new VirtualKeyboard(), mouse3, cameraAngle3));
assertBigArrayList(expected, actual);
@@ -332,9 +333,9 @@ void testDeserialiserNoExtensions() throws PlaybackLoadException, IOException {
e.printStackTrace();
}
- BigArrayList actual = PlaybackSerialiser.loadFromFile(file, false);
+ BigArrayList actual = PlaybackSerialiser.loadFromFile(file, false);
- BigArrayList expected = new BigArrayList<>();
+ BigArrayList expected = new BigArrayList<>();
VirtualKeyboard keyboard = new VirtualKeyboard();
keyboard.updateFromEvent(VirtualKey.W, true, 'w');
@@ -344,7 +345,7 @@ void testDeserialiserNoExtensions() throws PlaybackLoadException, IOException {
container.addInlineComment("This is a regular comment");
container.addInlineComment(null);
container.addEndlineComment("test");
- expected.add(new TickContainer(keyboard, new VirtualMouse(), new VirtualCameraAngle(), container));
+ expected.add(new InputContainer(keyboard, new VirtualMouse(), new VirtualCameraAngle(), container));
VirtualKeyboard keyboard2 = new VirtualKeyboard();
keyboard2.updateFromEvent(VirtualKey.W, true, 'w');
@@ -355,7 +356,7 @@ void testDeserialiserNoExtensions() throws PlaybackLoadException, IOException {
VirtualCameraAngle cameraAngle2 = new VirtualCameraAngle();
cameraAngle2.set(1f, 1f);
- expected.add(new TickContainer(keyboard2, mouse2, cameraAngle2));
+ expected.add(new InputContainer(keyboard2, mouse2, cameraAngle2));
VirtualMouse mouse3 = new VirtualMouse();
mouse3.updateFromEvent(VirtualKey.MOUSEMOVED, false, 0, 2, 2);
@@ -363,8 +364,9 @@ void testDeserialiserNoExtensions() throws PlaybackLoadException, IOException {
VirtualCameraAngle cameraAngle3 = new VirtualCameraAngle();
cameraAngle3.updateFromState(2f, 2f);
+ cameraAngle3.updateFromState(3f, 3f);
- expected.add(new TickContainer(new VirtualKeyboard(), mouse3, cameraAngle3));
+ expected.add(new InputContainer(new VirtualKeyboard(), mouse3, cameraAngle3));
assertBigArrayList(expected, actual);
diff --git a/src/test/java/tasmod/playback/tasfile/SerialiserFlavorBaseTest.java b/src/test/java/tasmod/playback/tasfile/SerialiserFlavorBaseTest.java
index 6e060930..6fc1d439 100644
--- a/src/test/java/tasmod/playback/tasfile/SerialiserFlavorBaseTest.java
+++ b/src/test/java/tasmod/playback/tasfile/SerialiserFlavorBaseTest.java
@@ -8,14 +8,16 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import com.dselent.bigarraylist.BigArrayList;
-import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
+import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
import com.minecrafttas.tasmod.playback.metadata.PlaybackMetadata;
@@ -38,7 +40,7 @@ void afterEach() {
this.currentTick = 0;
this.currentSubtick = 0;
- this.previousTickContainer = null;
+ this.previousInputContainer = null;
}
@Override
@@ -192,7 +194,7 @@ public String[] getFileCommandNames() {
}
/**
- * Test serialising a {@link TickContainer}.
+ * Test serialising a {@link InputContainer}.
* This container contains a keyboard, mouse and camera angle,
* with different amounts of subticks each.
*/
@@ -215,7 +217,7 @@ void testSerialiseContainer() {
angle.updateFromEvent(1, 1);
// Create container and fill actual
- TickContainer container = new TickContainer(keyboard, mouse, angle);
+ InputContainer container = new InputContainer(keyboard, mouse, angle);
BigArrayList actual = new BigArrayList<>();
serialiseContainer(actual, container);
@@ -678,7 +680,7 @@ void testExtractExceptions3() {
*/
@Test
void testDeserialiseContainer() {
- BigArrayList actual = new BigArrayList<>();
+ BigArrayList actual = new BigArrayList<>();
List tick = new ArrayList<>();
tick.add("55|W,LCONTROL;w|;0,887,626|17.85;-202.74799");
tick.add("\t1||RC;-15,1580,658|11.85;-2.74799");
@@ -686,22 +688,29 @@ void testDeserialiseContainer() {
deserialiseContainer(actual, tick);
- BigArrayList expected = new BigArrayList<>();
+ BigArrayList expected = new BigArrayList<>();
VirtualKeyboard keyboard = new VirtualKeyboard();
- keyboard.updateFromState(new int[] { VirtualKey.W.getKeycode(), VirtualKey.LCONTROL.getKeycode() }, new char[] { 'w' });
+ Set keyboardKeycodes = new HashSet<>();
+ keyboardKeycodes.add(VirtualKey.W.getKeycode());
+ keyboardKeycodes.add(VirtualKey.LCONTROL.getKeycode());
+ keyboard.updateFromState(keyboardKeycodes, new char[] { 'w' });
VirtualMouse mouse = new VirtualMouse();
- mouse.updateFromState(new int[] { VirtualKey.MOUSEMOVED.getKeycode() }, 0, 887, 626);
- mouse.updateFromState(new int[] { VirtualKey.RC.getKeycode() }, -15, 1580, 658);
- mouse.updateFromState(new int[] { VirtualKey.MOUSEMOVED.getKeycode() }, 0, 1580, 658);
+ Set mouseKeycodes1 = new HashSet<>();
+ Set mouseKeycodes2 = new HashSet<>();
+ mouseKeycodes2.add(VirtualKey.RC.getKeycode());
+ Set mouseKeycodes3 = new HashSet<>();
+ mouse.updateFromState(mouseKeycodes1, 0, 887, 626);
+ mouse.updateFromState(mouseKeycodes2, -15, 1580, 658);
+ mouse.updateFromState(mouseKeycodes3, 0, 1580, 658);
VirtualCameraAngle cameraAngle = new VirtualCameraAngle();
cameraAngle.updateFromState(-202.74799F, 17.85F);
cameraAngle.updateFromState(-2.74799F, 11.85F);
cameraAngle.updateFromState(-22.799F, 45F);
- expected.add(new TickContainer(keyboard, mouse, cameraAngle));
+ expected.add(new InputContainer(keyboard, mouse, cameraAngle));
assertBigArrayList(expected, actual);
}
diff --git a/src/test/java/tasmod/playback/tasfile/builtin/AlphaFlavorTest.java b/src/test/java/tasmod/playback/tasfile/builtin/AlphaFlavorTest.java
index e253a214..b5cc470f 100644
--- a/src/test/java/tasmod/playback/tasfile/builtin/AlphaFlavorTest.java
+++ b/src/test/java/tasmod/playback/tasfile/builtin/AlphaFlavorTest.java
@@ -63,7 +63,7 @@ void afterEach() {
this.currentTick = 0;
this.currentSubtick = 0;
- this.previousTickContainer = null;
+ this.previousInputContainer = null;
}
@BeforeEach