Skip to content

Commit

Permalink
progress has been rather silly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Jul 26, 2024
1 parent d8e69d2 commit bc2110b
Show file tree
Hide file tree
Showing 22 changed files with 411 additions and 117 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/mixces/legacyanimations/LegacyAnimations.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;

Expand All @@ -17,16 +18,27 @@ public class LegacyAnimations implements ModInitializer
public void onInitialize()
{
LegacyAnimationsSettings.CONFIG.load();
updatePlayerState();
registerCommands();
}

private void updatePlayerState()
{
ClientTickEvents.END_WORLD_TICK.register(world ->
{
if (MinecraftClient.getInstance().player == null)
final ClientPlayerEntity player = MinecraftClient.getInstance().player;

if (player == null)
{
return;
}

MinecraftClient.getInstance().player.calculateDimensions();
player.calculateDimensions();
});
}

private void registerCommands()
{
CommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess, environment) ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class LegacyAnimationsSettings {
@SerialEntry public boolean fastItems = true;
@SerialEntry public boolean armorTint = true;
@SerialEntry public boolean oldBreakProgress = true;
@SerialEntry public boolean oldDamageTilt = true;
// @SerialEntry public boolean noSwing = true;
@SerialEntry public boolean oldPotionGlint = true;
@SerialEntry public boolean noShieldDelay = true;


@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -87,6 +91,12 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.hideShieldHotbar, () -> config.hideShieldHotbar, newVal -> config.hideShieldHotbar = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Remove Shield Delay"))
.description(OptionDescription.of(Text.of("Removes the 5ms delay preventing you from instantly activating your shield.")))
.binding(defaults.noShieldDelay, () -> config.noShieldDelay, newVal -> config.noShieldDelay = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

.category(ConfigCategory.createBuilder()
Expand Down Expand Up @@ -173,6 +183,12 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldViewBob, () -> config.oldViewBob, newVal -> config.oldViewBob = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Damage Tilt"))
.description(OptionDescription.of(Text.of("Changes the yaw component of the damage tilt.")))
.binding(defaults.oldViewBob, () -> config.oldViewBob, newVal -> config.oldViewBob = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Projectiles"))
.description(OptionDescription.of(Text.of("Reverts the projectile's positions back to the older style.")))
Expand All @@ -191,6 +207,18 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldBreakProgress, () -> config.oldBreakProgress, newVal -> config.oldBreakProgress = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
// .option(Option.createBuilder(boolean.class)
// .name(Text.literal("Old Item Throw/Drop"))
// .description(OptionDescription.of(Text.of("Disables the swing animation while throwing/dropping items.")))
// .binding(defaults.noSwing, () -> config.noSwing, newVal -> config.noSwing = newVal)
// .controller(TickBoxControllerBuilder::create)
// .build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Potion Glint"))
.description(OptionDescription.of(Text.of("Brings back the enchantment glint on potions!")))
.binding(defaults.oldPotionGlint, () -> config.oldPotionGlint, newVal -> config.oldPotionGlint = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

)).generateScreen(parent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.mixces.legacyanimations.handler;

import com.mixces.legacyanimations.mixin.access.ILivingEntityMixin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket;
import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;

public class FakeSwingHandler {

// public static FakeSwingHandler INSTANCE = new FakeSwingHandler();
//
// public boolean handSwinging;
// public Hand preferredHand;
// public int handSwingTicks;
// public float lastHandSwingProgress;
// public float handSwingProgress;
//
// public void swingHand2(ClientPlayerEntity player, Hand hand) {
// this.swingHand(player, hand);
//
// if (MinecraftClient.getInstance().getNetworkHandler() == null)
// {
// return;
// }
//
// MinecraftClient.getInstance().getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand));
// }
//
// public void swingHand(ClientPlayerEntity player, Hand hand) {
// this.swingHand(player, hand, false);
// }
//
// public void swingHand(ClientPlayerEntity player, Hand hand, boolean fromServerPlayer) {
// final int handSwingDuration = ((ILivingEntityMixin) player).invokeGetHandSwingDuration();
//
// if (!this.handSwinging || this.handSwingTicks >= handSwingDuration / 2 || this.handSwingTicks < 0) {
// this.handSwingTicks = -1;
// this.handSwinging = true;
// this.preferredHand = hand;
// if (MinecraftClient.getInstance().g instanceof ServerWorld) {
// EntityAnimationS2CPacket entityAnimationS2CPacket = new EntityAnimationS2CPacket(this, hand == Hand.MAIN_HAND ? EntityAnimationS2CPacket.SWING_MAIN_HAND : EntityAnimationS2CPacket.SWING_OFF_HAND);
// ServerChunkManager serverChunkManager = ((ServerWorld)this.getWorld()).getChunkManager();
// if (fromServerPlayer) {
// serverChunkManager.sendToNearbyPlayers(this, entityAnimationS2CPacket);
// } else {
// serverChunkManager.sendToOtherNearbyPlayers(this, entityAnimationS2CPacket);
// }
// }
// }
// }
//
// protected void tickHandSwing(ClientPlayerEntity player) {
// int i = ((ILivingEntityMixin) player).invokeGetHandSwingDuration();
// if (this.handSwinging) {
// ++this.handSwingTicks;
// if (this.handSwingTicks >= i) {
// this.handSwingTicks = 0;
// this.handSwinging = false;
// }
// } else {
// this.handSwingTicks = 0;
// }
// this.handSwingProgress = (float)this.handSwingTicks / (float)i;
// }
//
// public float getHandSwingProgress(float tickDelta) {
// float f = this.handSwingProgress - this.lastHandSwingProgress;
// if (f < 0.0f) {
// f += 1.0f;
// }
// return this.lastHandSwingProgress + f * tickDelta;
// }
//
// public void setHandSwingProgress()
// {
// this.lastHandSwingProgress = this.handSwingProgress;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
@Shadow @Final public ModelPart leftLeg;
@Shadow protected abstract ModelPart getArm(Arm arm);

@Shadow @Final public ModelPart body;

@Inject(
method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V",
at = @At(
Expand Down Expand Up @@ -276,7 +274,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
return !LegacyAnimationsSettings.getInstance().oldSneaking;
}

@WrapOperation(
@ModifyExpressionValue(
method = "animateArms",
at = @At(
value = "FIELD",
Expand All @@ -285,23 +283,23 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
ordinal = 9
)
)
public float legacyAnimations$removeConflictingFields3(ModelPart instance, Operation<Float> original)
public float legacyAnimations$mirrorSwing1(float original, @Local Arm arm)
{
return 0.0F;
return (arm == Arm.LEFT ? -1 : 1) * original;
}

@Inject(
@WrapOperation(
method = "animateArms",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;handSwingProgress:F",
ordinal = 2
target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftArm:Lnet/minecraft/client/model/ModelPart;",
ordinal = 3
)
)
public void legacyAnimations$mirrorSwing(T entity, float animationProgress, CallbackInfo ci, @Local Arm arm, @Local ModelPart modelPart)
public ModelPart legacyAnimations$mirrorSwing2(BipedEntityModel<T> instance, Operation<ModelPart> original, @Local ModelPart modelPart)
{
modelPart.pitch += (arm == Arm.LEFT ? -1 : 1) * body.yaw;
return modelPart;
}

@ModifyExpressionValue(
Expand All @@ -312,7 +310,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
ordinal = 5
)
)
public float legacyAnimations$mirrorSwing2(float original, @Local Arm arm)
public float legacyAnimations$mirrorSwing3(float original, @Local Arm arm)
{
return (arm == Arm.LEFT ? -1 : 1) * original;
}
Expand All @@ -334,4 +332,16 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
arm.yaw = (rightArm ? -1.0f : 1.0f) * (float) (-Math.PI / 6);
}

@WrapOperation(
method = "positionRightArm",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel$ArmPose;ordinal()I"
)
)
private int shit(BipedEntityModel.ArmPose instance, Operation<Integer> original)
{
return 2;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.duck.EntityInterface;
import com.mixces.legacyanimations.mixin.interfaces.ICameraMixin;
import com.mixces.legacyanimations.mixin.access.ICameraMixin;
import com.mixces.legacyanimations.util.HandUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.mixces.legacyanimations.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.duck.PlayerPitchInterface;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
Expand All @@ -17,6 +20,21 @@
public class GameRendererMixin
{

@WrapOperation(
method = "tiltViewWhenHurt",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/LivingEntity;getDamageTiltYaw()F"
)
)
private float legacyAnimations$revertYaw(LivingEntity instance, Operation<Float> original) {
if (!LegacyAnimationsSettings.getInstance().oldDamageTilt)
{
return original.call(instance);
}
return 0.0F;
}

@Inject(
method = "bobView",
at = @At(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.hook.TransformHook;
import com.mixces.legacyanimations.util.ItemUtils;
import com.mixces.legacyanimations.util.MatrixUtil;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer;
import net.minecraft.client.render.model.json.ModelTransformationMode;
Expand All @@ -29,30 +30,15 @@ public class HeldItemFeatureRendererMixin {
)
private void legacyAnimations$swordBlockTransform(LivingEntity entity, ItemStack stack, ModelTransformationMode transformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.getInstance().oldSwordBlock)
{
return;
}
// if (LegacyAnimationsSettings.getInstance().oldSwordBlock && entity.isBlocking() &&
// ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) &&
// ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack()))
// {
final MatrixUtil matrix = new MatrixUtil(matrices);

if (!entity.isBlocking())
{
return;
}

if (ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) && ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack()))
{
matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ);
matrices.multiply(RotationAxis.POSITIVE_X.rotation(TransformHook.rotationX));
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(TransformHook.rotationY));
matrices.multiply(RotationAxis.POSITIVE_Z.rotation(TransformHook.rotationZ));
}

// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ);
// matrices.multiply(RotationAxis.POSITIVE_X.rotation(TransformHook.rotationX));
// matrices.multiply(RotationAxis.POSITIVE_Y.rotation(TransformHook.rotationY));
// matrices.multiply(RotationAxis.POSITIVE_Z.rotation(TransformHook.rotationZ));


matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ);
// }

// x: -0.2 y: 0.0 z: 0.1 yaw: 21.0 pitch: 90.0 roll: -90.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.util.HandUtils;
import com.mixces.legacyanimations.util.ItemUtils;
import com.mixces.legacyanimations.util.MatrixUtil;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
Expand All @@ -18,10 +19,7 @@
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(HeldItemRenderer.class)
Expand Down Expand Up @@ -126,11 +124,10 @@ public abstract class HeldItemRendererMixin
}

final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher);
final MatrixUtil matrix = new MatrixUtil(matrices);

matrices.translate(l * -0.14142136F, 0.08F, 0.14142136F);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25F));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 13.365F));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * 78.05F));
matrix.pitch(-102.25F).yaw(l * 13.365F).roll(l * 78.05F);
}

@Inject(
Expand Down
Loading

0 comments on commit bc2110b

Please sign in to comment.