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>> pTask) static <T> T
blockUntilDone
(Function<Executor, T> pTask, Predicate<T> pDonePredicate) static <T> List
<T> copyAndAdd
(List<T> pList, T pValue) static <T> List
<T> copyAndAdd
(T pValue, List<T> pList) static <K,
V> Map <K, V> copyAndPut
(Map<K, V> pMap, K pKey, V pValue) static void
copyBetweenDirs
(Path pFromDirectory, Path pToDirectory, Path pFilePath) private static BooleanSupplier
createDeleter
(Path pFilePath) private static BooleanSupplier
createFileCreatedCheck
(Path pFilePath) private static BooleanSupplier
createFileDeletedCheck
(Path pFilePath) static <T> ToIntFunction
<T> createIndexIdentityLookup
(List<T> pList) static <T> ToIntFunction
<T> createIndexLookup
(List<T> pList) private static BooleanSupplier
createRenamer
(Path pFilePath, Path pNewName) static String
describeError
(Throwable pThrowable) private static com.mojang.datafixers.types.Type
<?> doFetchChoiceType
(com.mojang.datafixers.DSL.TypeReference p_137552_, String p_137553_) private static void
private static boolean
executeInSequence
(BooleanSupplier... pSuppliers) private static <V> CompletableFuture
<List<V>> fallibleSequence
(List<? extends CompletableFuture<? extends V>> pCompletableFutures, Consumer<Throwable> pThrowableConsumer) static com.mojang.datafixers.types.Type
<?> fetchChoiceType
(com.mojang.datafixers.DSL.TypeReference p_137457_, String p_137458_) static <T> T
findNextInIterable
(Iterable<T> pIterable, T pElement) static <T> T
findPreviousInIterable
(Iterable<T> pIterable, T pCurrent) static <T> com.mojang.serialization.DataResult
<List<T>> static com.mojang.serialization.DataResult
<int[]> static com.mojang.serialization.DataResult
<long[]> fixedSize
(LongStream p_287579_, int p_287631_) static long
static String
private static int
static long
static long
getNanos()
static Util.OS
static <T extends Comparable<T>>
StringgetPropertyName
(Property<T> pProperty, Object pValue) static int
getRandom
(int[] pSelections, RandomSource pRandom) static <T> T
getRandom
(List<T> pSelections, RandomSource pRandom) static <T> T
getRandom
(T[] pSelections, RandomSource pRandom) static <T> Optional
<T> getRandomSafe
(List<T> pSelections, RandomSource pRandom) static <T> String
getRegisteredName
(Registry<T> pRegistry, T pValue) static <T> Optional
<T> static ExecutorService
ioPool()
static <T> boolean
isSymmetrical
(int pWidth, int pHeight, List<T> pList) static <T> T
static void
logAndPauseIfInIde
(String pError) static void
logAndPauseIfInIde
(String pMessage, Throwable pError) static <T> T
static <T> T
static String
makeDescriptionId
(String pType, ResourceLocation pId) private static ExecutorService
makeExecutor
(String pServiceName) private static ExecutorService
makeIoExecutor
(String pName, boolean pDaemon) static <T,
U, R> BiFunction <T, U, R> memoize
(BiFunction<T, U, R> pMemoBiFunction) static <T,
R> Function <T, R> static Runnable
static <T> Supplier
<T> static ExecutorService
static int
offsetByCodepoints
(String pText, int pCursorPos, int pDirection) private static void
onThreadException
(Thread p_137496_, Throwable p_137497_) static URI
static <T extends Throwable>
TpauseInIde
(T pThrowable) static <T> com.mojang.datafixers.Typed
<T> readTypedOrThrow
(com.mojang.datafixers.types.Type<T> p_312508_, com.mojang.serialization.Dynamic<?> p_312911_) static <T> com.mojang.datafixers.Typed
<T> readTypedOrThrow
(com.mojang.datafixers.types.Type<T> p_313853_, com.mojang.serialization.Dynamic<?> p_313851_, boolean p_313933_) private static boolean
runWithRetries
(int pMaxTries, String pActionName, BooleanSupplier... pSuppliers) static void
safeReplaceFile
(Path pCurrent, Path pLatest, Path pOldBackup) static boolean
safeReplaceOrMoveFile
(Path pCurrent, Path pLatest, Path pOldBackup, boolean p_212228_) static String
sanitizeName
(String pFileName, CharPredicate pCharacterValidator) static <V> CompletableFuture
<List<V>> sequence
(List<? extends CompletableFuture<V>> pFutures) 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>> pCompletableFutures) static <V> CompletableFuture
<List<V>> sequenceFailFastAndCancel
(List<? extends CompletableFuture<? extends V>> pCompletableFutures) static void
static <T> void
shuffle
(List<T> pList, RandomSource pRandom) static <T> List
<T> shuffledCopy
(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> p_214612_, RandomSource p_214613_) static <T> List
<T> shuffledCopy
(T[] pArray, RandomSource pRandom) private static void
shutdownExecutor
(ExecutorService pService) static void
static <K,
V> SingleKeyCache <K, V> singleKeyCache
(Function<K, V> pComputeValue) static void
static void
throwAsRuntime
(Throwable pThrowable) toMap()
static it.unimi.dsi.fastutil.ints.IntArrayList
toShuffledList
(IntStream p_214659_, RandomSource p_214660_) static <T> List
<T> toShuffledList
(Stream<T> pStream, RandomSource pRandom) static Runnable
wrapThreadWithTaskName
(String pName, Runnable pTask) static <V> Supplier
<V> wrapThreadWithTaskName
(String pName, Supplier<V> pTask) static <A,
B> com.mojang.datafixers.Typed <B> writeAndReadTypedOrThrow
(com.mojang.datafixers.Typed<A> p_311873_, com.mojang.datafixers.types.Type<B> p_312554_, UnaryOperator<com.mojang.serialization.Dynamic<?>> p_311990_)
-
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
public static <T extends Comparable<T>> String getPropertyName(Property<T> pProperty, Object pValue) -
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 p_137457_, String p_137458_) -
doFetchChoiceType
@Nullable private static com.mojang.datafixers.types.Type<?> doFetchChoiceType(com.mojang.datafixers.DSL.TypeReference p_137552_, String p_137553_) -
wrapThreadWithTaskName
-
wrapThreadWithTaskName
-
getRegisteredName
-
allOf
-
anyOf
-
isSymmetrical
-
getPlatform
-
parseAndValidateUntrustedUri
- Throws:
URISyntaxException
-
getVmArguments
-
lastOf
-
findNextInIterable
-
findPreviousInIterable
-
make
-
make
-
sequence
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> pFutures) 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>> pCompletableFutures) -
sequenceFailFastAndCancel
public static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> pCompletableFutures) -
fallibleSequence
private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> pCompletableFutures, Consumer<Throwable> pThrowableConsumer) -
ifElse
-
name
-
name
-
logAndPauseIfInIde
-
logAndPauseIfInIde
-
pauseInIde
-
setPause
-
doPause
-
describeError
-
getRandom
-
getRandom
-
getRandom
-
getRandomSafe
-
createRenamer
-
createDeleter
-
createFileDeletedCheck
-
createFileCreatedCheck
-
executeInSequence
-
runWithRetries
private static boolean runWithRetries(int pMaxTries, String pActionName, BooleanSupplier... pSuppliers) -
safeReplaceFile
-
safeReplaceOrMoveFile
-
offsetByCodepoints
-
prefix
-
fixedSize
public static com.mojang.serialization.DataResult<int[]> fixedSize(IntStream p_137540_, int p_137541_) -
fixedSize
public static com.mojang.serialization.DataResult<long[]> fixedSize(LongStream p_287579_, int p_287631_) -
fixedSize
-
startTimerHackThread
public static void startTimerHackThread() -
copyBetweenDirs
public static void copyBetweenDirs(Path pFromDirectory, Path pToDirectory, Path pFilePath) throws IOException - Throws:
IOException
-
sanitizeName
-
singleKeyCache
-
memoize
-
memoize
-
toShuffledList
-
toShuffledList
public static it.unimi.dsi.fastutil.ints.IntArrayList toShuffledList(IntStream p_214659_, RandomSource p_214660_) -
shuffledCopy
-
shuffledCopy
public static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> p_214612_, RandomSource p_214613_) -
shuffle
-
blockUntilDone
public static <T> CompletableFuture<T> blockUntilDone(Function<Executor, CompletableFuture<T>> pTask) -
blockUntilDone
-
createIndexLookup
-
createIndexIdentityLookup
-
writeAndReadTypedOrThrow
public static <A,B> com.mojang.datafixers.Typed<B> writeAndReadTypedOrThrow(com.mojang.datafixers.Typed<A> p_311873_, com.mojang.datafixers.types.Type<B> p_312554_, UnaryOperator<com.mojang.serialization.Dynamic<?>> p_311990_) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> p_312508_, com.mojang.serialization.Dynamic<?> p_312911_) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> p_313853_, com.mojang.serialization.Dynamic<?> p_313851_, boolean p_313933_) -
copyAndAdd
-
copyAndAdd
-
copyAndPut
-