Package net.minecraft
Class Util
java.lang.Object
net.minecraft.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 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> allOf()static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> static <T> Predicate<T> allOf(Predicate<? super T> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3) static <T> Predicate<T> allOf(Predicate<? super T> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3, Predicate<? super T> pPredicate4) static <T> Predicate<T> allOf(Predicate<? super T> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3, Predicate<? super T> pPredicate4, Predicate<? super T> pPredicate5) static <T> Predicate<T> 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> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3) static <T> Predicate<T> anyOf(Predicate<? super T> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3, Predicate<? super T> pPredicate4) static <T> Predicate<T> anyOf(Predicate<? super T> pPredicate1, Predicate<? super T> pPredicate2, Predicate<? super T> pPredicate3, Predicate<? super T> pPredicate4, Predicate<? super T> pPredicate5) static <T> Predicate<T> static TracingExecutorstatic <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 intgrowByHalf(int pValue, int pMinValue) static <T> Optional<T> static TracingExecutorioPool()static booleanstatic <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) makeEnumMap(Class<K> pEnumClass, Function<K, V> pValueGetter) private static TracingExecutormakeExecutor(String pName) private static TracingExecutormakeIoExecutor(String pName, boolean pDaemon) static <K,V1, V2>
Map<K, V2> static <K,V1, V2>
Map<K, V2> mapValuesLazy(Map<K, V1> pMap, Function<V1, V2> pMapper) static intstatic <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 TracingExecutorstatic intoffsetByCodepoints(String pText, int pCursorPos, int pDirection) private static voidonThreadException(Thread pThread, Throwable pThrowable) 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) static voidprivate 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 pRestore) 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) 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 <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
-
maxAllowedExecutorThreads
public static int maxAllowedExecutorThreads() -
getMaxThreads
private static int getMaxThreads() -
backgroundExecutor
-
ioPool
-
nonCriticalIoPool
-
shutdownExecutors
public static void shutdownExecutors() -
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) -
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 pValue, int pMinValue) -
getPlatform
-
isAarch64
public static boolean isAarch64() -
parseAndValidateUntrustedUri
- Throws:
URISyntaxException
-
lastOf
-
findNextInIterable
-
findPreviousInIterable
-
make
-
make
-
makeEnumMap
-
mapValues
-
mapValuesLazy
-
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
-