Package net.minecraft
Class Util
java.lang.Object
net.minecraft.Util
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ExecutorServiceprivate static final intprivate static final intprivate static final ExecutorServiceprivate static final DateTimeFormatterprivate static final ExecutorServicestatic final int(package private) static final org.slf4j.Loggerprivate static final Stringstatic final longstatic final UUIDstatic final com.google.common.base.Tickerstatic TimeSource.NanoTimeSourcestatic final FileSystemProvider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Predicate<T> static <T> Predicate<T> static ExecutorServicestatic <T> CompletableFuture<T> blockUntilDone(Function<Executor, CompletableFuture<T>> task) static <T> TblockUntilDone(Function<Executor, T> task, Predicate<T> donePredicate) static <T> List<T> copyAndAdd(List<T> list, T value) static <T> List<T> copyAndAdd(T value, List<T> list) static <K,V> Map <K, V> copyAndPut(Map<K, V> map, K key, V value) static voidcopyBetweenDirs(Path fromDirectory, Path toDirectory, Path filePath) private static BooleanSuppliercreateDeleter(Path filePath) private static BooleanSuppliercreateFileCreatedCheck(Path filePath) private static BooleanSuppliercreateFileDeletedCheck(Path filePath) static <T> ToIntFunction<T> createIndexIdentityLookup(List<T> list) static <T> ToIntFunction<T> createIndexLookup(List<T> list) private static BooleanSuppliercreateRenamer(Path filePath, Path newName) static StringdescribeError(Throwable throwable) private static com.mojang.datafixers.types.Type<?> doFetchChoiceType(com.mojang.datafixers.DSL.TypeReference p_type, String choiceName) private static voidprivate static booleanexecuteInSequence(BooleanSupplier... suppliers) private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> completableFutures, Consumer<Throwable> throwableConsumer) static com.mojang.datafixers.types.Type<?> fetchChoiceType(com.mojang.datafixers.DSL.TypeReference type, String choiceName) static <T> TfindNextInIterable(Iterable<T> iterable, T element) static <T> TfindPreviousInIterable(Iterable<T> iterable, T current) static <T> com.mojang.serialization.DataResult<List<T>> static com.mojang.serialization.DataResult<int[]> static com.mojang.serialization.DataResult<long[]> fixedSize(LongStream stream, int expectedSize) static longstatic Stringprivate static intstatic longstatic longgetNanos()static Util.OSstatic <T extends Comparable<T>>
StringgetPropertyName(Property<T> property, Object value) static intgetRandom(int[] selections, RandomSource random) static <T> TgetRandom(List<T> selections, RandomSource random) static <T> TgetRandom(T[] selections, RandomSource random) static <T> Optional<T> getRandomSafe(List<T> selections, RandomSource random) static <T> StringgetRegisteredName(Registry<T> registry, T value) static <T> Optional<T> static ExecutorServiceioPool()static <T> booleanisSymmetrical(int width, int height, List<T> list) static <T> Tstatic voidlogAndPauseIfInIde(String error) static voidlogAndPauseIfInIde(String message, Throwable error) static <T> Tstatic <T> Tstatic StringmakeDescriptionId(String type, ResourceLocation id) private static ExecutorServicemakeExecutor(String serviceName) private static ExecutorServicemakeIoExecutor(String name, boolean daemon) static <T,U, R> BiFunction <T, U, R> memoize(BiFunction<T, U, R> memoBiFunction) static <T,R> Function <T, R> static Runnablestatic <T> Supplier<T> static ExecutorServicestatic intoffsetByCodepoints(String text, int cursorPos, int direction) private static voidonThreadException(Thread thread, Throwable throwable) static URIstatic <T extends Throwable>
TpauseInIde(T throwable) static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> type, com.mojang.serialization.Dynamic<?> data) static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> type, com.mojang.serialization.Dynamic<?> data, boolean partial) private static booleanrunWithRetries(int maxTries, String actionName, BooleanSupplier... suppliers) static voidsafeReplaceFile(Path current, Path latest, Path oldBackup) static booleansafeReplaceOrMoveFile(Path current, Path latest, Path oldBackup, boolean p_212228_) static StringsanitizeName(String fileName, CharPredicate characterValidator) static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) Takes a list of futures and returns a future of list that completes when all of them succeed or any of them error,static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> completableFutures) static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> completableFutures) static voidstatic <T> voidshuffle(List<T> list, RandomSource random) static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> list, RandomSource random) static <T> List<T> shuffledCopy(T[] array, RandomSource random) private static voidshutdownExecutor(ExecutorService service) static voidstatic <K,V> SingleKeyCache <K, V> singleKeyCache(Function<K, V> computeValue) static voidstatic voidthrowAsRuntime(Throwable throwable) toMap()static it.unimi.dsi.fastutil.ints.IntArrayListtoShuffledList(IntStream stream, RandomSource random) static <T> List<T> toShuffledList(Stream<T> stream, RandomSource random) static RunnablewrapThreadWithTaskName(String name, Runnable task) static <V> Supplier<V> wrapThreadWithTaskName(String name, Supplier<V> task) static <A,B> com.mojang.datafixers.Typed <B> writeAndReadTypedOrThrow(com.mojang.datafixers.Typed<A> typed, com.mojang.datafixers.types.Type<B> type, UnaryOperator<com.mojang.serialization.Dynamic<?>> operator)
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
DEFAULT_MAX_THREADS
private static final int DEFAULT_MAX_THREADS- See Also:
-
DEFAULT_SAFE_FILE_OPERATION_RETRIES
private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES- See Also:
-
MAX_THREADS_SYSTEM_PROPERTY
- See Also:
-
BACKGROUND_EXECUTOR
-
IO_POOL
-
DOWNLOAD_POOL
-
FILENAME_DATE_TIME_FORMATTER
-
LINEAR_LOOKUP_THRESHOLD
public static final int LINEAR_LOOKUP_THRESHOLD- See Also:
-
ALLOWED_UNTRUSTED_LINK_PROTOCOLS
-
NANOS_PER_MILLI
public static final long NANOS_PER_MILLI- See Also:
-
timeSource
-
TICKER
public static final com.google.common.base.Ticker TICKER -
NIL_UUID
-
ZIP_FILE_SYSTEM_PROVIDER
-
thePauser
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
toMap
-
toMutableList
-
getPropertyName
-
makeDescriptionId
-
getMillis
public static long getMillis() -
getNanos
public static long getNanos() -
getEpochMillis
public static long getEpochMillis() -
getFilenameFormattedDateTime
-
makeExecutor
-
getMaxThreads
private static int getMaxThreads() -
backgroundExecutor
-
ioPool
-
nonCriticalIoPool
-
shutdownExecutors
public static void shutdownExecutors() -
shutdownExecutor
-
makeIoExecutor
-
throwAsRuntime
-
onThreadException
-
fetchChoiceType
@Nullable public static com.mojang.datafixers.types.Type<?> fetchChoiceType(com.mojang.datafixers.DSL.TypeReference type, String choiceName) -
doFetchChoiceType
@Nullable private static com.mojang.datafixers.types.Type<?> doFetchChoiceType(com.mojang.datafixers.DSL.TypeReference p_type, String choiceName) -
wrapThreadWithTaskName
-
wrapThreadWithTaskName
-
getRegisteredName
-
allOf
-
anyOf
-
isSymmetrical
-
getPlatform
-
parseAndValidateUntrustedUri
- Throws:
URISyntaxException
-
getVmArguments
-
lastOf
-
findNextInIterable
-
findPreviousInIterable
-
make
-
make
-
sequence
Takes a list of futures and returns a future of list that completes when all of them succeed or any of them error, -
sequenceFailFast
public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> completableFutures) -
sequenceFailFastAndCancel
public static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> completableFutures) -
fallibleSequence
private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> completableFutures, Consumer<Throwable> throwableConsumer) -
ifElse
-
name
-
name
-
logAndPauseIfInIde
-
logAndPauseIfInIde
-
pauseInIde
-
setPause
-
doPause
-
describeError
-
getRandom
-
getRandom
-
getRandom
-
getRandomSafe
-
createRenamer
-
createDeleter
-
createFileDeletedCheck
-
createFileCreatedCheck
-
executeInSequence
-
runWithRetries
private static boolean runWithRetries(int maxTries, String actionName, BooleanSupplier... suppliers) -
safeReplaceFile
-
safeReplaceOrMoveFile
-
offsetByCodepoints
-
prefix
-
fixedSize
-
fixedSize
public static com.mojang.serialization.DataResult<long[]> fixedSize(LongStream stream, int expectedSize) -
fixedSize
-
startTimerHackThread
public static void startTimerHackThread() -
copyBetweenDirs
public static void copyBetweenDirs(Path fromDirectory, Path toDirectory, Path filePath) throws IOException - Throws:
IOException
-
sanitizeName
-
singleKeyCache
-
memoize
-
memoize
-
toShuffledList
-
toShuffledList
public static it.unimi.dsi.fastutil.ints.IntArrayList toShuffledList(IntStream stream, RandomSource random) -
shuffledCopy
-
shuffledCopy
public static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> list, RandomSource random) -
shuffle
-
blockUntilDone
-
blockUntilDone
-
createIndexLookup
-
createIndexIdentityLookup
-
writeAndReadTypedOrThrow
public static <A,B> com.mojang.datafixers.Typed<B> writeAndReadTypedOrThrow(com.mojang.datafixers.Typed<A> typed, com.mojang.datafixers.types.Type<B> type, UnaryOperator<com.mojang.serialization.Dynamic<?>> operator) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> type, com.mojang.serialization.Dynamic<?> data) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> type, com.mojang.serialization.Dynamic<?> data, boolean partial) -
copyAndAdd
-
copyAndAdd
-
copyAndPut
-