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

Add a TickUtil class to convert minutes/seconds to ticks #911

Merged
merged 4 commits into from May 2, 2018

Conversation

@FlorentClarret
Copy link
Member

@FlorentClarret FlorentClarret commented Apr 30, 2018

Currently, when we are computing durations (for potions or animals for example), we are always calculating with the formula or directly put the final value in ticks.

I do not find it really easy to read and I'm always wondering how long 4800, 24000 or 6000 ticks really is, that's why I added a utility class to perform the conversion. Thanks to that, we directly know the duration of an effect.

@FlorentClarret FlorentClarret changed the title Add a TickUtil class to converts minutes/seconds to ticks Add a TickUtil class to convert minutes/seconds to ticks Apr 30, 2018
package net.glowstone.util;

/**
* Utility class to ease conversion between minutes/seconds and ticks.

This comment has been minimized.

@aramperes

aramperes May 1, 2018
Member

Since this class only does SI -> ticks, change this to "from standard time units to in-game ticks."

* @return The corresponding number of ticks.
*/
public static int secondsToTicks(int seconds) {
return 20 * seconds;

This comment has been minimized.

@aramperes

aramperes May 1, 2018
Member

Put the 20's in a constant, e.g. TICKS_PER_SECOND

@aramperes aramperes merged commit d0ae1ba into GlowstoneMC:dev May 2, 2018
2 checks passed
2 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.