Skip to content

Commit

Permalink
Add setting to fix visibility of attack indicator with high attack speed
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw committed Dec 22, 2024
1 parent a289483 commit 2ab2777
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 65 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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<Identifier, RenderLayer> 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;
Expand Down
208 changes: 143 additions & 65 deletions src/main/kotlin/me/mixces/animatium/config/AnimatiumConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ class AnimatiumConfig {
.controller(TickBoxControllerBuilder::create)
.build()
)
category.option(
Option.createBuilder<Boolean>()
.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<Boolean>()
.name(Text.translatable("animatium.removeHeartFlash"))
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/animatium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2ab2777

Please sign in to comment.