aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/dulkirfabric
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-07-18 12:27:13 -0500
committeringlettronald <inglettronald@gmail.com>2023-07-18 12:27:13 -0500
commit053db047a053cfa4b510d872802434a922275326 (patch)
tree799e113dcc22c85432ef355d5919ebb0f61a36f9 /src/main/java/com/dulkirfabric
parent9cd4efc009d45dd671908e8cdc3477aaf14550e6 (diff)
downloadDulkirMod-Fabric-053db047a053cfa4b510d872802434a922275326.tar.gz
DulkirMod-Fabric-053db047a053cfa4b510d872802434a922275326.tar.bz2
DulkirMod-Fabric-053db047a053cfa4b510d872802434a922275326.zip
More Entity/Animation fixes
Diffstat (limited to 'src/main/java/com/dulkirfabric')
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/HeldItemRendererMixin.java21
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java38
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java2
3 files changed, 55 insertions, 6 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/render/HeldItemRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/HeldItemRendererMixin.java
index 664af0d..f0e6422 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/HeldItemRendererMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/HeldItemRendererMixin.java
@@ -1,6 +1,8 @@
package com.dulkirfabric.mixin.render;
import com.dulkirfabric.config.DulkirConfig;
+import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
+import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.HeldItemRenderer;
@@ -9,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RotationAxis;
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;
@@ -16,7 +19,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
// SOURCE FOR A LOT OF THIS: https://github.com/cosrnic/smallviewmodel/blob/main/src/main/java/uk/cosrnic/smallviewmodel/mixin/MixinHeldItemRenderer.java
@Mixin(HeldItemRenderer.class)
-public class HeldItemRendererMixin {
+public abstract class HeldItemRendererMixin {
+ @Shadow public abstract void resetEquipProgress(Hand hand);
+
+ @Shadow private float equipProgressMainHand;
+
+ @Shadow private float equipProgressOffHand;
+
@Inject(method = "renderFirstPersonItem(Lnet/minecraft/client/network/AbstractClientPlayerEntity;FFLnet/minecraft/util/Hand;FLnet/minecraft/item/ItemStack;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
public void onRenderHeldItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
@@ -38,4 +47,14 @@ public class HeldItemRendererMixin {
matrices.translate(posX, posY, posZ);
}
}
+
+ /**
+ * Stop the weird mid-swing bobbing animation from happening
+ * @param original
+ * @return 1f if enabled, else original
+ */
+ @ModifyExpressionValue(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
+ public float attackCooldown(float original) {
+ return 1f;
+ }
}
diff --git a/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java b/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java
index badac4c..c0f9a03 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java
@@ -1,20 +1,31 @@
package com.dulkirfabric.mixin.render;
+import com.dulkirfabric.config.DulkirConfig;
import com.dulkirfabric.util.GlowingEntityInterface;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.text.Text;
+import net.minecraft.util.Hand;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
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.CallbackInfoReturnable;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.awt.*;
@Mixin(LivingEntity.class)
public class LivingEntityMixin implements GlowingEntityInterface {
+ @Shadow
+ public float handSwingProgress;
+ @Unique
+ private int animationTicks;
+
@Unique
private boolean shouldGlow_DulkirMod;
@Unique
@@ -45,8 +56,25 @@ public class LivingEntityMixin implements GlowingEntityInterface {
return shouldESP_DulkirMod;
}
- @Inject(method = "getHandSwingDuration()I", at = @At("HEAD"), cancellable = true)
- public void getHandSwingDuration(CallbackInfoReturnable<Integer> cir) {
- cir.setReturnValue(50);
+ @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;tickNewAi()V",
+ shift = At.Shift.AFTER))
+ public void onWhatever(CallbackInfo ci) {
+ if (DulkirConfig.ConfigVars.getConfigOptions().getHandSwingDuration() == 6) return;
+ if (animationTicks > DulkirConfig.ConfigVars.getConfigOptions().getHandSwingDuration()) {
+ animationTicks = 0;
+ }
+ if (animationTicks == 0) {
+ handSwingProgress = 1F;
+ } else {
+ handSwingProgress = (animationTicks - 1F) / DulkirConfig.ConfigVars.getConfigOptions().getHandSwingDuration();
+ animationTicks++;
+ }
+ }
+
+ @Inject(method = "swingHand(Lnet/minecraft/util/Hand;Z)V", at = @At("HEAD"))
+ public void onSwing(Hand hand, boolean fromServerPlayer, CallbackInfo ci) {
+ if (animationTicks == 0) {
+ animationTicks = 1;
+ }
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java
index db235df..03ffbd0 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java
@@ -69,6 +69,7 @@ public class WorldRendererMixin {
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderDispatcher;shouldRender(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/render/Frustum;DDD)Z"))
public void setOutlineESP(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci, @Local Entity entity) {
+ this.bufferBuilders.getEntityVertexConsumers().drawCurrentLayer();
if (entity instanceof GlowingEntityInterface dEntity && dEntity.shouldDulkirEntityGlow() && !dEntity.shouldDulkirEntityESP()) {
if (this.entityOutlinesFramebuffer != null)
this.entityOutlinesFramebuffer.copyDepthFrom(mc.getFramebuffer());
@@ -77,5 +78,6 @@ public class WorldRendererMixin {
if (this.entityOutlinesFramebuffer != null)
this.entityOutlinesFramebuffer.copyDepthFrom(defaultEntityOutlineBuffer);
}
+ this.client.getFramebuffer().beginWrite(false);
}
}