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 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>> pTask) static <T> TblockUntilDone(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 voidcopyBetweenDirs(Path pFromDirectory, Path pToDirectory, Path pFilePath) private static BooleanSuppliercreateDeleter(Path pFilePath) private static BooleanSuppliercreateFileCreatedCheck(Path pFilePath) private static BooleanSuppliercreateFileDeletedCheck(Path pFilePath) static <T> ToIntFunction<T> createIndexIdentityLookup(List<T> pList) static <T> ToIntFunction<T> createIndexLookup(List<T> pList) private static BooleanSuppliercreateRenamer(Path pFilePath, Path pNewName) static StringdescribeError(Throwable pThrowable) private static com.mojang.datafixers.types.Type<?> doFetchChoiceType(com.mojang.datafixers.DSL.TypeReference pType, String pChoiceName) private static voidprivate static booleanexecuteInSequence(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 pType, String pChoiceName) static <T> TfindNextInIterable(Iterable<T> pIterable, T pElement) static <T> TfindPreviousInIterable(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 pStream, int pExpectedSize) static longstatic Stringprivate static intstatic longstatic longgetNanos()static Util.OSstatic <T extends Comparable<T>>
StringgetPropertyName(Property<T> pProperty, Object pValue) static intgetRandom(int[] pSelections, RandomSource pRandom) static <T> TgetRandom(List<T> pSelections, RandomSource pRandom) static <T> TgetRandom(T[] pSelections, RandomSource pRandom) static <T> Optional<T> getRandomSafe(List<T> pSelections, RandomSource pRandom) static <T> StringgetRegisteredName(Registry<T> pRegistry, T pValue) static <T> Optional<T> static ExecutorServiceioPool()static <T> booleanisSymmetrical(int pWidth, int pHeight, List<T> pList) static <T> Tstatic voidlogAndPauseIfInIde(String pError) static voidlogAndPauseIfInIde(String pMessage, Throwable pError) static <T> Tstatic <T> Tstatic StringmakeDescriptionId(String pType, ResourceLocation pId) private static ExecutorServicemakeExecutor(String pServiceName) private static ExecutorServicemakeIoExecutor(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 Runnablestatic <T> Supplier<T> static ExecutorServicestatic intoffsetByCodepoints(String pText, int pCursorPos, int pDirection) private static voidonThreadException(Thread p_137496_, Throwable p_137497_) static URIstatic <T extends Throwable>
TpauseInIde(T pThrowable) static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> pType, com.mojang.serialization.Dynamic<?> pData) static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> pType, com.mojang.serialization.Dynamic<?> pData, boolean pPartial) private static booleanrunWithRetries(int pMaxTries, String pActionName, BooleanSupplier... pSuppliers) static voidsafeReplaceFile(Path pCurrent, Path pLatest, Path pOldBackup) static booleansafeReplaceOrMoveFile(Path pCurrent, Path pLatest, Path pOldBackup, boolean p_212228_) static StringsanitizeName(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 voidstatic <T> voidshuffle(List<T> pList, RandomSource pRandom) static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> pList, RandomSource pRandom) static <T> List<T> shuffledCopy(T[] pArray, RandomSource pRandom) private static voidshutdownExecutor(ExecutorService pService) static voidstatic <K,V> SingleKeyCache <K, V> singleKeyCache(Function<K, V> pComputeValue) static voidstatic voidthrowAsRuntime(Throwable pThrowable) toMap()static it.unimi.dsi.fastutil.ints.IntArrayListtoShuffledList(IntStream pStream, RandomSource pRandom) static <T> List<T> toShuffledList(Stream<T> pStream, RandomSource pRandom) static RunnablewrapThreadWithTaskName(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> pTyped, com.mojang.datafixers.types.Type<B> pType, UnaryOperator<com.mojang.serialization.Dynamic<?>> pOperator)
-
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
-
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 pType, String pChoiceName) -
doFetchChoiceType
@Nullable private static com.mojang.datafixers.types.Type<?> doFetchChoiceType(com.mojang.datafixers.DSL.TypeReference pType, String pChoiceName) -
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
-
fixedSize
public static com.mojang.serialization.DataResult<long[]> fixedSize(LongStream pStream, int pExpectedSize) -
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 pStream, RandomSource pRandom) -
shuffledCopy
-
shuffledCopy
public static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> pList, RandomSource pRandom) -
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> pTyped, com.mojang.datafixers.types.Type<B> pType, UnaryOperator<com.mojang.serialization.Dynamic<?>> pOperator) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> pType, com.mojang.serialization.Dynamic<?> pData) -
readTypedOrThrow
public static <T> com.mojang.datafixers.Typed<T> readTypedOrThrow(com.mojang.datafixers.types.Type<T> pType, com.mojang.serialization.Dynamic<?> pData, boolean pPartial) -
copyAndAdd
-
copyAndAdd
-
copyAndPut
-