Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track Client Side Initialization progress and only allow ticking if i…
…t completed. Fixes #316
- Loading branch information
1 parent
74c106a
commit dacf302
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package mod.chiselsandbits.helpers; | ||
|
||
public enum ReadyState | ||
{ | ||
PENDING_PRE, | ||
PENDING_INIT, | ||
PENDING_POST, | ||
READY, | ||
|
||
TRIGGER_PRE, | ||
TRIGGER_INIT, | ||
TRIGGER_POST; | ||
|
||
public boolean isReady() | ||
{ | ||
return this == READY; | ||
} | ||
|
||
public ReadyState updateState( | ||
ReadyState trigger ) | ||
{ | ||
switch ( trigger ) | ||
{ | ||
case TRIGGER_INIT: | ||
if ( this == PENDING_INIT ) | ||
return PENDING_POST; | ||
throw new RuntimeException( "Triggered " + trigger.toString() + " but was " + this.toString() ); | ||
case TRIGGER_POST: | ||
if ( this == PENDING_POST ) | ||
return READY; | ||
throw new RuntimeException( "Triggered " + trigger.toString() + " but was " + this.toString() ); | ||
case TRIGGER_PRE: | ||
if ( this == PENDING_PRE ) | ||
return PENDING_INIT; | ||
throw new RuntimeException( "Triggered " + trigger.toString() + " but was " + this.toString() ); | ||
default: | ||
} | ||
|
||
throw new RuntimeException( "Invalid Trigger" ); | ||
} | ||
} |