Skip to content

Conversation

@UpcraftLP
Copy link
Member

  • fixes ticking component behavior for child classes if one of their superclasses has a ticking component but the child class does not
  • add test case to verify the behavior

@UpcraftLP UpcraftLP requested a review from Pyrofab December 31, 2024 21:50
Copy link
Member

@Pyrofab Pyrofab left a comment

Choose a reason for hiding this comment

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

darn, actions broke

Comment on lines 61 to 62
if(StaticBlockComponentPlugin.INSTANCE.clientTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.clientTicking.add(entityClass);
if(StaticBlockComponentPlugin.INSTANCE.serverTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.serverTicking.add(entityClass);
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure all parent classes went through this method before this class does ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so. If you can find a scenario where that isnt the case please let me know.
Anyway I added another test case for it.

Copy link
Member

Choose a reason for hiding this comment

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

oh duh, there is the recursive call right above... But, consider a three-levels hierarchy A -> B -> C :

  • A has ticking components
  • B has non-ticking components
  • C has no components for itself

when C loads, it will check only B, not A right ?

Copy link
Member

Choose a reason for hiding this comment

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

wait nevermind, B will be considered ticking because the component building method is recursive, so no issue there.

Comment on lines 60 to 62
// if parent class needs to tick, this one does, too!
if(StaticBlockComponentPlugin.INSTANCE.clientTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.clientTicking.add(entityClass);
if(StaticBlockComponentPlugin.INSTANCE.serverTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.serverTicking.add(entityClass);
Copy link
Member

Choose a reason for hiding this comment

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

Also, could you maybe move this to a method in StaticBlockComponentPlugin instead of directly mutating its visible-for-testing "private" fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not change it because VisibleForTesting's semantics say it would otherwise be assumed to be package-private, which would still allow calling it like this just fine.

But sure, will do

Copy link
Member

@Pyrofab Pyrofab left a comment

Choose a reason for hiding this comment

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

I'm not 100% positive that there is no scenario where we could miss a ticking BE, but I can't think of one so we should be fine

@Pyrofab Pyrofab merged commit b620b40 into 1.20.1 Jan 6, 2025
0 of 4 checks passed
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.

3 participants