From 2ab2777ce8b8f5c0984f7b18ff59b2cbc5436f28 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sun, 22 Dec 2024 17:22:02 -0500 Subject: [PATCH] Add setting to fix visibility of attack indicator with high attack speed --- README.md | 3 + .../mixins/screen/MixinInGameHud.java | 15 ++ .../animatium/config/AnimatiumConfig.kt | 208 ++++++++++++------ .../assets/animatium/lang/en_us.json | 2 + 4 files changed, 163 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index b725081..2ea61a0 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,9 @@ them [here](https://github.com/Legacy-Visuals-Project/Animatium/actions). - [X] showCrosshairInThirdperson - Description: Show crosshair whilst in thirdperson like in <=1.8.x. - Type: BOOLEAN +- [X] fixHighAttackSpeedIndicator + - Description: Hides the attack indicator when you have such a high attack speed. (Fixes MC-268420) + - Type: BOOLEAN - [X] removeHeartFlash - Description: Remove heart blinking like in <=1.7.x. - Type: BOOLEAN diff --git a/src/main/java/me/mixces/animatium/mixins/screen/MixinInGameHud.java b/src/main/java/me/mixces/animatium/mixins/screen/MixinInGameHud.java index 7b05426..29231b6 100644 --- a/src/main/java/me/mixces/animatium/mixins/screen/MixinInGameHud.java +++ b/src/main/java/me/mixces/animatium/mixins/screen/MixinInGameHud.java @@ -9,10 +9,14 @@ import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.option.Perspective; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.util.Window; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import java.util.function.Function; + @Mixin(InGameHud.class) public abstract class MixinInGameHud { @WrapOperation(method = "renderChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;render(Lnet/minecraft/client/gui/DrawContext;IIIZ)V")) @@ -36,6 +40,17 @@ public abstract class MixinInGameHud { } } + @WrapWithCondition(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 2)) + private boolean animatium$fixHighAttackSpeedIndicator(DrawContext instance, Function renderLayers, Identifier sprite, int x, int y, int width, int height, @Local float f) { + if (AnimatiumConfig.getInstance().getFixHighAttackSpeedIndicator()) { + // NOTE: Couldn't grab it locally, so just copied it. Should be fine. + int progressWidth = (int) (f * 17.0F); + return progressWidth != 0; + } else { + return true; + } + } + @WrapWithCondition(method = "renderHealthBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawHeart(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/gui/hud/InGameHud$HeartType;IIZZZ)V")) private boolean animatium$removeHeartFlash(InGameHud instance, DrawContext context, InGameHud.HeartType type, int x, int y, boolean hardcore, boolean blinking, boolean half) { return !AnimatiumConfig.getInstance().getRemoveHeartFlash() || !blinking || type == InGameHud.HeartType.CONTAINER; diff --git a/src/main/kotlin/me/mixces/animatium/config/AnimatiumConfig.kt b/src/main/kotlin/me/mixces/animatium/config/AnimatiumConfig.kt index e72de73..d7b9876 100644 --- a/src/main/kotlin/me/mixces/animatium/config/AnimatiumConfig.kt +++ b/src/main/kotlin/me/mixces/animatium/config/AnimatiumConfig.kt @@ -412,6 +412,17 @@ class AnimatiumConfig { .controller(TickBoxControllerBuilder::create) .build() ) + category.option( + Option.createBuilder() + .name(Text.translatable("animatium.fixHighAttackSpeedIndicator")) + .description(OptionDescription.of(Text.translatable("animatium.fixHighAttackSpeedIndicator.description"))) + .binding( + defaults.fixHighAttackSpeedIndicator, + { config.fixHighAttackSpeedIndicator }, + { newVal -> config.fixHighAttackSpeedIndicator = newVal }) + .controller(TickBoxControllerBuilder::create) + .build() + ) category.option( Option.createBuilder() .name(Text.translatable("animatium.removeHeartFlash")) @@ -811,81 +822,148 @@ class AnimatiumConfig { } // Sneaking - @SerialEntry var removeSmoothSneaking = false - @SerialEntry var oldSneakAnimationInterpolation = true - @SerialEntry var oldSneakEyeHeight = true - @SerialEntry var fixSneakingFeetPosition = true - @SerialEntry var oldSneakingFeetPosition = false // TODO/NOTE: Might need a better name. - @SerialEntry var syncPlayerModelWithEyeHeight = false - @SerialEntry var sneakAnimationWhileFlying = true + @SerialEntry + var removeSmoothSneaking = false + @SerialEntry + var oldSneakAnimationInterpolation = true + @SerialEntry + var oldSneakEyeHeight = true + @SerialEntry + var fixSneakingFeetPosition = true + @SerialEntry + var oldSneakingFeetPosition = false // TODO/NOTE: Might need a better name. + @SerialEntry + var syncPlayerModelWithEyeHeight = false + @SerialEntry + var sneakAnimationWhileFlying = true // QOL - @SerialEntry var minimalViewBobbing = true - @SerialEntry var showNametagInThirdperson = true - @SerialEntry var hideNameTagBackground = true - @SerialEntry var applyTextShadowToNametag = true - @SerialEntry var oldDebugHudTextColor = true - @SerialEntry var fixMirrorArmSwing = true - @SerialEntry var persistentBlockOutline = true - @SerialEntry var alwaysAllowUsageSwinging = true - @SerialEntry var allowOffhandUsageSwinging = true - @SerialEntry var alwaysShowSharpParticles = true - @SerialEntry var forceItemGlintOnEntity = false - @SerialEntry var disableRecipeAndTutorialToasts = false - @SerialEntry var disablePoseUpdates = false - @SerialEntry var showArmWhileInvisible = false + @SerialEntry + var minimalViewBobbing = true + @SerialEntry + var showNametagInThirdperson = true + @SerialEntry + var hideNameTagBackground = true + @SerialEntry + var applyTextShadowToNametag = true + @SerialEntry + var oldDebugHudTextColor = true + @SerialEntry + var fixMirrorArmSwing = true + @SerialEntry + var persistentBlockOutline = true + @SerialEntry + var alwaysAllowUsageSwinging = true + @SerialEntry + var allowOffhandUsageSwinging = true + @SerialEntry + var alwaysShowSharpParticles = true + @SerialEntry + var forceItemGlintOnEntity = false + @SerialEntry + var disableRecipeAndTutorialToasts = false + @SerialEntry + var disablePoseUpdates = false + @SerialEntry + var showArmWhileInvisible = false // Movement - @SerialEntry var rotateBackwardsWalking = true - @SerialEntry var uncapBlockingHeadRotation = true - @SerialEntry var removeHeadRotationInterpolation = true - @SerialEntry var fixVerticalBobbingTilt = true - @SerialEntry var oldDeathLimbs = true - @SerialEntry var fixBowArmMovement = true - @SerialEntry var oldCapeMovement = false // TODO/NOTE: Currently not accurate/broken. + @SerialEntry + var rotateBackwardsWalking = true + @SerialEntry + var uncapBlockingHeadRotation = true + @SerialEntry + var removeHeadRotationInterpolation = true + @SerialEntry + var fixVerticalBobbingTilt = true + @SerialEntry + var oldDeathLimbs = true + @SerialEntry + var fixBowArmMovement = true + @SerialEntry + var oldCapeMovement = false // TODO/NOTE: Currently not accurate/broken. // Sky - @SerialEntry var oldBlueVoidSky = true - @SerialEntry var oldSkyHorizonHeight = true - @SerialEntry var oldCloudHeight = true + @SerialEntry + var oldBlueVoidSky = true + @SerialEntry + var oldSkyHorizonHeight = true + @SerialEntry + var oldCloudHeight = true // Screen - @SerialEntry var showCrosshairInThirdperson = true - @SerialEntry var removeHeartFlash = true - @SerialEntry var fixTextStrikethroughStyle = true - @SerialEntry var centerScrollableListWidgets = true - @SerialEntry var oldListWidgetSelectedBorderColor = true - @SerialEntry var oldButtonTextColors = true - @SerialEntry var removeDebugHudBackground = true - @SerialEntry var debugHudTextShadow = true - @SerialEntry var oldChatPosition = true - @SerialEntry var disableCameraTransparentPassthrough = true - @SerialEntry var cameraVersion = CameraVersion.V1_8 + @SerialEntry + var showCrosshairInThirdperson = true + @SerialEntry + var fixHighAttackSpeedIndicator = true + @SerialEntry + var removeHeartFlash = true + @SerialEntry + var fixTextStrikethroughStyle = true + @SerialEntry + var centerScrollableListWidgets = true + @SerialEntry + var oldListWidgetSelectedBorderColor = true + @SerialEntry + var oldButtonTextColors = true + @SerialEntry + var removeDebugHudBackground = true + @SerialEntry + var debugHudTextShadow = true + @SerialEntry + var oldChatPosition = true + @SerialEntry + var disableCameraTransparentPassthrough = true + @SerialEntry + var cameraVersion = CameraVersion.V1_8 // Items - @SerialEntry var tiltItemPositions = true - @SerialEntry var tiltItemPositionsInThirdperson = true - @SerialEntry var applyItemSwingUsage = true - @SerialEntry var removeEquipAnimationOnItemUse = true - @SerialEntry var disableItemUsingTextureInGui = true - @SerialEntry var itemDropsFaceCamera = true - @SerialEntry var itemDrops2D = true - @SerialEntry var oldDurabilityBarColors = true - @SerialEntry var oldItemRarities = true - @SerialEntry var removeClientsideBlockingDelay = true - @SerialEntry var oldFishingRodTextureStackCheck = true - @SerialEntry var fishingRodLineInterpolation = true - @SerialEntry var noMoveFishingRodLine = true - @SerialEntry var oldFishingRodLinePositionThirdPerson = true - @SerialEntry var fixCastLineCheck = true - @SerialEntry var fixCastLineSwing = true + @SerialEntry + var tiltItemPositions = true + @SerialEntry + var tiltItemPositionsInThirdperson = true + @SerialEntry + var applyItemSwingUsage = true + @SerialEntry + var removeEquipAnimationOnItemUse = true + @SerialEntry + var disableItemUsingTextureInGui = true + @SerialEntry + var itemDropsFaceCamera = true + @SerialEntry + var itemDrops2D = true + @SerialEntry + var oldDurabilityBarColors = true + @SerialEntry + var oldItemRarities = true + @SerialEntry + var removeClientsideBlockingDelay = true + @SerialEntry + var oldFishingRodTextureStackCheck = true + @SerialEntry + var fishingRodLineInterpolation = true + @SerialEntry + var noMoveFishingRodLine = true + @SerialEntry + var oldFishingRodLinePositionThirdPerson = true + @SerialEntry + var fixCastLineCheck = true + @SerialEntry + var fixCastLineSwing = true // Other - @SerialEntry var legacyThirdpersonSwordBlockingPosition = true - @SerialEntry var lockBlockingArmRotation = true - @SerialEntry var oldProjectilePosition = true - @SerialEntry var disableProjectileAgeCheck = true - @SerialEntry var oldBlockMiningProgress = true - @SerialEntry var disableInventoryEntityScissor = true - @SerialEntry var legacyBlockOutlineRendering = true + @SerialEntry + var legacyThirdpersonSwordBlockingPosition = true + @SerialEntry + var lockBlockingArmRotation = true + @SerialEntry + var oldProjectilePosition = true + @SerialEntry + var disableProjectileAgeCheck = true + @SerialEntry + var oldBlockMiningProgress = true + @SerialEntry + var disableInventoryEntityScissor = true + @SerialEntry + var legacyBlockOutlineRendering = true } \ No newline at end of file diff --git a/src/main/resources/assets/animatium/lang/en_us.json b/src/main/resources/assets/animatium/lang/en_us.json index 8886513..d45640c 100644 --- a/src/main/resources/assets/animatium/lang/en_us.json +++ b/src/main/resources/assets/animatium/lang/en_us.json @@ -74,6 +74,8 @@ "animatium.category.screen": "Screen", "animatium.showCrosshairInThirdperson": "Show crosshair in third-person", "animatium.showCrosshairInThirdperson.description": "Show crosshair whilst in thirdperson like in <=1.8.x.", + "animatium.fixHighAttackSpeedIndicator": "Fix high attack speed crosshair indicator", + "animatium.fixHighAttackSpeedIndicator.description": "Hides the attack indicator when you have such a high attack speed. (Fixes MC-268420)", "animatium.removeHeartFlash": "Remove hearts flashing when taking damage", "animatium.removeHeartFlash.description": "Remove heart blinking like in <=1.7.x.", "animatium.fixTextStrikethroughStyle": "Fix text strikethrough style",