Interface DistExecutor.SafeReferent

All Known Subinterfaces:
DistExecutor.SafeCallable<T>, DistExecutor.SafeRunnable, DistExecutor.SafeSupplier<T>
Enclosing class:
DistExecutor

public static interface DistExecutor.SafeReferent
A safe referent. This will assert that it is being called via a separated class method reference. This will avoid the common pitfalls of DistExecutor.callWhenOn(Dist, Supplier) above. SafeReferents assert that they are defined as a separate method outside the scope of the calling class. Implementations need to be defined in a separate class to the referring site, with appropriate visibility to be accessible at the callsite (generally, avoid private methods).

Valid:
DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->AnotherClass::clientOnlyMethod);

Invalid:
DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->()->Minecraft.getInstance().world);