Package net.minecraft

Class Util

java.lang.Object
net.minecraft.Util

public class Util extends Object
  • 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

      private static final String MAX_THREADS_SYSTEM_PROPERTY
      See Also:
    • BACKGROUND_EXECUTOR

      private static final ExecutorService BACKGROUND_EXECUTOR
    • IO_POOL

      private static final ExecutorService IO_POOL
    • DOWNLOAD_POOL

      private static final ExecutorService DOWNLOAD_POOL
    • FILENAME_DATE_TIME_FORMATTER

      private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER
    • LINEAR_LOOKUP_THRESHOLD

      public static final int LINEAR_LOOKUP_THRESHOLD
      See Also:
    • NANOS_PER_MILLI

      public static final long NANOS_PER_MILLI
      See Also:
    • timeSource

      public static TimeSource.NanoTimeSource timeSource
    • TICKER

      public static final com.google.common.base.Ticker TICKER
    • NIL_UUID

      public static final UUID NIL_UUID
    • ZIP_FILE_SYSTEM_PROVIDER

      public static final FileSystemProvider ZIP_FILE_SYSTEM_PROVIDER
    • thePauser

      private static Consumer<String> thePauser
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • toMap

      public static <K, V> Collector<Map.Entry<? extends K,? extends V>,?,Map<K,V>> toMap()
    • toMutableList

      public static <T> Collector<T,?,List<T>> toMutableList()
    • getPropertyName

      public static <T extends Comparable<T>> String getPropertyName(Property<T> pProperty, Object pValue)
    • makeDescriptionId

      public static String makeDescriptionId(String pType, @Nullable ResourceLocation pId)
    • getMillis

      public static long getMillis()
    • getNanos

      public static long getNanos()
    • getEpochMillis

      public static long getEpochMillis()
    • getFilenameFormattedDateTime

      public static String getFilenameFormattedDateTime()
    • makeExecutor

      private static ExecutorService makeExecutor(String pServiceName)
    • getMaxThreads

      private static int getMaxThreads()
    • backgroundExecutor

      public static ExecutorService backgroundExecutor()
    • ioPool

      public static ExecutorService ioPool()
    • nonCriticalIoPool

      public static ExecutorService nonCriticalIoPool()
    • shutdownExecutors

      public static void shutdownExecutors()
    • shutdownExecutor

      private static void shutdownExecutor(ExecutorService pService)
    • makeIoExecutor

      private static ExecutorService makeIoExecutor(String pName, boolean pDaemon)
    • throwAsRuntime

      public static void throwAsRuntime(Throwable pThrowable)
    • onThreadException

      private static void onThreadException(Thread p_137496_, Throwable p_137497_)
    • 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

      public static Runnable wrapThreadWithTaskName(String pName, Runnable pTask)
    • wrapThreadWithTaskName

      public static <V> Supplier<V> wrapThreadWithTaskName(String pName, Supplier<V> pTask)
    • getRegisteredName

      public static <T> String getRegisteredName(Registry<T> pRegistry, T pValue)
    • allOf

      public static <T> Predicate<T> allOf(List<? extends Predicate<T>> pPredicates)
    • anyOf

      public static <T> Predicate<T> anyOf(List<? extends Predicate<T>> pPredicates)
    • isSymmetrical

      public static <T> boolean isSymmetrical(int pWidth, int pHeight, List<T> pList)
    • getPlatform

      public static Util.OS getPlatform()
    • parseAndValidateUntrustedUri

      public static URI parseAndValidateUntrustedUri(String pUri) throws URISyntaxException
      Throws:
      URISyntaxException
    • getVmArguments

      public static Stream<String> getVmArguments()
    • lastOf

      public static <T> T lastOf(List<T> pList)
    • findNextInIterable

      public static <T> T findNextInIterable(Iterable<T> pIterable, @Nullable T pElement)
    • findPreviousInIterable

      public static <T> T findPreviousInIterable(Iterable<T> pIterable, @Nullable T pCurrent)
    • make

      public static <T> T make(Supplier<T> pSupplier)
    • make

      public static <T> T make(T pObject, Consumer<? super T> pConsumer)
    • 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

      public static <T> Optional<T> ifElse(Optional<T> pOpt, Consumer<T> pConsumer, Runnable pOrElse)
    • name

      public static <T> Supplier<T> name(Supplier<T> pItem, Supplier<String> pNameSupplier)
    • name

      public static Runnable name(Runnable pItem, Supplier<String> pNameSupplier)
    • logAndPauseIfInIde

      public static void logAndPauseIfInIde(String pError)
    • logAndPauseIfInIde

      public static void logAndPauseIfInIde(String pMessage, Throwable pError)
    • pauseInIde

      public static <T extends Throwable> T pauseInIde(T pThrowable)
    • setPause

      public static void setPause(Consumer<String> pThePauser)
    • doPause

      private static void doPause(String pMessage)
    • describeError

      public static String describeError(Throwable pThrowable)
    • getRandom

      public static <T> T getRandom(T[] pSelections, RandomSource pRandom)
    • getRandom

      public static int getRandom(int[] pSelections, RandomSource pRandom)
    • getRandom

      public static <T> T getRandom(List<T> pSelections, RandomSource pRandom)
    • getRandomSafe

      public static <T> Optional<T> getRandomSafe(List<T> pSelections, RandomSource pRandom)
    • createRenamer

      private static BooleanSupplier createRenamer(Path pFilePath, Path pNewName)
    • createDeleter

      private static BooleanSupplier createDeleter(Path pFilePath)
    • createFileDeletedCheck

      private static BooleanSupplier createFileDeletedCheck(Path pFilePath)
    • createFileCreatedCheck

      private static BooleanSupplier createFileCreatedCheck(Path pFilePath)
    • executeInSequence

      private static boolean executeInSequence(BooleanSupplier... pSuppliers)
    • runWithRetries

      private static boolean runWithRetries(int pMaxTries, String pActionName, BooleanSupplier... pSuppliers)
    • safeReplaceFile

      public static void safeReplaceFile(Path pCurrent, Path pLatest, Path pOldBackup)
    • safeReplaceOrMoveFile

      public static boolean safeReplaceOrMoveFile(Path pCurrent, Path pLatest, Path pOldBackup, boolean p_212228_)
    • offsetByCodepoints

      public static int offsetByCodepoints(String pText, int pCursorPos, int pDirection)
    • prefix

      public static Consumer<String> prefix(String pPrefix, Consumer<String> pExpectedSize)
    • 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

      public static <T> com.mojang.serialization.DataResult<List<T>> fixedSize(List<T> p_143796_, int p_143797_)
    • startTimerHackThread

      public static void startTimerHackThread()
    • copyBetweenDirs

      public static void copyBetweenDirs(Path pFromDirectory, Path pToDirectory, Path pFilePath) throws IOException
      Throws:
      IOException
    • sanitizeName

      public static String sanitizeName(String pFileName, CharPredicate pCharacterValidator)
    • singleKeyCache

      public static <K, V> SingleKeyCache<K,V> singleKeyCache(Function<K,V> pComputeValue)
    • memoize

      public static <T, R> Function<T,R> memoize(Function<T,R> pMemoFunction)
    • memoize

      public static <T, U, R> BiFunction<T,U,R> memoize(BiFunction<T,U,R> pMemoBiFunction)
    • toShuffledList

      public static <T> List<T> toShuffledList(Stream<T> pStream, RandomSource pRandom)
    • toShuffledList

      public static it.unimi.dsi.fastutil.ints.IntArrayList toShuffledList(IntStream p_214659_, RandomSource p_214660_)
    • shuffledCopy

      public static <T> List<T> shuffledCopy(T[] pArray, RandomSource pRandom)
    • shuffledCopy

      public static <T> List<T> shuffledCopy(it.unimi.dsi.fastutil.objects.ObjectArrayList<T> p_214612_, RandomSource p_214613_)
    • shuffle

      public static <T> void shuffle(List<T> pList, RandomSource pRandom)
    • blockUntilDone

      public static <T> CompletableFuture<T> blockUntilDone(Function<Executor,CompletableFuture<T>> pTask)
    • blockUntilDone

      public static <T> T blockUntilDone(Function<Executor,T> pTask, Predicate<T> pDonePredicate)
    • createIndexLookup

      public static <T> ToIntFunction<T> createIndexLookup(List<T> pList)
    • createIndexIdentityLookup

      public static <T> ToIntFunction<T> createIndexIdentityLookup(List<T> pList)
    • 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

      public static <T> List<T> copyAndAdd(List<T> pList, T pValue)
    • copyAndAdd

      public static <T> List<T> copyAndAdd(T pValue, List<T> pList)
    • copyAndPut

      public static <K, V> Map<K,V> copyAndPut(Map<K,V> pMap, K pKey, V pValue)