Skip to content

Commit

Permalink
stylistic choice!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Jul 17, 2024
1 parent 893b31d commit 6041220
Show file tree
Hide file tree
Showing 33 changed files with 344 additions and 173 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ archives_base_name=legacyanimations
# Dependencies
fabric_version=0.97.8+1.20.6
modmenu_version=10.0.0-beta.1
yacl_version=3.4.0+1.20.5
yacl_version=3.4.2+1.20.5
devauth_version=1.2.0
12 changes: 8 additions & 4 deletions src/main/java/com/mixces/legacyanimations/LegacyAnimations.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;

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

@Override
public void onInitialize() {
public void onInitialize()
{
LegacyAnimationsSettings.CONFIG.load();
ClientTickEvents.END_WORLD_TICK.register(world -> {
if (MinecraftClient.getInstance().player != null) {
ClientTickEvents.END_WORLD_TICK.register(world ->
{
if (MinecraftClient.getInstance().player != null)
{
MinecraftClient.getInstance().player.calculateDimensions();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

public class LegacyAnimationsSettings {

//todo ugly as hell

public static final ConfigClassHandler<LegacyAnimationsSettings> CONFIG = ConfigClassHandler.createBuilder(LegacyAnimationsSettings.class)
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("legacyanimations.json"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
public class ModMenuIntegration implements ModMenuApi
{

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
public ConfigScreenFactory<?> getModConfigScreenFactory()
{
return LegacyAnimationsSettings::configScreen;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mixces.legacyanimations.duck;

public interface PlayerPitchInterface {
public interface PlayerPitchInterface
{

float legacyAnimations$getPrevPlayerPitch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Camera.class)
public interface AccessorCamera {
public interface AccessorCamera
{

@Accessor float getCameraY();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ArmorFeatureRenderer.class)
public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extends BipedEntityModel<T>> {
public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extends BipedEntityModel<T>>
{

@Unique public T legacyAnimations$entity;
@Unique private T legacyAnimations$entity;

@Inject(
method = "renderArmor",
at = @At(
value = "HEAD"
)
)
private void legacyAnimations$setEntity(MatrixStack matrices, VertexConsumerProvider vertexConsumers, T entity, EquipmentSlot armorSlot, int light, A model, CallbackInfo ci) {
private void legacyAnimations$setEntity(MatrixStack matrices, VertexConsumerProvider vertexConsumers, T entity, EquipmentSlot armorSlot, int light, A model, CallbackInfo ci)
{
legacyAnimations$entity = entity;
}

Expand All @@ -40,11 +42,13 @@ public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extend
target = "Lnet/minecraft/client/render/VertexConsumerProvider;getBuffer(Lnet/minecraft/client/render/RenderLayer;)Lnet/minecraft/client/render/VertexConsumer;"
)
)
private RenderLayer legacyAnimations$useEntityLayerRenderer(RenderLayer var1, @Local(ordinal = 0, argsOnly = true) Identifier overlay) {
if (LegacyAnimationsSettings.CONFIG.instance().armorTint) {
return RenderLayer.getEntityCutoutNoCullZOffset(overlay);
private RenderLayer legacyAnimations$useEntityLayerRenderer(RenderLayer var1, @Local(ordinal = 0, argsOnly = true) Identifier overlay)
{
if (!LegacyAnimationsSettings.CONFIG.instance().armorTint)
{
return var1;
}
return var1;
return RenderLayer.getEntityCutoutNoCullZOffset(overlay);
}

@ModifyArg(
Expand All @@ -55,15 +59,18 @@ public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extend
),
index = 3
)
private int legacyAnimations$useDamageUVOverlay(int par3) {
if (LegacyAnimationsSettings.CONFIG.instance().armorTint) {
return OverlayTexture.packUv(OverlayTexture.getU(0.0F), OverlayTexture.getV(isEntityDying(legacyAnimations$entity)));
private int legacyAnimations$useDamageUVOverlay(int par3)
{
if (!LegacyAnimationsSettings.CONFIG.instance().armorTint)
{
return par3;
}
return par3;
return OverlayTexture.packUv(OverlayTexture.getU(0.0F), OverlayTexture.getV(isEntityDying(legacyAnimations$entity)));
}

@Unique
private boolean isEntityDying(T entity) {
private boolean isEntityDying(T entity)
{
return entity.deathTime > 0 || entity.hurtTime > 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(BipedEntityModel.class)
public abstract class BipedEntityModelMixin<T extends LivingEntity> {
public abstract class BipedEntityModelMixin<T extends LivingEntity>
{

@Shadow public BipedEntityModel.ArmPose leftArmPose;
@Shadow public BipedEntityModel.ArmPose rightArmPose;
Expand All @@ -32,17 +33,21 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
ordinal = 1
)
)
private void legacyAnimations$fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) {
private void legacyAnimations$fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage)
{
rightArm.roll = 0.0F;
leftArm.roll = 0.0F;
if (rightArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) {
if (rightArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW)
{
rightArm.yaw = -0.1F + head.yaw;
leftArm.yaw = 0.1F + head.yaw + 0.4F;
rightArm.pitch = (float) (-Math.PI / 2) + head.pitch;
leftArm.pitch = (float) (-Math.PI / 2) + head.pitch;
}
if (leftArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) {
if (leftArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW)
{
rightArm.yaw = -0.1F + head.yaw - 0.4F;
leftArm.yaw = 0.1F + head.yaw;
rightArm.pitch = (float) (-Math.PI / 2) + head.pitch;
Expand Down Expand Up @@ -73,8 +78,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
)
)
)
private void legacyAnimations$oldSneakValue1(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) {
private void legacyAnimations$oldSneakValue1(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
{
rightLeg.pivotY = 9.0f;
}
}
Expand All @@ -101,8 +108,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
)
)
)
private void legacyAnimations$oldSneakValue2(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) {
private void legacyAnimations$oldSneakValue2(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
{
leftLeg.pivotY = 9.0f;
}
}
Expand All @@ -116,8 +125,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
ordinal = 9
)
)
private void legacyAnimations$oldSneakValue3(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) {
private void legacyAnimations$oldSneakValue3(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
{
rightLeg.pivotZ = 0.1f;
}
}
Expand All @@ -131,8 +142,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
ordinal = 5
)
)
private void legacyAnimations$oldSneakValue4(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) {
private void legacyAnimations$oldSneakValue4(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
{
leftLeg.pivotZ = 0.1f;
}
}
Expand All @@ -146,8 +159,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
ordinal = 2
)
)
private void legacyAnimations$oldSneakValue5(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) {
private void legacyAnimations$oldSneakValue5(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
{
head.pivotY = 1.0f;
}
}
Expand All @@ -174,7 +189,8 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
target = "Lnet/minecraft/client/model/ModelPart;pivotY:F"
)
)
public boolean legacyAnimations$removeConflictingFields1(ModelPart instance, float value) {
public boolean legacyAnimations$removeConflictingFields1(ModelPart instance, float value)
{
return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking;
}

Expand All @@ -200,7 +216,8 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
target = "Lnet/minecraft/client/model/ModelPart;pivotY:F"
)
)
public boolean legacyAnimations$removeConflictingFields2(ModelPart instance, float value) {
public boolean legacyAnimations$removeConflictingFields2(ModelPart instance, float value)
{
return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking;
}

Expand All @@ -210,8 +227,10 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
value = "TAIL"
)
)
public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) {
public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock)
{
arm.pitch = arm.pitch * 0.5F - (float) (Math.PI / 3);
arm.yaw = 0.0F;
}
Expand All @@ -225,7 +244,8 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
),
index = 0
)
private ModelPart legacyAnimations$switchBlockingArm1(ModelPart arm) {
private ModelPart legacyAnimations$switchBlockingArm1(ModelPart arm)
{
return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? rightArm : arm;
}

Expand All @@ -237,7 +257,8 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity> {
),
index = 0
)
private ModelPart legacyAnimations$switchBlockingArm2(ModelPart arm) {
private ModelPart legacyAnimations$switchBlockingArm2(ModelPart arm)
{
return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? leftArm : arm;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import org.spongepowered.asm.mixin.injection.At;

@Mixin(BuiltinModelItemRenderer.class)
public class BuiltinModelItemRendererMixin {
public class BuiltinModelItemRendererMixin
{

@ModifyExpressionValue(
method = "render",
Expand All @@ -23,11 +24,13 @@ public class BuiltinModelItemRendererMixin {
ordinal = 0
)
)
private boolean legacyAnimations$disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (LegacyAnimationsSettings.CONFIG.instance().hideShields && TransformationModeUtils.isValidPerspective(mode)) {
return !ItemUtils.INSTANCE.isValidItem(stack, stack.getUseAction());
private boolean legacyAnimations$disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay)
{
if (LegacyAnimationsSettings.CONFIG.instance().hideShields && TransformationModeUtils.isValidPerspective(mode))
{
return original;
}
return original;
return !ItemUtils.INSTANCE.isValidItem(stack, stack.getUseAction());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Camera.class)
public abstract class CameraMixin {
public abstract class CameraMixin
{

@Shadow private float cameraY;
@Shadow private Entity focusedEntity;
Expand All @@ -26,7 +27,8 @@ public abstract class CameraMixin {
cancellable = true
)
private void legacyAnimations$addOldSneakCalculation(CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking && focusedEntity.getStandingEyeHeight() < cameraY) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking && focusedEntity.getStandingEyeHeight() < cameraY)
{
cameraY = focusedEntity.getStandingEyeHeight();
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ClientPlayerInteractionManager.class)
public abstract class ClientPlayerInteractionManagerMixin {
public abstract class ClientPlayerInteractionManagerMixin
{

@Shadow @Final private MinecraftClient client;
@Shadow public abstract boolean isBreakingBlock();
Expand All @@ -26,7 +27,8 @@ public abstract class ClientPlayerInteractionManagerMixin {
target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isCurrentlyBreaking(Lnet/minecraft/util/math/BlockPos;)Z"
)
)
public boolean legacyAnimations$fixBreakingBlockCheck(boolean original) {
public boolean legacyAnimations$fixBreakingBlockCheck(boolean original)
{
return (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage || isBreakingBlock()) && original;
}

Expand All @@ -38,8 +40,10 @@ public abstract class ClientPlayerInteractionManagerMixin {
shift = At.Shift.AFTER
),
cancellable = true)
public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage && client.player != null && client.player.isUsingItem()) {
public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir)
{
if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage && client.player != null && client.player.isUsingItem())
{
cir.setReturnValue(true);
}
}
Expand Down
Loading

0 comments on commit 6041220

Please sign in to comment.