Skip to content

Commit

Permalink
HERE WE GO
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed May 10, 2024
1 parent ee16638 commit b3a7f74
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 57 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
- Fixed Controlify 2.0 compatibility.
- Updated Forge version to NeoForge 1.20.4.
- LexForge will not be supported from now on.
- Updated to 1.20.6.
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,27 @@
import nl.enjarai.doabarrelroll.EventCallbacksClient;
import nl.enjarai.doabarrelroll.util.StarFoxUtil;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
public abstract class InGameHudMixin {
@Shadow private int scaledWidth;
@Shadow private int scaledHeight;

@Inject(
method = "render",
method = "renderCrosshair",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/hud/InGameHud;renderCrosshair(Lnet/minecraft/client/gui/DrawContext;)V"
value = "HEAD"
)
)
private void doABarrelRoll$captureTickDelta(DrawContext context, float tickDelta, CallbackInfo ci) {
context.getMatrices().push();
EventCallbacksClient.onRenderCrosshair(context, tickDelta, scaledWidth, scaledHeight);
EventCallbacksClient.onRenderCrosshair(context, tickDelta, context.getScaledWindowWidth(), context.getScaledWindowHeight());
}

@Inject(
method = "render",
method = "renderCrosshair",
at = @At(
value = "CONSTANT",
args = "stringValue=bossHealth"
value = "RETURN"
)
)
private void doABarrelRoll$renderCrosshairReturn(DrawContext context, float tickDelta, CallbackInfo ci) {
Expand All @@ -42,11 +36,11 @@ public abstract class InGameHudMixin {
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F",
target = "Lnet/minecraft/client/gui/LayeredDrawer;render(Lnet/minecraft/client/gui/DrawContext;F)V",
ordinal = 0
)
)
private void doABarrelRoll$renderPeppy(DrawContext context, float tickDelta, CallbackInfo ci) {
StarFoxUtil.renderPeppy(context, tickDelta, scaledWidth, scaledHeight);
StarFoxUtil.renderPeppy(context, tickDelta, context.getScaledWindowWidth(), context.getScaledWindowHeight());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class DebugHudMixin {
at = @At(
value = "INVOKE",
target = "Ljava/lang/String;format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;",
ordinal = 6
ordinal = 7
),
index = 1,
require = 0
Expand All @@ -39,7 +39,7 @@ public abstract class DebugHudMixin {
at = @At(
value = "INVOKE",
target = "Ljava/lang/String;format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;",
ordinal = 6
ordinal = 7
),
index = 2,
require = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@

import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import nl.enjarai.doabarrelroll.api.RollCamera;
import nl.enjarai.doabarrelroll.math.MagicNumbers;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(GameRenderer.class)
public abstract class GameRendererMixin {
@Shadow @Final private Camera camera;

@Inject(
@Redirect(
method = "renderWorld",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/math/RotationAxis;rotationDegrees(F)Lorg/joml/Quaternionf;",
ordinal = 2
target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;",
ordinal = 0
)
)
public void doABarrelRoll$renderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) {
matrix.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(((RollCamera) camera).doABarrelRoll$getRoll()));
public Matrix4f doABarrelRoll$renderWorld(Matrix4f instance, float angleX, float angleY, float angleZ) {
return instance.rotateZ((float) (((RollCamera) camera).doABarrelRoll$getRoll() * MagicNumbers.TORAD))
.rotateX(angleX)
.rotateY(angleY);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package nl.enjarai.doabarrelroll.mixin.client.roll;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalDoubleRef;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import net.minecraft.client.network.ClientPlayerEntity;
Expand All @@ -16,43 +15,26 @@
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Mouse.class)
public abstract class MouseMixin implements RollMouse {
@Shadow @Final private MinecraftClient client;
@Shadow private double lastMouseUpdateTime;
@Shadow private double lastTickTime;

@Unique
private final Vector2d mouseTurnVec = new Vector2d();

@ModifyVariable(
method = "updateMouse",
index = 3,
at = @At(
value = "STORE",
ordinal = 0
)
)
private double doABarrelRoll$captureDelta(double original, @Share("mouseDelta") LocalDoubleRef mouseDeltaRef) {
if (lastMouseUpdateTime != Double.MIN_VALUE) {
mouseDeltaRef.set(original);
}

return original;
}

@Inject(
method = "updateMouse",
at = @At(
value = "RETURN",
ordinal = 0
)
)
private void doABarrelRoll$maintainMouseMomentum(CallbackInfo ci, @Share("mouseDelta") LocalDoubleRef mouseDeltaRef) {
private void doABarrelRoll$maintainMouseMomentum(double timeDelta, CallbackInfo ci) {
if (client.player != null && !client.isPaused()) {
doABarrelRoll$updateMouse(client.player, 0, 0, mouseDeltaRef.get());
doABarrelRoll$updateMouse(client.player, 0, 0, timeDelta);
}
}

Expand All @@ -63,8 +45,8 @@ public abstract class MouseMixin implements RollMouse {
target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V"
)
)
private boolean doABarrelRoll$changeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY, @Share("mouseDelta") LocalDoubleRef mouseDeltaRef) {
return !doABarrelRoll$updateMouse(player, cursorDeltaX, cursorDeltaY, mouseDeltaRef.get());
private boolean doABarrelRoll$changeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY, @Local(argsOnly = true) double timeDelta) {
return !doABarrelRoll$updateMouse(player, cursorDeltaX, cursorDeltaY, timeDelta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import nl.enjarai.doabarrelroll.api.RollEntity;
import org.joml.Quaternionf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin {
@ModifyArg(
method = "setupTransforms(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;FFF)V",
method = "setupTransforms(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;FFFF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V",
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
mappings "net.fabricmc:yarn:${yarn_version}:v2"
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation project(":common")
implementation project(path: ":common", configuration: "namedElements")

modImplementation("nl.enjarai:cicada-lib:${project.cicada_version}") {
exclude group: "net.fabricmc.fabric-api"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

# Project
mod_version=3.5.4
mod_version=3.5.6
group=nl.enjarai

# Common
Expand Down

0 comments on commit b3a7f74

Please sign in to comment.