Class Util
java.lang.Object
net.minecraft.util.Util
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TracingExecutorprivate static final intprivate static final intprivate static final TracingExecutorprivate static final DateTimeFormatterprivate static final TracingExecutorstatic final intprivate 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> allOf()static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3) static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4) static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4, Predicate<? super T> condition5) static <T> Predicate<T> allOfEnumExcept(T value) static <T> Predicate<T> anyOf()static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3) static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4) static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4, Predicate<? super T> condition5) static <T> Predicate<T> static TracingExecutorstatic <T> CompletableFuture<T> blockUntilDone(Function<Executor, CompletableFuture<T>> task) static <T> TblockUntilDone(Function<Executor, T> task, Predicate<T> completionCheck) static <T> List<T> copyAndAdd(List<T> list, T element) static <T> List<T> copyAndAdd(List<T> list, T... elements) static <T> List<T> copyAndAdd(T element, List<T> list) static <K,V> Map <K, V> copyAndPut(Map<K, V> map, K key, V value) static voidcopyBetweenDirs(Path sourceDir, Path targetDir, Path sourcePath) private static BooleanSuppliercreateDeleter(Path target) private static BooleanSuppliercreateFileCreatedCheck(Path target) private static BooleanSuppliercreateFileDeletedCheck(Path target) static <T> ToIntFunction<T> createIndexIdentityLookup(List<T> values) static <T> ToIntFunction<T> createIndexLookup(List<T> values) private static BooleanSuppliercreateRenamer(Path from, Path to, CopyOption... options) static StringdescribeError(Throwable err) private static @Nullable Type<?> doFetchChoiceType(DSL.TypeReference reference, String name) private static voidprivate static booleanexecuteInSequence(BooleanSupplier... operations) private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> futures, Consumer<Throwable> failureHandler) static @Nullable Type<?> fetchChoiceType(DSL.TypeReference reference, String name) static <T> TfindNextInIterable(Iterable<T> collection, @Nullable T current) static <T> TfindPreviousInIterable(Iterable<T> collection, @Nullable T current) static <T> DataResult<List<T>> static DataResult<int[]> static DataResult<long[]> fixedSize(LongStream stream, int size) static longstatic Stringprivate static intstatic longstatic longgetNanos()static Util.OSstatic <T extends Comparable<T>>
StringgetPropertyName(Property<T> key, Object value) static intgetRandom(int[] array, RandomSource random) static <T> TgetRandom(List<T> list, RandomSource random) static <T> TgetRandom(T[] array, RandomSource random) static <T> Optional<T> getRandomSafe(List<T> list, RandomSource random) static <T> StringgetRegisteredName(Registry<T> registry, T entry) static intgrowByHalf(int currentSize, int minimalNewSize) static <T> Optional<T> static TracingExecutorioPool()static booleanstatic <T> booleanisSymmetrical(int width, int height, List<T> ingredients) static DateTimeFormatterlocalizedDateFormatter(FormatStyle formatStyle) static voidlogAndPauseIfInIde(String message) static voidlogAndPauseIfInIde(String message, Throwable throwable) static <T> Tstatic <T> Tstatic StringmakeDescriptionId(String prefix, @Nullable Identifier location) makeEnumMap(Class<K> keyType, Function<K, V> function) private static TracingExecutormakeExecutor(String name) private static TracingExecutormakeIoExecutor(String prefix, boolean daemon) static <K,V1, V2> Map <K, V2> static <K,V1, V2> Map <K, V2> mapValuesLazy(Map<K, V1> map, com.google.common.base.Function<V1, V2> valueMapper) static intstatic <T,U, R> BiFunction <T, U, R> memoize(BiFunction<T, U, R> function) static <T,R> Function <T, R> static Runnablestatic <T> Supplier<T> static TracingExecutorstatic intoffsetByCodepoints(String input, int pos, int offset) private static voidonThreadException(Thread thread, Throwable throwable) static URIstatic <T extends Throwable>
TpauseInIde(T t) static <T> Typed<T> readTypedOrThrow(Type<T> type, Dynamic<?> dynamic) static <T> Typed<T> readTypedOrThrow(Type<T> type, Dynamic<?> dynamic, boolean acceptPartial) static voidprivate static booleanrunWithRetries(int numberOfRetries, String description, BooleanSupplier... operations) static booleansafeMoveFile(Path fromPath, Path toPath, CopyOption... options) static voidsafeReplaceFile(Path targetPath, Path newPath, Path backupPath) static booleansafeReplaceOrMoveFile(Path targetPath, Path newPath, Path backupPath, boolean noRollback) static StringsanitizeName(String value, CharPredicate isAllowedChar) static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> futures) static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> futures) 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) static voidstatic <K,V> SingleKeyCache <K, V> singleKeyCache(Function<K, V> computeValueFunction) 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 <A,B> Typed <B> writeAndReadTypedOrThrow(Typed<A> typed, Type<B> newType, UnaryOperator<Dynamic<?>> function)
-
Field Details
-
LOGGER
private 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
-
maxAllowedExecutorThreads
public static int maxAllowedExecutorThreads() -
getMaxThreads
private static int getMaxThreads() -
backgroundExecutor
-
ioPool
-
nonCriticalIoPool
-
shutdownExecutors
public static void shutdownExecutors() -
makeIoExecutor
-
throwAsRuntime
-
onThreadException
-
fetchChoiceType
-
doFetchChoiceType
-
runNamed
-
getRegisteredName
-
allOf
-
allOf
-
allOf
-
allOf
-
allOf
-
allOf
-
allOf
-
allOf
-
anyOf
-
anyOf
-
anyOf
-
anyOf
-
anyOf
-
anyOf
-
anyOf
-
anyOf
-
isSymmetrical
-
growByHalf
public static int growByHalf(int currentSize, int minimalNewSize) -
localizedDateFormatter
-
getPlatform
-
isAarch64
public static boolean isAarch64() -
parseAndValidateUntrustedUri
- Throws:
URISyntaxException
-
findNextInIterable
-
findPreviousInIterable
-
make
-
make
-
makeEnumMap
-
mapValues
-
mapValuesLazy
-
allOfEnumExcept
-
sequence
-
sequenceFailFast
public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> futures) -
sequenceFailFastAndCancel
public static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> futures) -
fallibleSequence
private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> futures, Consumer<Throwable> failureHandler) -
ifElse
-
name
-
name
-
logAndPauseIfInIde
-
logAndPauseIfInIde
-
pauseInIde
-
setPause
-
doPause
-
describeError
-
getRandom
-
getRandom
-
getRandom
-
getRandomSafe
-
createRenamer
-
createDeleter
-
createFileDeletedCheck
-
createFileCreatedCheck
-
executeInSequence
-
runWithRetries
private static boolean runWithRetries(int numberOfRetries, String description, BooleanSupplier... operations) -
safeMoveFile
-
safeReplaceFile
-
safeReplaceOrMoveFile
-
offsetByCodepoints
-
prefix
-
fixedSize
-
fixedSize
-
fixedSize
-
startTimerHackThread
public static void startTimerHackThread() -
copyBetweenDirs
public static void copyBetweenDirs(Path sourceDir, Path targetDir, Path sourcePath) 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
public static <T> CompletableFuture<T> blockUntilDone(Function<Executor, CompletableFuture<T>> task) -
blockUntilDone
-
createIndexLookup
-
createIndexIdentityLookup
-
writeAndReadTypedOrThrow
public static <A,B> Typed<B> writeAndReadTypedOrThrow(Typed<A> typed, Type<B> newType, UnaryOperator<Dynamic<?>> function) -
readTypedOrThrow
-
readTypedOrThrow
-
copyAndAdd
-
copyAndAdd
-
copyAndAdd
-
copyAndPut
-