Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Armor Stack Decay Timer #2538

Open
wants to merge 7 commits into
base: beta
Choose a base branch
from

Conversation

Ovi-111
Copy link
Contributor

@Ovi-111 Ovi-111 commented Sep 18, 2024

What

This adds a decay timer for armor stacks. When a stack reaches max stacks (10), text color changes for better experience. Decay timer can be toggled to show only for the 10th stack.

Images

image
image image

Changelog New Features

  • Added a decay timer for armor stacks. - Ovi_1
    • The timer can be set to show only for the 10th stack.
    • Shows stack type when you gain stack (toggleable).

Changelog Improvements

  • The armor stack counter is hidden from the action bar when Armor Stack Display is enabled. - Ovi_1

Changelog Technical Details

  • Renamed StackDisplayConfig to ArmorStackDisplayConfig. - Ovi_1

@hannibal002 hannibal002 added this to the Version 0.28 milestone Sep 20, 2024
@jani270 jani270 added the Soon This Pull Request will be merged within the next couple of betas label Oct 8, 2024
@CalMWolfs CalMWolfs added Waiting on Dependency PR and removed Soon This Pull Request will be merged within the next couple of betas labels Oct 8, 2024
@jani270
Copy link
Collaborator

jani270 commented Oct 10, 2024

I dont think the dependency is good here, the other PR has been dead for months, would be better to just review/merge this one with good changes.

@CalMWolfs
Copy link
Collaborator

I dont think the dependency is good here, the other PR has been dead for months, would be better to just review/merge this one with good changes.

ill close the other one then

@jani270 jani270 added the Soon This Pull Request will be merged within the next couple of betas label Oct 10, 2024
Copy link
Owner

@hannibal002 hannibal002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks mostly fine.
Feature works also cool in game.

But i could not get it to work with 3/4 aurora armor.
and with 3/4 crimson the timer was 1-2 seconds off: the display showed "0s" for 1-2 seconds until it finally removed one stack.

Also suggested some code cleanup and consistnecy changes

@Accordion
// TODO rename to armor stack display
public StackDisplayConfig stackDisplayConfig = new StackDisplayConfig();
public ArmorStackDisplayConfig armorStackDisplayConfig = new ArmorStackDisplayConfig();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the suffix "Config" from the variable name (not the class name)


public class ArmorStackDisplayConfig {
@Expose
@ConfigOption(name = "Enable", desc = "Enable the armor stack display feature.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain a bit more what this feature does. (include crimson armor names maybe, or their ability names)

@ConfigOption(name = "Enable", desc = "Enable the armor stack display feature.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this default diabled


private fun drawDisplay(): List<String> {
if (stackCount == 0 || armorPieceCount < 3) return emptyList()
val displaySingleLine = config.showInSingleLine
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config variables here can all be removed/inlined (not the isMaxStack one)

if (!isEnabled()) return
config.position.renderString(display, posLabel = "Armor Stack Display")
display = drawDisplay()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a check so that this only happens every second tick (10 times a second, not 20 times a second). Can be done via event.isMod(2)

else -> "§b"
}

if (displaySingleLine) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can move the two returns below to this if block directly


@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
if (!isEnabled()) return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check here can go


@SubscribeEvent
fun onPlaySound(event: PlaySoundEvent) {
if (!isEnabled() && !config.armorStackDecayTimer) return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the AND here is wrong, a OR makes more sense to me

@SubscribeEvent
fun onPlaySound(event: PlaySoundEvent) {
if (!isEnabled() && !config.armorStackDecayTimer) return
if (event.soundName in listOf("tile.piston.out", "tile.piston.in") &&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the list into a member of the class so that we dont need to recreate it each time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, a set is probably better than a list here?


private fun resetDecayTime() {
armorPieceCount = InventoryUtils.getArmor().firstNotNullOfOrNull { armor ->
val lore = armor?.getLore().toString()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont like the getLore().toString() workaround here. i think we have another matcher utils function that works with a list and uses the first/last directly

@github-actions github-actions bot added the Wrong Title/Changelog There is an error in the title or changelog label Oct 11, 2024
Copy link

I have detected some issues with your pull request:

Body issues:
No changes detected in this pull request

Please fix these issues. For the correct format, refer to the pull request template.

@github-actions github-actions bot removed the Wrong Title/Changelog There is an error in the title or changelog label Oct 11, 2024
@hannibal002 hannibal002 removed the Soon This Pull Request will be merged within the next couple of betas label Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants