Skip to content

Commit

Permalink
push unfinished changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Aug 20, 2024
1 parent 1fb52b4 commit 98289ea
Show file tree
Hide file tree
Showing 28 changed files with 550 additions and 638 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ archives_base_name=legacyanimations

# Dependencies
fabric_version=0.100.1+1.21
modmenu_version=10.0.0-beta.1
yacl_version=3.4.2+1.20.5
modmenu_version=11.0.1
yacl_version=3.5.0+1.21
devauth_version=1.2.0
32 changes: 10 additions & 22 deletions src/main/java/com/mixces/legacyanimations/LegacyAnimations.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,26 @@
import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;

public class LegacyAnimations implements ModInitializer
{
public class LegacyAnimations implements ModInitializer {

@Override
public void onInitialize()
{
public void onInitialize() {
LegacyAnimationsSettings.CONFIG.load();
updatePlayerState();
registerCommands();
}

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

if (player == null)
{
return;
}

if (player == null) return;
player.calculateDimensions();
});
}

private void registerCommands()
{
private void registerCommands() {
CommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess, environment) ->
{
(dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("legacyanimations")
.then(CommandManager.argument("x", FloatArgumentType.floatArg())
.executes(context -> {
Expand Down Expand Up @@ -80,7 +69,7 @@ private void registerCommands()
TransformHook.translationY = value2;
TransformHook.translationZ = value3;
TransformHook.rotationX = value4;
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4), false);
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4), false);
return 1;
})
.then(CommandManager.argument("yaw", FloatArgumentType.floatArg())
Expand All @@ -95,7 +84,7 @@ private void registerCommands()
TransformHook.translationZ = value3;
TransformHook.rotationX = value4;
TransformHook.rotationY = value5;
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4 + " pitch: " + value5), false);
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4 + " yaw: " + value5), false);
return 1;
})
.then(CommandManager.argument("roll", FloatArgumentType.floatArg())
Expand All @@ -112,12 +101,11 @@ private void registerCommands()
TransformHook.rotationX = value4;
TransformHook.rotationY = value5;
TransformHook.rotationZ = value6;
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4 + " pitch: " + value5 + " roll: " + value6), false);
context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4 + " yaw: " + value5 + " roll: " + value6), false);
return 1;
})

)))))));
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ public class LegacyAnimationsSettings {

@SerialEntry public boolean punchDuringUsage = true;
@SerialEntry public boolean itemPositions = true;
@SerialEntry public boolean oldSwordBlock = true; // TODO: this prevents an item in offhand (e.g., bow) from being used. Also causes to walk slow despite not actually blocking, may trigger ACs
// @SerialEntry public boolean blockWithShieldOnly = true; // this fixes the aforementioned issue by requiring a shield in offhand
@SerialEntry public boolean oldSwordBlock = true;
@SerialEntry public boolean hideShields = true;
@SerialEntry public boolean hideShieldHotbar = true;
@SerialEntry public boolean noCooldown = true;
// @SerialEntry public boolean oldMovement = true; // already in viafabric
@SerialEntry public boolean oldSneaking = true;
@SerialEntry public boolean oldWalking = true;
@SerialEntry public boolean oldCape = true;
@SerialEntry public boolean oldDeath = true;
@SerialEntry public boolean oldSwim = true;
@SerialEntry public boolean oldHearts = true;
Expand All @@ -37,7 +36,6 @@ public class LegacyAnimationsSettings {
@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;

Expand Down Expand Up @@ -73,12 +71,6 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldSwordBlock, () -> config.oldSwordBlock, newVal -> config.oldSwordBlock = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
// .option(Option.createBuilder(boolean.class)
// .name(Text.literal("Block Only when Holding Shield"))
// .description(OptionDescription.of(Text.of("Only blocks with your sword when you hold a shield in your offhand.")))
// .binding(defaults.blockWithShieldOnly, () -> config.blockWithShieldOnly, newVal -> config.blockWithShieldOnly = newVal)
// .controller(TickBoxControllerBuilder::create)
// .build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Hide Shield Model"))
.description(OptionDescription.of(Text.of("Hides the shield model from rendering.")))
Expand Down Expand Up @@ -148,6 +140,12 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldWalking, () -> config.oldWalking, newVal -> config.oldWalking = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Cape Physics"))
.description(OptionDescription.of(Text.of("Reverts the cape physics to it's former glory.")))
.binding(defaults.oldCape, () -> config.oldCape, newVal -> config.oldCape = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Entity Death Animation"))
.description(OptionDescription.of(Text.of("Allows dead entity corpse limbs to move.")))
Expand All @@ -171,12 +169,6 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.noCooldown, () -> config.noCooldown, newVal -> config.noCooldown = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Movement"))
.description(OptionDescription.of(Text.of("Completely stops the player's sprint while blocking, drawing a bow, or consuming a consumable item.")))
.binding(defaults.oldMovement, () -> config.oldMovement, newVal -> config.oldMovement = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old View Bobbing"))
.description(OptionDescription.of(Text.of("Changes the held item's position while moving based on the player's yaw")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Arm;
Expand Down Expand Up @@ -305,17 +303,4 @@ 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
@@ -0,0 +1,35 @@
package com.mixces.legacyanimations.mixin;

import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = CapeFeatureRenderer.class)
public class CapeFeatureRendererMixin {

@Redirect(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/math/MathHelper;lerpAngleDegrees(FFF)F"
)
)
private float legacyAnimations$useLerp(float delta, float start, float end) {
return LegacyAnimationsSettings.getInstance().oldCape ? MathHelper.lerp(delta, start, end) : MathHelper.lerpAngleDegrees(delta, start, end);
}

@Redirect(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F",
ordinal = 2
)
)
private float legacyAnimations$removeClamp(float value, float min, float max) {
return LegacyAnimationsSettings.getInstance().oldCape ? value : MathHelper.clamp(value, min, max);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mixces.legacyanimations.mixin;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
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;
Expand All @@ -10,17 +10,55 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Arm;
import net.minecraft.util.math.RotationAxis;
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.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(HeldItemFeatureRenderer.class)
public class HeldItemFeatureRendererMixin {

@ModifyArgs(
method = "renderItem",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V"
)
)
private void legacyAnimations$revertTranslation(Args args) {
args.setAll((float) args.get(0) * -1.0F, 0.4375F, (float) args.get(2) / 10 * -1.0F);
}

@WrapWithCondition(
method = "renderItem",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V",
ordinal = 0
)
)
private boolean legacyAnimations$removeExtraMultiply(MatrixStack instance, Quaternionf quaternion) {
return !LegacyAnimationsSettings.getInstance().itemPositions;
}

@WrapWithCondition(
method = "renderItem",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V",
ordinal = 1
)
)
private boolean legacyAnimations$removeExtraMultiply2(MatrixStack instance, Quaternionf quaternion) {
return !LegacyAnimationsSettings.getInstance().itemPositions;
}

@Inject(
method = "renderItem",
at = @At(
Expand All @@ -29,14 +67,61 @@ 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 && entity.isBlocking() &&
ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) &&
ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) {
final MatrixUtil matrix = new MatrixUtil(matrices);
// if (LegacyAnimationsSettings.getInstance().oldSwordBlock && entity.isBlocking() &&
// ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) &&
// ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) {
//
// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ);
// matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ);
// }
final MatrixUtil matrix = new MatrixUtil(matrices);
// matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ);
// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ);

matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ);
matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ);
Item item = stack.getItem();
float var7;
if (item instanceof BlockItem) {
var7 = 0.375F;
matrices.translate(0.0F, 0.1875F, -0.3125F);
matrix.pitch(20.0F).yaw(45.0F);
matrices.scale(-var7, -var7, var7);
} else if (item == Items.BOW) {
var7 = 0.625F;
matrices.translate(0.0F, 0.125F, 0.3125F);
matrix.yaw(-20.0F);
matrices.scale(var7, -var7, var7);
matrix.pitch(-100.0F).yaw(45.0F);
} else if (ItemUtils.INSTANCE.isFull3d(stack)) {
var7 = 0.625F;
if (ItemUtils.INSTANCE.shouldRotateAroundWhenRendering(stack, true)) {
matrix.roll(180.0F);
matrices.translate(0.0F, -0.125F, 0.0F);
}
if (entity instanceof PlayerEntity && entity.getItemUseTime() > 0 && entity.isBlocking()) {
matrices.translate(0.05F, 0.0F, -0.1F);
matrix.yaw(-50.0F).pitch(-10.0F).roll(-60.0F);
}
matrices.translate(0.0F, 0.1875F, 0.0F);
matrices.scale(var7, var7, var7);
matrix.pitch(-100.0F).yaw(45.0F);
} else {
var7 = 0.375F;
matrices.translate(0.25F, 0.1875F, -0.1875F);
matrices.scale(var7, var7, var7);
matrix.roll(60.0F).pitch(-90.0F).roll(20.0F);
}
// x: -0.2 y: 0.0 z: 0.1 yaw: 21.0 pitch: 90.0 roll: -90.0
}

@ModifyArg(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/entity/feature/HeldItemFeatureRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;Lnet/minecraft/util/Arm;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"
),
index = 2
)
private ModelTransformationMode legacyAnimations$changeTransformType(ModelTransformationMode renderMode) {
return LegacyAnimationsSettings.getInstance().itemPositions ? ModelTransformationMode.NONE : renderMode;
}
}
Loading

0 comments on commit 98289ea

Please sign in to comment.