Skip to content

Commit

Permalink
devauth and try to use mixinextras where we can
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jan 30, 2024
1 parent 93e9323 commit 7dde0ef
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {
maven { url = "https://maven.isxander.dev/releases" }
maven { url = "https://maven.terraformersmc.com/releases" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" }
}

loom {
Expand All @@ -24,9 +25,9 @@ loom {
}

dependencies {
modImplementation("dev.isxander.yacl:yet-another-config-lib-fabric:${yaclVersion}")
modImplementation("dev.isxander.yacl:yet-another-config-lib-fabric:${yacl_version}")

modImplementation("com.terraformersmc:modmenu:${project.modMenuVersion}")
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")

// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -36,6 +37,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}")
}

processResources {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ archives_base_name=oldanimations

# Dependencies
fabric_version=0.95.0+1.20.4
modMenuVersion=9.0.0
yaclVersion=3.3.2+1.20.4
modmenu_version=9.0.0
yacl_version=3.3.2+1.20.4
devauth_version=1.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ private void breakBlock_attackBlock_isCurrentlyBreaking_damageSync(CallbackInfoR
syncSelectedSlot();
}

// can probably be done with WrapOperation (see below) but I don't know exactly what this is for and don't know how to test
@Redirect(method = "updateBlockBreakingProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isCurrentlyBreaking(Lnet/minecraft/util/math/BlockPos;)Z"))
public boolean updateBlockBreakingProgress_fixDestroy(ClientPlayerInteractionManager instance, BlockPos pos) {
return isCurrentlyBreaking(pos) && isBreakingBlock();
}

// @WrapOperation(method = "updateBlockBreakingProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isCurrentlyBreaking(Lnet/minecraft/util/math/BlockPos;)Z"))
// public boolean updateBlockBreakingProgress_fixDestroy(ClientPlayerInteractionManager instance, BlockPos pos, Operation<Boolean> original) {
// return original.call(instance, pos) && isBreakingBlock();
// }

@SuppressWarnings("ConstantConditions")
@Inject(method = "updateBlockBreakingProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;syncSelectedSlot()V", shift = At.Shift.AFTER), cancellable = true)
public void updateBlockBreakingProgress_cancelDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mixces.oldanimations.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mixces.oldanimations.config.OldAnimationsSettings;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -16,7 +16,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand All @@ -40,11 +39,11 @@ private void renderItem_bowHit(AbstractClientPlayerEntity player, float tickDelt
}
}

@Redirect(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
public float simplified$renderItemInFirstPerson(ClientPlayerEntity instance, float v) {
@ModifyExpressionValue(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
public float simplified$renderItemInFirstPerson(float original) {
if (OldAnimationsSettings.CONFIG.instance().noCooldown)
return 1.0F;
return instance.getAttackCooldownProgress(v);
return original;
}

@Inject(method = "resetEquipProgress", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mixces.oldanimations.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mixces.oldanimations.config.OldAnimationsSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
Expand All @@ -16,7 +18,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(MinecraftClient.class)
Expand Down Expand Up @@ -50,9 +51,9 @@ public void handleBlockBreaking_blockHitAnimation(boolean breaking, CallbackInfo
}
}

@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
private boolean doItemUse_allowPunching(ClientPlayerInteractionManager instance) {
return !OldAnimationsSettings.CONFIG.instance().punchDuringUsage && instance.isBreakingBlock();
@WrapOperation(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
private boolean doItemUse_allowPunching(ClientPlayerInteractionManager instance, Operation<Boolean> original) {
return !OldAnimationsSettings.CONFIG.instance().punchDuringUsage && original.call(instance);
}

}

0 comments on commit 7dde0ef

Please sign in to comment.