Skip to content

Commit

Permalink
Please remind me to test this pleaese i beg
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Oct 22, 2024
1 parent ad5f8f8 commit 567eac8
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val mod = ModData()

val loader = loom.platform.get().name.lowercase()
val isFabric = loader == "fabric"
val mcVersion = stonecutter.current.project.substringBeforeLast('-')
val mcVersion = property("mod.mc_version").toString() // stonecutter.current.project.substringBeforeLast('-')
val mcDep = property("mod.mc_dep").toString()
val isSnapshot = hasProperty("env.snapshot")

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod.version=3.7.2
mod.group=nl.enjarai
mod.id=do_a_barrel_roll
mod.name=Do a Barrel Roll
mod.mc_version=1.21.2-rc2

# Global Dependencies
deps.mixin_squared=0.1.2-beta.4
Expand All @@ -34,4 +35,4 @@ mod.mc_targets=[VERSIONED]
publish.modrinth=6FtRfnLg
publish.curseforge=663658
publish.github=enjarai/do-a-barrel-roll
publish.branch=stonecutter/1.21
publish.branch=stonecutter/1.21.2
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extensions.configure<StonecutterSettings> {
//mc("1.20.2", "fabric", "forge")
//mc("1.20.4", "fabric", "neoforge")
//mc("1.20.6", "fabric", "neoforge")
mc("1.21", "fabric", "neoforge")
mc("1.21.2", "fabric",) //"neoforge")
}
create(rootProject)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static boolean isFallFlying() {
if (ModConfig.INSTANCE.getDisableWhenSubmerged() && player.isSubmergedInWater()) {
return false;
}
return player.isFallFlying();
return player.isGliding();
}

public static boolean isConnectedToRealms() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/nl/enjarai/doabarrelroll/api/RollRenderState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package nl.enjarai.doabarrelroll.api;

public interface RollRenderState {
boolean doABarrelRoll$isRolling();

void doABarrelRoll$setRolling(boolean rolling);

float doABarrelRoll$getRoll();

void doABarrelRoll$setRoll(float roll);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
@ModifyVariable(
method = "travel",
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/math/Vec3d;horizontalLength()D",
ordinal = 1
)
),
method = "checkGlidingCollision",
at = @At("STORE"),
index = 21,
index = 7,
require = 0 // We let this mixin fail if it needs to as a temporary workaround to be compatible with Connector.
)
private float doABarrelRoll$modifyKineticDamage(float original) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
MixinHooks.thirdJump = false;
}

MixinHooks.wasJumping = input.jumping;
MixinHooks.wasJumping = input.playerInput.jump();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public LivingEntityMixin(EntityType<?> type, World world) {

@SuppressWarnings("ConstantConditions")
@ModifyArg(
method = "travel",
method = "travelGliding",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V",
ordinal = 6
ordinal = 0
)
)
private Vec3d doABarrelRoll$wrapElytraVelocity(Vec3d original) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World

@SuppressWarnings("ConstantConditions")
@Inject(
method = "checkFallFlying()Z",
method = "checkGliding()Z",
at = @At("HEAD"),
cancellable = true
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package nl.enjarai.doabarrelroll.mixin.client.roll;

import net.minecraft.client.render.entity.state.EntityRenderState;
import nl.enjarai.doabarrelroll.api.RollRenderState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(EntityRenderState.class)
public class EntityRenderStateMixin implements RollRenderState {
@Unique
protected boolean rolling;
@Unique
protected float roll;

@Override
public boolean doABarrelRoll$isRolling() {
return rolling;
}

@Override
public void doABarrelRoll$setRolling(boolean rolling) {
this.rolling = rolling;
}

@Override
public float doABarrelRoll$getRoll() {
return roll;
}

@Override
public void doABarrelRoll$setRoll(float roll) {
this.roll = roll;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package nl.enjarai.doabarrelroll.mixin.client.roll;

import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.state.EntityRenderState;
import net.minecraft.entity.Entity;
import nl.enjarai.doabarrelroll.api.RollEntity;
import nl.enjarai.doabarrelroll.api.RollRenderState;
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.callback.CallbackInfo;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin {
@Inject(
method = "updateRenderState",
at = @At("TAIL")
)
private void updateRollState(Entity entity, EntityRenderState state, float tickDelta, CallbackInfo ci) {
var rollEntity = (RollEntity) entity;
var rollState = (RollRenderState) state;

rollState.doABarrelRoll$setRolling(rollEntity.doABarrelRoll$isRolling());
rollState.doABarrelRoll$setRoll(rollEntity.doABarrelRoll$getRoll(tickDelta));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
import net.minecraft.util.math.RotationAxis;
import nl.enjarai.doabarrelroll.api.RollEntity;
import nl.enjarai.doabarrelroll.api.RollRenderState;
import org.joml.Quaternionf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -13,7 +15,7 @@
@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin {
@ModifyArg(
method = "setupTransforms(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;FFFF)V",
method = "setupTransforms(Lnet/minecraft/client/render/entity/state/PlayerEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;FF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V",
Expand All @@ -22,12 +24,11 @@ public abstract class PlayerEntityRendererMixin {
index = 0
)
private Quaternionf doABarrelRoll$modifyRoll(Quaternionf original,
@Local(argsOnly = true) AbstractClientPlayerEntity player,
@Local(argsOnly = true, ordinal = 2) float tickDelta) {
var rollEntity = (RollEntity) player;
@Local(argsOnly = true) PlayerEntityRenderState state) {
var rollState = (RollRenderState) state;

if (rollEntity.doABarrelRoll$isRolling()) {
var roll = rollEntity.doABarrelRoll$getRoll(tickDelta);
if (rollState.doABarrelRoll$isRolling()) {
var roll = rollState.doABarrelRoll$getRoll();
return RotationAxis.POSITIVE_Y.rotationDegrees(roll);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin {
@Override
public void doABarrelRoll$setRoll(float roll) {
if (!Float.isFinite(roll)) {
Util.error("Invalid entity rotation: " + roll + ", discarding.");
Util.logErrorOrPause("Invalid entity rotation: " + roll + ", discarding.");
return;
}
var lastRoll = doABarrelRoll$getRoll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import nl.enjarai.doabarrelroll.ModMath;
Expand All @@ -22,7 +23,7 @@ public static void render(MatrixStack matrices, int scaledWidth, int scaledHeigh

RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
for (int i = 0; i < 2; i++) {
v.negate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.util.math.MatrixStack;
import nl.enjarai.doabarrelroll.ModMath;
import org.joml.Vector2d;
Expand All @@ -20,7 +22,7 @@ public static void render(MatrixStack matrices, int scaledWidth, int scaledHeigh

RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
ModMath.forBresenhamLine(
centerX, centerY,
centerX + (int) lineVec.x, centerY + (int) lineVec.y,
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/nl/enjarai/doabarrelroll/util/StarFoxUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -52,7 +53,7 @@ public static void renderPeppy(DrawContext context, float tickDelta, int scaledW
int x = scaledWidth / 2 - 75;
int y = scaledHeight - 90;
int texture = barrelRollTimer % 2 == 0 ? 1 : 2;
context.drawTexture(texture == 1 ? barrelRollTexture1 : barrelRollTexture2,
context.drawTexture(RenderLayer::getGuiTextured, texture == 1 ? barrelRollTexture1 : barrelRollTexture2,
x, y, 0, 0, 160, 160, 160, 160);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/do_a_barrel_roll.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"client.key.KeyBindingMixin",
"client.roll.CameraMixin",
"client.roll.DebugHudMixin",
"client.roll.EntityRendererMixin",
"client.roll.EntityRenderStateMixin",
"client.roll.MouseMixin",
"client.roll.PlayerEntityRendererMixin",
"client.roll.entity.ClientPlayerEntityMixin"
Expand Down
2 changes: 1 addition & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
id("me.modmuss50.mod-publish-plugin") version "0.5.+" apply false
}
stonecutter active "1.21-fabric" /* [SC] DO NOT EDIT */
stonecutter active "1.21.2-fabric" /* [SC] DO NOT EDIT */

stonecutter registerChiseled tasks.register("chiseledBuildAndCollect", stonecutter.chiseled) {
group = "project"
Expand Down
18 changes: 0 additions & 18 deletions versions/1.21-fabric/gradle.properties

This file was deleted.

18 changes: 18 additions & 0 deletions versions/1.21.2-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
loom.platform=fabric

# Global
deps.yarn_build=1
deps.compat=\
controlify=2.0.0-beta.14+1.21-fabric
deps.compat_runtime=

# Fabric
deps.fapi=0.106.1+1.21.2
deps.modmenu=12.0.0-beta.1
deps.yacl=3.6.0+1.21.2
deps.cicada=0.8.4-beta.1+1.21.2-and-above

# Mod
mod.mc_dep=>=1.21.2 <=1.21.2
mod.mc_title=1.21.2
mod.mc_targets=1.21.2

0 comments on commit 567eac8

Please sign in to comment.