package top.r3944realms.lib39.util; import top.r3944realms.lib39.Lib39; import java.util.function.Supplier; /** * The interface Client only. */ public interface IClientOnly { /** * Check. * * @param runnable the runnable */ static void check(Runnable runnable) { if (Lib39.isClientEnvironment()) { runnable.run(); return; } throw new RuntimeException("This method should be called in ClientEnvironment"); } /** * Check. * * @param runnable the runnable * @param fallback the fallback */ static void check(Runnable runnable, Runnable fallback) { if (Lib39.isClientEnvironment()) { runnable.run(); return; } fallback.run(); } /** * Check t. * * @param the type parameter * @param supplier the supplier * @return the t */ static T check(Supplier supplier) { if (Lib39.isClientEnvironment()) { return supplier.get(); } throw new RuntimeException("This method should be called in ClientEnvironment"); } /** * Check t. * * @param the type parameter * @param supplier the supplier * @param fallback the fallback * @return the t */ static T check(Supplier supplier, Supplier fallback) { if (Lib39.isClientEnvironment()) { return supplier.get(); } return fallback.get(); } }