mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-25 01:28:54 -05:00
Riding momentum is maintained when window is not active
This commit is contained in:
1 parent
741e38d606
commit
3061ba69e2
3 files changed
+13
-6
No files matched your search
@@ -30,6 +30,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(MouseHandler.class)
|
||||
public abstract class MouseHandlerMixin {
|
||||
@@ -56,6 +57,8 @@ public abstract class MouseHandlerMixin {
|
||||
|
||||
@Shadow protected abstract void turnPlayer(double movementTime);
|
||||
|
||||
@Unique private double cobblemon$timeDelta;
|
||||
|
||||
@Inject(
|
||||
method = "onScroll",
|
||||
at = @At(
|
||||
@@ -168,17 +171,21 @@ public abstract class MouseHandlerMixin {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Inject(method = "handleAccumulatedMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MouseHandler;isMouseGrabbed()Z", ordinal = 0))
|
||||
private void cobblemon$maintainMovementWhenInScreens(CallbackInfo ci, @Local(ordinal = 1) double e) {
|
||||
@Inject(method = "handleAccumulatedMovement", at = @At("HEAD"))
|
||||
private void cobblemon$maintainMovementWhenInScreens2(CallbackInfo ci) {
|
||||
double time = Blaze3D.getTime();
|
||||
cobblemon$timeDelta = time - this.lastHandleMovementTime;
|
||||
}
|
||||
|
||||
@Inject(method = "handleAccumulatedMovement", at = @At("TAIL"))
|
||||
private void cobblemon$maintainMovementWhenInScreens(CallbackInfo ci) {
|
||||
if (minecraft.player == null) return;
|
||||
if (!(minecraft.player instanceof OrientationControllable controllable)) return;
|
||||
if (!controllable.getOrientationController().isActive()) return;
|
||||
if (minecraft.isPaused()) return;
|
||||
if (isMouseGrabbed()) return;
|
||||
|
||||
this.accumulatedDX = 0f;
|
||||
this.accumulatedDY = 0f;
|
||||
this.turnPlayer(e);
|
||||
this.turnPlayer(cobblemon$timeDelta);
|
||||
}
|
||||
|
||||
@Unique
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
"PiglinEntityMixin",
|
||||
"PlayerAdvancementsMixin",
|
||||
"PlayerMixin",
|
||||
"PointedDripstoneBlockMixin",
|
||||
"ServerPlayerMixin",
|
||||
"ServerEntityMixin",
|
||||
"ShearsDispenserBehaviorMixin",
|
||||
|
||||
@@ -16,6 +16,7 @@ val bundle: Configuration by configurations.creating {
|
||||
loom {
|
||||
val clientConfig = runConfigs.getByName("client")
|
||||
clientConfig.runDir = "runClient"
|
||||
// clientConfig.vmArg("-Dmixin.debug=true")
|
||||
// clientConfig.programArg("--username=AshKetchum")
|
||||
//This is AshKetchum's UUID so you get an Ash Ketchum skin
|
||||
// clientConfig.programArg("--uuid=93e4e551-589a-41cb-ab2d-435266c8e035")
|
||||
|
||||
Reference in new issue
Block a user