Skip to content

Commit

Permalink
Port config to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw committed Dec 20, 2024
1 parent b66981b commit 43c0031
Show file tree
Hide file tree
Showing 42 changed files with 964 additions and 627 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ them [here](https://github.com/Legacy-Visuals-Project/Animatium/actions).
- [X] tiltItemPositions
- Description: Tilts the held item position to make held items look like they did in <=1.7.x.
- Type: BOOLEAN
- [X] tiltItemPositions
- Description: Tilts the third-person held item position to make held items look like they did in <=1.7.x.
- Type: BOOLEAN
- [X] legacyThirdpersonSwordBlockingPosition
- Description: Brings back the old third-person sword blocking look from <=1.7.
- Type: BOOLEAN
- [X] lockBlockingArmRotation
- Description: Locks the third-person blocking arm rotation.
- Type: BOOLEAN
Expand Down
515 changes: 0 additions & 515 deletions src/main/java/me/mixces/animatium/config/AnimatiumConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public abstract class MixinMinecraftClient {

@Inject(method = "tick", at = @At("TAIL"))
private void animatium$applySwingWhilstMining(CallbackInfo ci) {
if (AnimatiumConfig.getInstance().applyItemSwingUsage) {
if (AnimatiumConfig.getInstance().getApplyItemSwingUsage()) {
ClientPlayerEntity player = this.player;
if (player == null || player.getStackInHand(player.getActiveHand()) == null || !player.isUsingItem() || !this.options.attackKey.isPressed()) {
return;
}

// TODO: Possible setting to allow swinging without having to look at a block?
if (AnimatiumConfig.getInstance().alwaysAllowUsageSwinging || (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.BLOCK)) {
if (AnimatiumConfig.getInstance().getAlwaysAllowUsageSwinging() || (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.BLOCK)) {
PlayerUtils.fakeHandSwing(player, player.getActiveHand());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render

@WrapOperation(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;isInSneakingPose:Z"))
private boolean animatium$oldSneakingFeetPosition(BipedEntityRenderState instance, Operation<Boolean> original) {
if (AnimatiumConfig.getInstance().oldSneakingFeetPosition && instance.isInSneakingPose) {
if (AnimatiumConfig.getInstance().getOldSneakingFeetPosition() && instance.isInSneakingPose) {
// Values sourced from older versions
body.pitch = 0.5F;
rightArm.pitch += 0.4F;
Expand All @@ -78,7 +78,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render

@WrapOperation(method = "animateArms", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftArm:Lnet/minecraft/client/model/ModelPart;", opcode = Opcodes.GETFIELD, ordinal = 3))
public ModelPart animatium$fixMirrorArmSwing$field(BipedEntityModel<?> instance, Operation<ModelPart> original, @Local ModelPart modelPart) {
if (AnimatiumConfig.getInstance().fixMirrorArmSwing) {
if (AnimatiumConfig.getInstance().getFixMirrorArmSwing()) {
return modelPart;
} else {
return original.call(instance);
Expand All @@ -87,7 +87,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render

@ModifyExpressionValue(method = "animateArms", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;sin(F)F", ordinal = 5))
public float animatium$fixMirrorArmSwing$sin(float original, @Local Arm arm) {
if (AnimatiumConfig.getInstance().fixMirrorArmSwing) {
if (AnimatiumConfig.getInstance().getFixMirrorArmSwing()) {
return (arm == Arm.LEFT ? -1 : 1) * original;
} else {
return original;
Expand All @@ -96,7 +96,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render

@WrapOperation(method = "positionBlockingArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F"))
private float animatium$lockBlockingArmRotation(float value, float min, float max, Operation<Float> original) {
if (AnimatiumConfig.getInstance().lockBlockingArmRotation) {
if (AnimatiumConfig.getInstance().getLockBlockingArmRotation()) {
return 0.0F;
} else {
return original.call(value, min, max);
Expand All @@ -105,7 +105,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render

@Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "CONSTANT", args = "floatValue=0.0", ordinal = 1))
private void animatium$fixBowArmMovement(T bipedEntityRenderState, CallbackInfo ci) {
if (AnimatiumConfig.getInstance().fixBowArmMovement) {
if (AnimatiumConfig.getInstance().getFixBowArmMovement()) {
BipedEntityModel.ArmPose leftArmPose = bipedEntityRenderState.leftArmPose;
BipedEntityModel.ArmPose rightArmPose = bipedEntityRenderState.rightArmPose;
final boolean isRightArmPose = rightArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW;
Expand All @@ -132,7 +132,7 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render
@WrapOperation(method = {"positionLeftArm", "positionRightArm"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;positionBlockingArm(Lnet/minecraft/client/model/ModelPart;Z)V"))
private void animatium$oldSwordBlockArm(BipedEntityModel<?> instance, ModelPart arm, boolean rightArm, Operation<Void> original, @Local(argsOnly = true) T state) {
original.call(instance, arm, rightArm);
if (AnimatiumConfig.getInstance().legacySwordBlockingPosition) {
if (AnimatiumConfig.getInstance().getLegacyThirdpersonSwordBlockingPosition()) {
Optional<Entity> optionalLivingEntity = EntityUtils.getEntityByState(state);
if (optionalLivingEntity.isPresent() && state instanceof BipedEntityRenderState) {
LivingEntity livingEntity = (LivingEntity) optionalLivingEntity.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
public abstract class MixinFishingRodCastProperty {
@ModifyReturnValue(method = "getValue", at = @At(value = "RETURN", ordinal = 0))
private boolean animatium$getValue(boolean original, @Local(argsOnly = true) ModelTransformationMode modelTransformationMode) {
if (AnimatiumConfig.getInstance().disableItemUsingTextureInGui && modelTransformationMode == ModelTransformationMode.GUI) {
if (AnimatiumConfig.getInstance().getDisableItemUsingTextureInGui() && modelTransformationMode == ModelTransformationMode.GUI) {
return false;
} else {
return AnimatiumConfig.getInstance().oldFishingRodTextureStackCheck || original;
return AnimatiumConfig.getInstance().getOldFishingRodTextureStackCheck() || original;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class MixinItemRenderLayerState {

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/json/Transformation;apply(ZLnet/minecraft/client/util/math/MatrixStack;)V"))
private void animatium$tiltItemPositionsRod(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) {
if (AnimatiumConfig.getInstance().tiltItemPositions) {
if (AnimatiumConfig.getInstance().getTiltItemPositions()) {
Optional<ItemStack> stackOptional = ItemUtils.getStack();
if (stackOptional.isPresent() && ItemUtils.isFishingRodItem(stackOptional.get())) {
Optional<ModelTransformationMode> modeOptional = ItemUtils.getTransformMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public abstract class MixinUsingItemProperty {
@ModifyReturnValue(method = "getValue", at = @At(value = "RETURN"))
private boolean animatium$getValue(boolean original, @Local(argsOnly = true) ItemStack stack, @Local(argsOnly = true) ModelTransformationMode modelTransformationMode) {
if (AnimatiumConfig.getInstance().disableItemUsingTextureInGui && ItemUtils.isRangedWeaponItem(stack) && modelTransformationMode == ModelTransformationMode.GUI) {
if (AnimatiumConfig.getInstance().getDisableItemUsingTextureInGui() && ItemUtils.isRangedWeaponItem(stack) && modelTransformationMode == ModelTransformationMode.GUI) {
return false;
} else {
return original;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class MixinClientPlayNetworkHandler {

@WrapOperation(method = "onEntityTrackerUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityTrackerUpdateS2CPacket;trackedValues()Ljava/util/List;"))
public List<DataTracker.SerializedEntry<?>> animatium$disablePoseUpdates(EntityTrackerUpdateS2CPacket instance, Operation<List<DataTracker.SerializedEntry<?>>> original) {
if (AnimatiumConfig.getInstance().disablePoseUpdates) {
if (AnimatiumConfig.getInstance().getDisablePoseUpdates()) {
if (Objects.requireNonNull(MinecraftClient.getInstance().player).equals(world.getEntityById(instance.id()))) {
instance.trackedValues().removeIf(entry -> entry.handler().equals(TrackedDataHandlerRegistry.ENTITY_POSE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class MixinClientPlayerInteractionManager {

@Inject(method = "getBlockBreakingProgress", at = @At(value = "RETURN"), cancellable = true)
private void animatium$oldBlockMiningProgress(CallbackInfoReturnable<Integer> cir) {
if (AnimatiumConfig.getInstance().oldBlockMiningProgress && currentBreakingProgress > 0.0F) {
if (AnimatiumConfig.getInstance().getOldBlockMiningProgress() && currentBreakingProgress > 0.0F) {
cir.setReturnValue((int) (this.currentBreakingProgress * 10.0f));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class MixinDrawContext {

@Inject(method = "drawItemBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(Lnet/minecraft/client/render/RenderLayer;IIIIII)V", ordinal = 0, shift = At.Shift.AFTER))
private void animatium$oldDurabilityBar(ItemStack stack, int x, int y, CallbackInfo ci) {
if (AnimatiumConfig.getInstance().oldDurabilityBarColors) {
if (AnimatiumConfig.getInstance().getOldDurabilityBarColors()) {
int i = x + 2;
int j = y + 13;
int color = ColorHelper.getArgb((255 - ItemUtils.getLegacyDurabilityColorValue(stack)) / 4, 64, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class MixinGameRenderer {

@Inject(method = "bobView", at = @At("TAIL"))
private void animatium$fixVerticalBobbingTilt(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
if (AnimatiumConfig.getInstance().fixVerticalBobbingTilt && this.client.getCameraEntity() instanceof PlayerEntity playerEntity) {
if (AnimatiumConfig.getInstance().getFixVerticalBobbingTilt() && this.client.getCameraEntity() instanceof PlayerEntity playerEntity) {
ViewBobbingStorage bobbingAccessor = (ViewBobbingStorage) playerEntity;
float j = MathHelper.lerp(tickDelta, bobbingAccessor.animatium$getPreviousBobbingTilt(), bobbingAccessor.animatium$getBobbingTilt());
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(j));
Expand All @@ -35,12 +35,12 @@ public abstract class MixinGameRenderer {

@WrapWithCondition(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V"))
private boolean animatium$minimalViewBobbing(GameRenderer instance, MatrixStack matrices, float tickDelta) {
return !AnimatiumConfig.getInstance().minimalViewBobbing;
return !AnimatiumConfig.getInstance().getMinimalViewBobbing();
}

@WrapOperation(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;shouldRenderBlockOutline()Z"))
private boolean animatium$e(GameRenderer instance, Operation<Boolean> original) {
if (AnimatiumConfig.getInstance().persistentBlockOutline) {
if (AnimatiumConfig.getInstance().getPersistentBlockOutline()) {
return true;
} else {
return original.call(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class MixinWorldRenderer {

@Inject(method = "method_62215", at = @At(value = "TAIL"))
private void animatium$oldBlueVoidSky(Fog fog, DimensionEffects.SkyType skyType, float tickDelta, DimensionEffects dimensionEffects, CallbackInfo ci, @Local MatrixStack matrices) {
if (AnimatiumConfig.getInstance().oldBlueVoidSky && skyType != DimensionEffects.SkyType.END) {
if (AnimatiumConfig.getInstance().getOldBlueVoidSky() && skyType != DimensionEffects.SkyType.END) {
assert this.client.player != null;
assert this.world != null;
// can't get it via local, so have to re-get it this way
Expand All @@ -58,7 +58,7 @@ public abstract class MixinWorldRenderer {

@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/DimensionEffects;getCloudsHeight()F"))
private float animatium$oldCloudHeight(DimensionEffects instance, Operation<Float> original) {
if (AnimatiumConfig.getInstance().oldCloudHeight) {
if (AnimatiumConfig.getInstance().getOldCloudHeight()) {
return instance.getSkyType() == DimensionEffects.SkyType.END ? 8.0F : 128.0F;
} else {
return original.call(instance);
Expand Down Expand Up @@ -95,7 +95,7 @@ public abstract class MixinWorldRenderer {
@Unique
public double animatium$getHorizonHeight(ClientWorld world) {
if (((ClientWorldPropertiesAccessor) world.getLevelProperties()).isFlatWorld()) {
return AnimatiumConfig.getInstance().oldSkyHorizonHeight ? 0.0D : world.getBottomY();
return AnimatiumConfig.getInstance().getOldSkyHorizonHeight() ? 0.0D : world.getBottomY();
} else {
return 63.0D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public abstract class MixinBipedEntityRenderer {
@WrapOperation(method = "updateBipedRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isInSneakingPose()Z"))
private static boolean animatium$sneakAnimationWhileFlying(LivingEntity instance, Operation<Boolean> original) {
if (AnimatiumConfig.getInstance().sneakAnimationWhileFlying) {
if (AnimatiumConfig.getInstance().getSneakAnimationWhileFlying()) {
return instance.isInSneakingPose() || instance.isSneaking();
} else {
return original.call(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class MixinEntityRenderer {

@WrapOperation(method = "renderLabelIfPresent", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/entity/state/EntityRenderState;sneaking:Z"))
private boolean animatium$sneakAnimationWhileFlying(EntityRenderState instance, Operation<Boolean> original) {
if (AnimatiumConfig.getInstance().sneakAnimationWhileFlying && instance instanceof LivingEntityRenderState livingEntityRenderState) {
if (AnimatiumConfig.getInstance().getSneakAnimationWhileFlying() && instance instanceof LivingEntityRenderState livingEntityRenderState) {
return livingEntityRenderState.sneaking || livingEntityRenderState.isInPose(EntityPose.CROUCHING);
} else {
return original.call(instance);
Expand All @@ -34,7 +34,7 @@ public abstract class MixinEntityRenderer {

@WrapOperation(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getTextBackgroundOpacity(F)F"))
private float animatium$hideNameTagBackground(GameOptions instance, float fallback, Operation<Float> original) {
if (AnimatiumConfig.getInstance().hideNameTagBackground) {
if (AnimatiumConfig.getInstance().getHideNameTagBackground()) {
return 0F;
} else {
return original.call(instance, fallback);
Expand All @@ -43,7 +43,7 @@ public abstract class MixinEntityRenderer {

@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"), index = 4)
private boolean animatium$applyTextShadowToNametag(boolean shadow) {
if (AnimatiumConfig.getInstance().applyTextShadowToNametag) {
if (AnimatiumConfig.getInstance().getApplyTextShadowToNametag()) {
return true;
} else {
return shadow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected MixinFishingBobberEntityRenderer(EntityRendererFactory.Context ctx) {

@WrapOperation(method = "getHandPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getCameraPosVec(F)Lnet/minecraft/util/math/Vec3d;"))
private Vec3d animatium$fishingRodLineInterpolation(PlayerEntity instance, float v, Operation<Vec3d> original) {
if (AnimatiumConfig.getInstance().fishingRodLineInterpolation) {
if (AnimatiumConfig.getInstance().getFishingRodLineInterpolation()) {
CameraAccessor cameraAccessor = (CameraAccessor) dispatcher.camera;
float eyeHeight = MathHelper.lerp(v, cameraAccessor.getLastCameraY(), cameraAccessor.getCameraY());
return PlayerUtils.lerpPlayerWithEyeHeight(instance, v, eyeHeight);
Expand All @@ -42,31 +42,31 @@ protected MixinFishingBobberEntityRenderer(EntityRendererFactory.Context ctx) {

@ModifyExpressionValue(method = "getHandPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isInSneakingPose()Z"))
private boolean animatium$noMoveFishingRodLine(boolean original) {
return !AnimatiumConfig.getInstance().noMoveFishingRodLine && original;
return !AnimatiumConfig.getInstance().getNoMoveFishingRodLine() && original;
}

@ModifyExpressionValue(method = "getHandPos", at = @At(value = "CONSTANT", args = "doubleValue=0.8"))
private double animatium$oldFishingRodLinePositionThirdPerson(double original) {
return original + (AnimatiumConfig.getInstance().oldFishingRodLinePositionThirdPerson ? 0.05 : 0.0);
return original + (AnimatiumConfig.getInstance().getOldFishingRodLinePositionThirdPerson() ? 0.05 : 0.0);
}

@WrapOperation(method = "getHandPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/FishingBobberEntityRenderer;getArmHoldingRod(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/util/Arm;"))
private Arm animatium$fixCastLineCheck(PlayerEntity player, Operation<Arm> original) {
Arm value = original.call(player);
if (AnimatiumConfig.getInstance().fixCastLineCheck && value != player.getMainArm() && !(player.getOffHandStack().getItem() instanceof FishingRodItem)) {
if (AnimatiumConfig.getInstance().getFixCastLineCheck() && value != player.getMainArm() && !(player.getOffHandStack().getItem() instanceof FishingRodItem)) {
return value.getOpposite();
} else {
return value;
}
}

@ModifyArg(method = "updateRenderState(Lnet/minecraft/entity/projectile/FishingBobberEntity;Lnet/minecraft/client/render/entity/state/FishingBobberEntityState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/FishingBobberEntityRenderer;getHandPos(Lnet/minecraft/entity/player/PlayerEntity;FF)Lnet/minecraft/util/math/Vec3d;"), index = 1)
private float animatium$fixCastLineSwing(float f) {
if (AnimatiumConfig.getInstance().fixCastLineSwing) {
private float animatium$fixCastLineSwing(float original) {
if (AnimatiumConfig.getInstance().getFixCastLineSwing()) {
int multiplier = PlayerUtils.getHandMultiplier(Objects.requireNonNull(MinecraftClient.getInstance().player));
return f * multiplier;
return original * multiplier;
} else {
return f;
return original;
}
}
}
Loading

0 comments on commit 43c0031

Please sign in to comment.