Skip to content

Commit

Permalink
[VirtualInput] Removing old VirtualInput
Browse files Browse the repository at this point in the history
  • Loading branch information
ScribbleTAS committed Feb 8, 2024
1 parent 297be0b commit 9b615c7
Show file tree
Hide file tree
Showing 26 changed files with 1,444 additions and 2,869 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/minecrafttas/tasmod/TASmodClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.minecrafttas.tasmod.util.LoggerMarkers;
import com.minecrafttas.tasmod.util.Scheduler;
import com.minecrafttas.tasmod.util.ShieldDownloader;
import com.minecrafttas.tasmod.virtual.VirtualInput2;
import com.minecrafttas.tasmod.virtual.VirtualInput;
import com.minecrafttas.tasmod.virtual.VirtualKeybindings;

import net.fabricmc.api.ClientModInitializer;
Expand All @@ -52,7 +52,7 @@
public class TASmodClient implements ClientModInitializer, EventClientInit, EventPlayerJoinedClientSide, EventOpenGui{


public static VirtualInput2 virtual;
public static VirtualInput virtual;

public static TickSyncClient ticksyncClient;

Expand Down Expand Up @@ -126,7 +126,7 @@ public void onInitializeClient() {
} else {
config.reset(ConfigOptions.FileToOpen);
}
virtual=new VirtualInput2(LOGGER); //TODO Move fileOnStart to PlaybackController
virtual=new VirtualInput(LOGGER); //TODO Move fileOnStart to PlaybackController

// Initialize InfoHud
hud = new InfoHud();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.handlers.InterpolationHandler;
import com.minecrafttas.tasmod.util.Ducks.SubtickDuck;
import com.minecrafttas.tasmod.virtual.VirtualInput;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.util.math.MathHelper;
Expand All @@ -18,7 +19,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* Redirects the camera to use {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualCameraAngleInput}.<br>
* Redirects the camera to use {@link VirtualInput.VirtualCameraAngleInput}.<br>
* Also conforms the camera to 20tps as
*/
@Mixin(EntityRenderer.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecrafttas.tasmod.mixin.playbackhooks;

import com.minecrafttas.tasmod.virtual.VirtualInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -11,7 +12,7 @@
@Mixin(GuiChat.class)
public class MixinGuiChat {
/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#getEventMouseScrollWheel()}
* @return {@link VirtualInput.VirtualMouseInput#getEventMouseScrollWheel()}
*/
@Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I", remap = false))
public int redirectHandleMouseInput4() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecrafttas.tasmod.mixin.playbackhooks;

import com.minecrafttas.tasmod.virtual.VirtualInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -12,7 +13,7 @@
public class MixinGuiClickableScrolledSelectionListProxy {

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#getEventMouseState()}
* @return {@link VirtualInput.VirtualMouseInput#getEventMouseState()}
*/
@Redirect(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButtonState()Z", ordinal = 0, remap = false))
public boolean redirectHandleMouseInput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.virtual.VirtualKey2;
import com.minecrafttas.tasmod.virtual.VirtualKey;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
Expand All @@ -15,7 +15,7 @@
public class MixinGuiContainer {

/**
* Redirects the check for {@link VirtualKey2#LSHIFT} and {@link VirtualKey2#RSHIFT} in mouseClicked
* Redirects the check for {@link VirtualKey#LSHIFT} and {@link VirtualKey#RSHIFT} in mouseClicked
* @param i The keycode to check for
* @return If the keycode is down
*/
Expand All @@ -25,7 +25,7 @@ private boolean redirectIsKeyDown(int i) {
}

/**
* Redirects the check for {@link VirtualKey2#LSHIFT} and {@link VirtualKey2#RSHIFT} in mouseReleased
* Redirects the check for {@link VirtualKey#LSHIFT} and {@link VirtualKey#RSHIFT} in mouseReleased
* @param i The keycode to check for
* @return If the keycode is down
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecrafttas.tasmod.mixin.playbackhooks;

import com.minecrafttas.tasmod.virtual.VirtualInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -10,8 +11,7 @@

import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.util.Ducks.GuiScreenDuck;
import com.minecrafttas.tasmod.virtual.VirtualInput2;
import com.minecrafttas.tasmod.virtual.VirtualKeyboardEvent;
import com.minecrafttas.tasmod.virtual.event.VirtualKeyboardEvent;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
Expand All @@ -21,7 +21,7 @@ public class MixinGuiScreen implements GuiScreenDuck {

/**
* Run at the start of run handleInput. Runs every tick.
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#nextKeyboardTick()
* @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))
Expand All @@ -30,9 +30,9 @@ public void injectAfterKeyboardCreated(CallbackInfo ci) {
}

/**
* Redirects a {@link org.lwjgl.input.Keyboard#next()}. Starts running every tick and continues as long as there are {@link VirtualKeyboardEvent}s in {@link VirtualInput2}
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#nextKeyboardSubtick()
* @return If {@link VirtualKeyboardEvent}s are present in {@link VirtualInput2}
* 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}
*/
@Redirect(method = "handleInput", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;next()Z", remap = false))
public boolean redirectKeyboardNext() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecrafttas.tasmod.mixin.playbackhooks;

import com.minecrafttas.tasmod.virtual.VirtualInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -8,10 +9,9 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.virtual.VirtualInput2;
import com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput;
import com.minecrafttas.tasmod.virtual.VirtualKeyboardEvent;
import com.minecrafttas.tasmod.virtual.VirtualMouseEvent;
import com.minecrafttas.tasmod.virtual.VirtualInput.VirtualMouseInput;
import com.minecrafttas.tasmod.virtual.event.VirtualKeyboardEvent;
import com.minecrafttas.tasmod.virtual.event.VirtualMouseEvent;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
Expand All @@ -24,7 +24,7 @@ public class MixinMinecraft {

/**
* Runs every frame.
* @see VirtualInput2#update(GuiScreen)
* @see VirtualInput#update(GuiScreen)
* @param ci CBI
*/
@Inject(method = "runGameLoop", at = @At(value = "HEAD"))
Expand All @@ -36,7 +36,7 @@ public void playback_injectRunGameLoop(CallbackInfo ci) {

/**
* Run at the start of run tick keyboard. Runs every tick.
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#nextKeyboardTick()
* @see VirtualInput.VirtualKeyboardInput#nextKeyboardTick()
* @param ci CBI
*/
@Inject(method = "runTickKeyboard", at = @At(value = "HEAD"))
Expand All @@ -45,33 +45,33 @@ public void playback_injectRunTickKeyboard(CallbackInfo ci) {
}

/**
* Redirects a {@link org.lwjgl.input.Keyboard#next()}. Starts running every tick and continues as long as there are {@link VirtualKeyboardEvent}s in {@link VirtualInput2}
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#nextKeyboardSubtick()
* @return If {@link VirtualKeyboardEvent}s are present in {@link VirtualInput2}
* 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}
*/
@Redirect(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;next()Z", remap = false))
public boolean playback_redirectKeyboardNext() {
return TASmodClient.virtual.KEYBOARD.nextKeyboardSubtick();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardKey()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardKey()}
*/
@Redirect(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKey()I", remap = false))
public int playback_redirectKeyboardGetEventKey() {
return TASmodClient.virtual.KEYBOARD.getEventKeyboardKey();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardState()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardState()}
*/
@Redirect(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKeyState()Z", remap = false))
public boolean playback_redirectGetEventState() {
return TASmodClient.virtual.KEYBOARD.getEventKeyboardState();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardCharacter()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardCharacter()}
*/
@Redirect(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventCharacter()C", remap = false))
public char playback_redirectKeyboardGetEventCharacter() {
Expand All @@ -80,32 +80,32 @@ public char playback_redirectKeyboardGetEventCharacter() {

/**
* Runs everytime {@link #playback_redirectKeyboardNext()} has an event ready. Redirects {@link org.lwjgl.input.Keyboard#isKeyDown(int)}
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#isKeyDown(int)
* @return Whether the key is down in {@link VirtualInput2}
* @see VirtualInput.VirtualKeyboardInput#isKeyDown(int)
* @return Whether the key is down in {@link VirtualInput}
*/
@Redirect(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;isKeyDown(I)Z", remap = false))
public boolean playback_redirectIsKeyDown(int keyCode) {
return TASmodClient.virtual.KEYBOARD.isKeyDown(keyCode);
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardKey()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardKey()}
*/
@Redirect(method = "dispatchKeypresses", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKey()I", remap = false))
public int playback_redirectGetEventKeyDPK() {
return TASmodClient.virtual.KEYBOARD.getEventKeyboardKey();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardState()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardState()}
*/
@Redirect(method = "dispatchKeypresses", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKeyState()Z", remap = false))
public boolean playback_redirectGetEventKeyStateDPK() {
return TASmodClient.virtual.KEYBOARD.getEventKeyboardState();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualKeyboardInput#getEventKeyboardCharacter()}
* @return {@link VirtualInput.VirtualKeyboardInput#getEventKeyboardCharacter()}
*/
@Redirect(method = "dispatchKeypresses", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventCharacter()C", remap = false))
public char playback_redirectGetEventCharacterDPK() {
Expand All @@ -116,7 +116,7 @@ public char playback_redirectGetEventCharacterDPK() {

/**
* Run at the start of run tick mouse. Runs every tick.
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#nextMouseTick()
* @see VirtualInput.VirtualMouseInput#nextMouseTick()
* @param ci CBI
*/
@Inject(method = "runTickMouse", at = @At(value = "HEAD"))
Expand All @@ -125,33 +125,33 @@ public void playback_injectRunTickMouse(CallbackInfo ci) {
}

/**
* Redirects a {@link org.lwjgl.input.Mouse#next()}. Starts running every tick and continues as long as there are {@link VirtualMouseEvent}s in {@link VirtualInput2}
* @see com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#nextMouseSubtick()
* @return If {@link VirtualMouseInput}s are present in {@link VirtualInput2}
* 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()
* @return If {@link VirtualMouseInput}s are present in {@link VirtualInput}
*/
@Redirect(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;next()Z", remap = false))
public boolean playback_redirectMouseNext() {
return TASmodClient.virtual.MOUSE.nextMouseSubtick();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#getEventMouseKey()}
* @return {@link VirtualInput.VirtualMouseInput#getEventMouseKey()}
*/
@Redirect(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButton()I", remap = false))
public int playback_redirectMouseGetEventButton() {
return TASmodClient.virtual.MOUSE.getEventMouseKey() + 100;
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#getEventMouseState()}
* @return {@link VirtualInput.VirtualMouseInput#getEventMouseState()}
*/
@Redirect(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButtonState()Z", remap = false))
public boolean playback_redirectGetEventButtonState() {
return TASmodClient.virtual.MOUSE.getEventMouseState();
}

/**
* @return {@link com.minecrafttas.tasmod.virtual.VirtualInput2.VirtualMouseInput#getEventMouseScrollWheel()}
* @return {@link VirtualInput.VirtualMouseInput#getEventMouseScrollWheel()}
*/
@Redirect(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I", remap = false))
public int playback_redirectGetEventDWheel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ private void tpPlayer(String startLocation) throws NumberFormatException {
* Clears {@link #keyboard} and {@link #mouse}
*/
public void unpressContainer() {
LOGGER.trace(LoggerMarkers.Playback, "Unpressing container");
keyboard.clear();
mouse.clear();
// LOGGER.trace(LoggerMarkers.Playback, "Unpressing container");
// keyboard.clear();
// mouse.clear();
}

// ==============================================================
Expand Down Expand Up @@ -747,7 +747,7 @@ public TickInputContainer(int tick) {
this.tick = tick;
this.keyboard = new VirtualKeyboard();
this.mouse = new VirtualMouse();
this.subticks = new VirtualCameraAngle(0, 0);
// this.subticks = new VirtualCameraAngle(0, 0);
}

@Override
Expand Down
Loading

0 comments on commit 9b615c7

Please sign in to comment.