11package com .minecrafttas .tasmod .virtual ;
22
3- import java .util .ArrayList ;
43import java .util .List ;
54import java .util .Queue ;
65import java .util .concurrent .ConcurrentLinkedQueue ;
76
8- import org .apache .commons .lang3 .tuple .Triple ;
97import org .apache .logging .log4j .Logger ;
108import org .lwjgl .input .Keyboard ;
119import org .lwjgl .input .Mouse ;
1210import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1311
1412import com .minecrafttas .mctcommon .events .EventListenerRegistry ;
15- import com .minecrafttas .tasmod .TASmodClient ;
1613import com .minecrafttas .tasmod .events .EventVirtualInput ;
1714import com .minecrafttas .tasmod .mixin .playbackhooks .MixinEntityRenderer ;
1815import com .minecrafttas .tasmod .mixin .playbackhooks .MixinMinecraft ;
1916import com .minecrafttas .tasmod .util .Ducks ;
20- import com .minecrafttas .tasmod .util .Ducks .GuiScreenDuck ;
2117import com .minecrafttas .tasmod .util .Ducks .SubtickDuck ;
2218import com .minecrafttas .tasmod .util .LoggerMarkers ;
2319import com .minecrafttas .tasmod .util .PointerNormalizer ;
2622
2723import net .minecraft .client .Minecraft ;
2824import net .minecraft .client .gui .GuiScreen ;
29- import net .minecraft .util .math .MathHelper ;
3025
3126/**
3227 * Main component for redirecting inputs.<br>
@@ -51,6 +46,8 @@ public class VirtualInput {
5146 */
5247 public final VirtualCameraAngleInput CAMERA_ANGLE ;
5348
49+ public final VirtualInterpolationHandler interpolationHandler = new VirtualInterpolationHandler ();
50+
5451 /**
5552 * Creates a new virtual input with an empty {@link VirtualKeyboardInput}, {@link VirtualMouseInput} and {@link VirtualCameraAngleInput}
5653 * @param logger The logger instance
@@ -426,8 +423,6 @@ public class VirtualMouseInput {
426423 */
427424 private VirtualMouseEvent currentMouseEvent = new VirtualMouseEvent ();
428425
429- private final List <VirtualMouse > mousePointerInterpolationStates = new ArrayList <>();
430-
431426 /**
432427 * Constructor to preload the {@link #currentMouse} with an existing mouse
433428 * @param preloadedMouse The new {@link #currentMouse}
@@ -460,8 +455,6 @@ public void updateNextMouse(int keycode, boolean keystate, int scrollwheel, int
460455 */
461456 public void nextMouseTick () {
462457 nextMouse .deepCopyFrom ((VirtualMouse ) EventListenerRegistry .fireEvent (EventVirtualInput .EventVirtualMouseTick .class , nextMouse ));
463- mousePointerInterpolationStates .clear ();
464- TASmodClient .controller .getNextMouse ().getStates (mousePointerInterpolationStates );
465458 currentMouse .getVirtualEvents (nextMouse , mouseEventQueue );
466459 currentMouse .moveFrom (nextMouse );
467460 }
@@ -551,60 +544,6 @@ public boolean willKeyBeDown(int keycode) {
551544 return nextMouse .isKeyDown (keycode );
552545 }
553546
554- /**
555- * Gets the absolute coordinates of the camera angle
556- *
557- * @param partialTick The partial ticks of the timer
558- * @param pitch The original pitch of the camera
559- * @param yaw The original yaw of the camera
560- * @param enable Whether the custom interpolation is enabled. Enabled during playback.
561- * @return Integer coordinate of
562- */
563- public int getInterpolatedX (float partialTick , boolean enable ) {
564-
565- int interpolatedPointerX = nextMouse .getCursorX ();
566-
567- if (enable && !mousePointerInterpolationStates .isEmpty ()) {
568- int index = (int ) MathHelper .clampedLerp (0 , mousePointerInterpolationStates .size () - 1 , partialTick ); // Get interpolate index
569-
570- VirtualMouse interpolatedCamera = mousePointerInterpolationStates .get (index );
571-
572- interpolatedPointerX = interpolatedCamera .getCursorX ();
573-
574- }
575- Minecraft mc = Minecraft .getMinecraft ();
576- GuiScreenDuck gui = (GuiScreenDuck ) mc .currentScreen ;
577-
578- if (gui != null ) {
579- interpolatedPointerX = gui .rescaleX (PointerNormalizer .reapplyScalingX (interpolatedPointerX ));
580- }
581-
582- return interpolatedPointerX ;
583- }
584-
585- public int getInterpolatedY (float partialTick , boolean enable ) {
586-
587- int interpolatedPointerY = nextMouse .getCursorY ();
588-
589- if (enable && !mousePointerInterpolationStates .isEmpty ()) {
590- int index = (int ) MathHelper .clampedLerp (0 , mousePointerInterpolationStates .size () - 1 , partialTick ); // Get interpolate index
591-
592- VirtualMouse interpolatedCamera = mousePointerInterpolationStates .get (index );
593-
594- interpolatedPointerY = interpolatedCamera .getCursorY ();
595-
596- }
597-
598- Minecraft mc = Minecraft .getMinecraft ();
599- GuiScreenDuck gui = (GuiScreenDuck ) mc .currentScreen ;
600-
601- if (gui != null ) {
602- interpolatedPointerY = gui .rescaleY (PointerNormalizer .reapplyScalingY (interpolatedPointerY ));
603- }
604-
605- return interpolatedPointerY ;
606- }
607-
608547 /**
609548 * Clears the {@link #nextMouse}
610549 */
@@ -676,11 +615,6 @@ public class VirtualCameraAngleInput {
676615 * and updates {@link #currentCameraAngle} in {@link #nextCameraTick()}
677616 */
678617 private final VirtualCameraAngle nextCameraAngle = new VirtualCameraAngle ();
679- /**
680- * States of the {@link #nextCameraAngle} made during the tick.<br>
681- * Is updated in {@link #nextCameraTick()}
682- */
683- private final List <VirtualCameraAngle > cameraAngleInterpolationStates = new ArrayList <>();
684618
685619 /**
686620 * Constructor to preload the {@link #currentCameraAngle} with an existing
@@ -728,8 +662,6 @@ public void updateNextCameraAngle(float pitchDelta, float yawDelta, boolean upda
728662 */
729663 public void nextCameraTick () {
730664 nextCameraAngle .deepCopyFrom ((VirtualCameraAngle ) EventListenerRegistry .fireEvent (EventVirtualInput .EventVirtualCameraAngleTick .class , nextCameraAngle ));
731- cameraAngleInterpolationStates .clear ();
732- nextCameraAngle .getStates (cameraAngleInterpolationStates );
733665 currentCameraAngle .moveFrom (nextCameraAngle );
734666 }
735667
@@ -765,32 +697,6 @@ public Float getCurrentYaw() {
765697 return currentCameraAngle .getYaw ();
766698 }
767699
768- /**
769- * Gets the absolute coordinates of the camera angle
770- *
771- * @param partialTick The partial ticks of the timer
772- * @param pitch The original pitch of the camera
773- * @param yaw The original yaw of the camera
774- * @param enable Whether the custom interpolation is enabled. Enabled during playback.
775- * @return A triple of pitch, yaw and roll, as left, middle and right respectively
776- */
777- public Triple <Float , Float , Float > getInterpolatedState (float partialTick , float pitch , float yaw , boolean enable ) {
778-
779- float interpolatedPitch = nextCameraAngle .getPitch () == null ? pitch : nextCameraAngle .getPitch ();
780- float interpolatedYaw = nextCameraAngle .getYaw () == null ? yaw : nextCameraAngle .getYaw () + 180 ;
781-
782- if (enable && !cameraAngleInterpolationStates .isEmpty ()) {
783- int index = (int ) MathHelper .clampedLerp (0 , cameraAngleInterpolationStates .size () - 1 , partialTick ); // Get interpolate index
784-
785- VirtualCameraAngle interpolatedCamera = cameraAngleInterpolationStates .get (index );
786-
787- interpolatedPitch = interpolatedCamera .getPitch () == null ? 0 : interpolatedCamera .getPitch ();
788- interpolatedYaw = interpolatedCamera .getYaw () == null ? 0 : interpolatedCamera .getYaw () + 180 ;
789-
790- }
791- return Triple .of (interpolatedPitch , interpolatedYaw , 0f );
792- }
793-
794700 /**
795701 * Clears the {@link #nextCameraAngle}
796702 */
0 commit comments