Package net.minecraft.util
Class Util
java.lang.Object
net.minecraft.util.Util
public class Util extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Util.IdentityHashStrategy
static class
Util.OperatingSystem
-
Field Summary
Fields Modifier and Type Field Description private static ExecutorService
BOOTSTRAP_EXECUTOR
private static ExecutorService
IO_WORKER_EXECUTOR
private static Logger
LOGGER
private static ExecutorService
MAIN_WORKER_EXECUTOR
static LongSupplier
nanoTimeSupplier
private static AtomicInteger
NEXT_WORKER_ID
static UUID
NIL_UUID
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
Modifier and Type Method Description private static void
attemptShutdown(ExecutorService service)
private static boolean
attemptTasks(int retries, String taskName, BooleanSupplier[] tasks)
private static boolean
attemptTasks(BooleanSupplier[] booleanSupplier)
static void
backupAndReplace(File current, File newFile, File backup)
static void
backupAndReplace(Path current, Path newPath, Path backup)
Copiescurrent
tobackup
and then replacescurrent
withnewPath
static <V> CompletableFuture<List<V>>
combine(List<? extends CompletableFuture<? extends V>> futures)
static <T> CompletableFuture<T>
completeExceptionally(Throwable throwable)
private static ExecutorService
createIoWorker()
static String
createTranslationKey(String type, Identifier id)
private static ExecutorService
createWorker(String name)
static Runnable
debugRunnable(Runnable runnable, Supplier<String> messageSupplier)
private static BooleanSupplier
deleteTask(Path path)
private static BooleanSupplier
deletionVerifyTask(Path path)
private static BooleanSupplier
existenceCheckTask(Path path)
static Executor
getBootstrapExecutor()
static com.mojang.datafixers.types.Type<?>
getChoiceType(com.mojang.datafixers.DSL.TypeReference typeReference, String id)
private static com.mojang.datafixers.types.Type<?>
getChoiceTypeInternal(com.mojang.datafixers.DSL.TypeReference typeReference, String id)
static long
getEpochTimeMs()
static String
getInnermostMessage(Throwable t)
static Executor
getIoWorkerExecutor()
static Stream<String>
getJVMFlags()
static <T> T
getLast(List<T> list)
static Executor
getMainWorkerExecutor()
static long
getMeasuringTimeMs()
static long
getMeasuringTimeNano()
static Util.OperatingSystem
getOperatingSystem()
static int
getRandom(int[] array, Random random)
static <T> T
getRandom(T[] array, Random random)
static <T extends Comparable<T>>
StringgetValueAsString(Property<T> property, Object object)
static <K> Hash.Strategy<K>
identityHashStrategy()
static <T> Optional<T>
ifPresentOrElse(Optional<T> optional, Consumer<T> consumer, Runnable runnable)
static <T> T
make(Supplier<T> factory)
static <T> T
make(T object, Consumer<T> initializer)
private static void
method_18347(Thread thread, Throwable throwable)
static Consumer<String>
method_29188(String string, Consumer<String> consumer)
static int
moveCursor(String string, int cursor, int delta)
Moves thecursor
in thestring
by adelta
amount.static <T> T
next(Iterable<T> iterable, T t)
static <T> T
previous(Iterable<T> iterable, T t)
static void
relativeCopy(Path src, Path dest, Path toCopy)
Copies a file contained in the foldersrc
to the folderdest
.private static BooleanSupplier
renameTask(Path src, Path dest)
static String
replaceInvalidChars(String string, CharPredicate predicate)
static void
shutdownExecutors()
static void
startTimerHack()
static <T> Stream<T>
stream(Optional<? extends T> optional)
static <T extends Throwable>
TthrowOrPause(T t)
static void
throwUnchecked(Throwable throwable)
static com.mojang.serialization.DataResult<int[]>
toIntArray(IntStream intStream, int length)
static <K, V> Collector<Map.Entry<? extends K,? extends V>,?,Map<K,V>>
toMap()
-
Field Details
-
NEXT_WORKER_ID
-
BOOTSTRAP_EXECUTOR
-
MAIN_WORKER_EXECUTOR
-
IO_WORKER_EXECUTOR
-
nanoTimeSupplier
-
NIL_UUID
-
LOGGER
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
toMap
-
getValueAsString
public static <T extends Comparable<T>> String getValueAsString(Property<T> property, Object object) -
createTranslationKey
-
getMeasuringTimeMs
public static long getMeasuringTimeMs() -
getMeasuringTimeNano
public static long getMeasuringTimeNano() -
getEpochTimeMs
public static long getEpochTimeMs() -
createWorker
-
getBootstrapExecutor
-
getMainWorkerExecutor
-
getIoWorkerExecutor
-
shutdownExecutors
public static void shutdownExecutors() -
attemptShutdown
-
createIoWorker
-
completeExceptionally
@Environment(CLIENT) public static <T> CompletableFuture<T> completeExceptionally(Throwable throwable) -
throwUnchecked
-
method_18347
-
getChoiceType
-
getChoiceTypeInternal
-
getOperatingSystem
-
getJVMFlags
-
getLast
-
next
-
previous
-
make
-
make
-
identityHashStrategy
-
combine
public static <V> CompletableFuture<List<V>> combine(List<? extends CompletableFuture<? extends V>> futures) -
stream
-
ifPresentOrElse
-
debugRunnable
-
throwOrPause
-
getInnermostMessage
-
getRandom
-
getRandom
-
renameTask
-
deleteTask
-
deletionVerifyTask
-
existenceCheckTask
-
attemptTasks
-
attemptTasks
-
backupAndReplace
-
backupAndReplace
Copiescurrent
tobackup
and then replacescurrent
withnewPath
-
moveCursor
Moves thecursor
in thestring
by adelta
amount. Skips surrogate characters. -
method_29188
-
toIntArray
public static com.mojang.serialization.DataResult<int[]> toIntArray(IntStream intStream, int length) -
startTimerHack
public static void startTimerHack() -
relativeCopy
@Environment(CLIENT) public static void relativeCopy(Path src, Path dest, Path toCopy) throws IOExceptionCopies a file contained in the foldersrc
to the folderdest
. This will replicate any path structure that may exist betweensrc
andtoCopy
.- Throws:
IOException
-
replaceInvalidChars
@Environment(CLIENT) public static String replaceInvalidChars(String string, CharPredicate predicate)
-