Skip to content

Commit

Permalink
change some config stuff + new features (i swear it existed in this m…
Browse files Browse the repository at this point in the history
…od before)
  • Loading branch information
Mixces committed Jul 24, 2024
1 parent f6f8df0 commit 96f2554
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ 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"))
.build())
.build();

@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 hideShields = true;
@SerialEntry public boolean hideShieldHotbar = true;
@SerialEntry public boolean noCooldown = true;
@SerialEntry public boolean oldMovement = true;
@SerialEntry public boolean oldSneaking = true;
@SerialEntry public boolean oldWalking = true;
@SerialEntry public boolean oldDeath = true;
Expand All @@ -40,6 +35,7 @@ public class LegacyAnimationsSettings {
@SerialEntry public boolean oldViewBob = true;
@SerialEntry public boolean fastItems = true;
@SerialEntry public boolean armorTint = true;
@SerialEntry public boolean oldBreakProgress = true;


@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -165,6 +161,12 @@ 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 All @@ -183,9 +185,30 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.fastItems, () -> config.fastItems, newVal -> config.fastItems = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Block Break Progress"))
.description(OptionDescription.of(Text.of("Delays the block breaking animation.")))
.binding(defaults.oldBreakProgress, () -> config.oldBreakProgress, newVal -> config.oldBreakProgress = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

)).generateScreen(parent);
}

public static final ConfigClassHandler<LegacyAnimationsSettings> CONFIG = ConfigClassHandler
.createBuilder(LegacyAnimationsSettings.class)
.serializer(config ->
GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance()
.getConfigDir()
.resolve("legacyanimations.json"))
.build())
.build();

public static LegacyAnimationsSettings getInstance()
{
return CONFIG.instance();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extend
)
private RenderLayer legacyAnimations$useEntityLayerRendererArmor(RenderLayer var1, @Local(ordinal = 0, argsOnly = true) Identifier overlay)
{
if (!LegacyAnimationsSettings.CONFIG.instance().armorTint)
if (!LegacyAnimationsSettings.getInstance().armorTint)
{
return var1;
}
Expand All @@ -64,7 +64,7 @@ public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extend
)
private VertexConsumer legacyAnimations$useEntityLayerRendererTrim(Sprite instance, VertexConsumer consumer, Operation<VertexConsumer> original, @Local(ordinal = 0, argsOnly = true) VertexConsumerProvider vertexConsumers)
{
if (!LegacyAnimationsSettings.CONFIG.instance().armorTint)
if (!LegacyAnimationsSettings.getInstance().armorTint)
{
return original.call(instance, consumer);
}
Expand All @@ -88,7 +88,7 @@ public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extend
)
private int legacyAnimations$useDamageUVOverlay(int par3)
{
if (!LegacyAnimationsSettings.CONFIG.instance().armorTint)
if (!LegacyAnimationsSettings.getInstance().armorTint)
{
return par3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
)
private void legacyAnimations$oldSneakValue4(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
if (!LegacyAnimationsSettings.getInstance().oldSneaking)
{
return;
}
Expand All @@ -171,7 +171,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
)
private void legacyAnimations$oldSneakValue5(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
if (!LegacyAnimationsSettings.getInstance().oldSneaking)
{
return;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
)
public boolean legacyAnimations$removeConflictingFields1(ModelPart instance, float value)
{
return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking;
return !LegacyAnimationsSettings.getInstance().oldSneaking;
}

@WrapWithCondition(
Expand All @@ -230,7 +230,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
)
public boolean legacyAnimations$removeConflictingFields2(ModelPart instance, float value)
{
return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking;
return !LegacyAnimationsSettings.getInstance().oldSneaking;
}

@Inject(
Expand All @@ -241,7 +241,7 @@ public abstract class BipedEntityModelMixin<T extends LivingEntity>
)
public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock)
if (!LegacyAnimationsSettings.getInstance().oldSwordBlock)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class BuiltinModelItemRendererMixin
)
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))
if (!LegacyAnimationsSettings.getInstance().hideShields || !TransformationModeUtils.isValidPerspective(mode))
{
return original;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class CameraMixin
)
private void legacyAnimations$addOldSneakCalculation(Camera instance, float value, Operation<Void> original)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking)
if (!LegacyAnimationsSettings.getInstance().oldSneaking)
{
original.call(instance, value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mixces.legacyanimations.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(ClientPlayerEntity.class)
public class ClientPlayerEntityMixin {

@WrapOperation(
method = "tickMovement",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z"
)
)
public boolean legacyAnimations$revertMovement2(Input instance, Operation<Boolean> original) {
if (!LegacyAnimationsSettings.getInstance().oldMovement)
{
return original.call(instance);
}
return instance.movementForward >= 0.8;
}

@ModifyExpressionValue(
method = "isWalking",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSubmergedInWater()Z"
)
)
public boolean legacyAnimations$revertMovement3(boolean original) {
if (!LegacyAnimationsSettings.getInstance().oldMovement)
{
return original;
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class ClientPlayerInteractionManagerMixin
)
public boolean legacyAnimations$fixBreakingBlockCheck(boolean original)
{
if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage)
if (!LegacyAnimationsSettings.getInstance().punchDuringUsage)
{
return original;
}
Expand All @@ -49,7 +49,7 @@ public abstract class ClientPlayerInteractionManagerMixin
cancellable = true)
public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir)
{
if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage)
if (!LegacyAnimationsSettings.getInstance().punchDuringUsage)
{
return;
}
Expand All @@ -72,4 +72,20 @@ public abstract class ClientPlayerInteractionManagerMixin
}
}

@Inject(
method = "getBlockBreakingProgress",
at = @At(
value = "HEAD"
),
cancellable = true
)
private void legacyAnimations$oldMiningProgress(CallbackInfoReturnable<Integer> cir)
{
if (!LegacyAnimationsSettings.getInstance().oldBreakProgress)
{
return;
}
cir.setReturnValue((int)(this.currentBreakingProgress * 10.0f) - 1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class DebugHudMixin
)
private boolean legacyAnimations$removeDebugBackground(DrawContext instance, int x1, int y1, int x2, int y2, int color)
{
return !LegacyAnimationsSettings.CONFIG.instance().oldDebug;
return !LegacyAnimationsSettings.getInstance().oldDebug;
}

@ModifyArg(
Expand All @@ -34,7 +34,7 @@ public abstract class DebugHudMixin
)
private boolean legacyAnimations$addDebugShadow(boolean shadow)
{
return LegacyAnimationsSettings.CONFIG.instance().oldDebug;
return LegacyAnimationsSettings.getInstance().oldDebug;
}

}
12 changes: 11 additions & 1 deletion src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

Expand All @@ -32,7 +33,7 @@ public abstract class EntityMixin implements EntityInterface
)
public EntityPose legacyAnimations$revertSwimPose(EntityPose original)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldSwim)
if (!LegacyAnimationsSettings.getInstance().oldSwim)
{
return original;
}
Expand All @@ -55,4 +56,13 @@ public abstract class EntityMixin implements EntityInterface
return new Vec3d(d, e, f);
}

// /**
// * @author Mixces
// * @reason Old hitbox margin
// */
// @Overwrite
// public float getTargetingMargin() {
// return 0.1f;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx)
)
public void legacyAnimations$shiftRodBob(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles)
if (!LegacyAnimationsSettings.getInstance().oldProjectiles)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx)
)
public int legacyAnimations$disableDelay(Entity instance, Operation<Integer> original)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles)
if (!LegacyAnimationsSettings.getInstance().oldProjectiles)
{
return original.call(instance);
}
Expand All @@ -55,7 +55,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx)
)
public void legacyAnimations$shiftProjectile(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles)
if (!LegacyAnimationsSettings.getInstance().oldProjectiles)
{
return;
}
Expand All @@ -75,7 +75,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx)
)
private float legacyAnimations$rotateProjectileAccordingly(float deg)
{
if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles)
if (LegacyAnimationsSettings.getInstance().oldProjectiles)
{
return deg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GameRendererMixin
)
private void legacyAnimations$addOldPitchRotation(MatrixStack matrices, float tickDelta, CallbackInfo ci, @Local(ordinal = 0) PlayerEntity playerEntity)
{
if (!LegacyAnimationsSettings.CONFIG.instance().oldViewBob)
if (!LegacyAnimationsSettings.getInstance().oldViewBob)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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.CONFIG.instance().oldSwordBlock)
if (!LegacyAnimationsSettings.getInstance().oldSwordBlock)
{
return;
}
Expand Down
Loading

0 comments on commit 96f2554

Please sign in to comment.