Package net.minecraft
Class Util
java.lang.Object
net.minecraft.Util
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ExecutorService
private static final int
private static final int
private static final ExecutorService
private static final DateTimeFormatter
private static final ExecutorService
static final int
(package private) static final org.slf4j.Logger
private static final String
static final long
static final UUID
static final com.google.common.base.Ticker
static TimeSource.NanoTimeSource
static final FileSystemProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Predicate
<T> static <T> Predicate
<T> static ExecutorService
static <T> CompletableFuture
<T> blockUntilDone
(Function<Executor, CompletableFuture<T>> task) static <T> T
blockUntilDone
(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 void
copyBetweenDirs
(Path fromDirectory, Path toDirectory, Path filePath) private static BooleanSupplier
createDeleter
(Path filePath) private static BooleanSupplier
createFileCreatedCheck
(Path filePath) private static BooleanSupplier
createFileDeletedCheck
(Path filePath) static <T> ToIntFunction
<T> createIndexIdentityLookup
(List<T> list) static <T> ToIntFunction
<T> createIndexLookup
(List<T> list) private static BooleanSupplier
createRenamer
(Path filePath, Path newName) static String
describeError
(Throwable throwable) private static com.mojang.datafixers.types.Type
<?> doFetchChoiceType
(com.mojang.datafixers.DSL.TypeReference p_type, String choiceName) private static void
private static boolean
executeInSequence
(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> T
findNextInIterable
(Iterable<T> iterable, T element) static <T> T
findPreviousInIterable
(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 long
static String
private static int
static long
static long
getNanos()
static Util.OS
static <T extends Comparable<T>>
StringgetPropertyName
(Property<T> property, Object value) static int
getRandom
(int[] selections, RandomSource random) static <T> T
getRandom
(List<T> selections, RandomSource random) static <T> T
getRandom
(T[] selections, RandomSource random) static <T> Optional
<T> getRandomSafe
(List<T> selections, RandomSource random) static <T> String
getRegisteredName
(Registry<T> registry, T value) static <T> Optional
<T> static ExecutorService
ioPool()
static <T> boolean
isSymmetrical
(int width, int height, List<T> list) static <T> T
static void
logAndPauseIfInIde
(String error) static void
logAndPauseIfInIde
(String message, Throwable error) static <T> T
static <T> T
static String
makeDescriptionId
(String type, ResourceLocation id) private static ExecutorService
makeExecutor
(String serviceName) private static ExecutorService
makeIoExecutor
(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 Runnable
static <T> Supplier
<T> static ExecutorService
static int
offsetByCodepoints
(String text, int cursorPos, int direction) private static void
onThreadException
(Thread thread, Throwable throwable) static URI
static <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 boolean
runWithRetries
(int maxTries, String actionName, BooleanSupplier... suppliers) static void
safeReplaceFile
(Path current, Path latest, Path oldBackup) static boolean
safeReplaceOrMoveFile
(Path current, Path latest, Path oldBackup, boolean p_212228_) static String
sanitizeName
(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 void
static <T> void
shuffle
(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 void
shutdownExecutor
(ExecutorService service) static void
static <K,
V> SingleKeyCache <K, V> singleKeyCache
(Function<K, V> computeValue) static void
static void
throwAsRuntime
(Throwable throwable) toMap()
static it.unimi.dsi.fastutil.ints.IntArrayList
toShuffledList
(IntStream stream, RandomSource random) static <T> List
<T> toShuffledList
(Stream<T> stream, RandomSource random) static Runnable
wrapThreadWithTaskName
(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
-