stackotter / delta-client

An open source Minecraft Java Edition client built for speed.
https://deltaclient.app
GNU General Public License v3.0
331 stars 32 forks source link

Add attack strength indicator under crossbar when recharging (the small sword icon) #204

Open stackotter opened 5 months ago

stackotter commented 5 months ago

Not strictly necessary for game play, but it'd be nice to have and I reckon it'd definitely make things feel more polished. This should make a relatively friendly first issue so I've included an overview of the steps below,

  1. Create a new PlayerAttackStrength component in Sources/Core/Sources/ECS/Components. This component should just store a ticksSinceLastReset property which stores the tick number in which the player last did an action that reset their attack strength (e.g. switching hot bar slots, left clicking an entity or nothing, cancelling breaking a block in survival; not sure if there are any others)
  2. Add an instance of that component as a property in Sources/Core/Sources/Player/Player.swift (and remember to add the component to the createEntity call in Player.add(to:))
  3. Update PlayerInputSystem and PlayerBlockBreakingSystem to reset ticksSinceLastReset whenever an action is performed that should reset the player's attack strength. Remember to increment this values every tick as well (do it before anything resets it so that the reset value doesn't immediately get incremented).
  4. Add two new icons to Sources/Core/Sources/GUI/GUISprite.swift; attackStrengthIndicatorForeground and attackStrengthIndicatorBackground. To get the positions and sizes, open ~/Library/Application Support/dev.stackotter.delta-client/assets/minecraft/textures/gui/icons.png in Preview and measure by making selections.
  5. Add a currentAttackStrengthMultiplier(for item: Item, factor: Float) -> Float function which computes Float(ticksSinceLastReset + factor) / Float(item.properties?.toolProperties?.speed ?? 4)
  6. Update Sources/Core/Sources/GUI/InGameGUI.swift to display the attack strength indicator under the crosshair (you should be able to make use of InGameGUI.continuousMeter)

If you need any help feel free to ask on the Discord server!