Package dev.twilite.game.common
Class TickAssumption<T>
java.lang.Object
dev.twilite.game.common.TickAssumption<T>
Stores a predicted value that is only trusted for the current game tick.
This is useful after enqueueing a client action whose backing varp or varbit will not update until a later client cycle or server tick. The facade can assume the requested value immediately, while still falling back to the real client state once the tick changes.
private static final TickAssumption<Boolean> ENABLED = new TickAssumption<>();
public static boolean enabled() {
return ENABLED.get(() -> Game.var(VarpId.SOME_TOGGLE) == 1);
}
public static boolean setEnabled(boolean enabled) {
if (enabled() == enabled) {
return false;
}
if (clickToggle()) {
ENABLED.set(enabled);
return true;
}
return false;
}
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TickAssumption
public TickAssumption()
-
-
Method Details
-
get
Returns the assumed value for this tick, or the supplied fallback value. -
set
Assumesvaluefor the current game tick.
-