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> property, Object value)
    • makeDescriptionId

      public static String makeDescriptionId(String type, @Nullable ResourceLocation id)
    • 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 serviceName)
    • 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 service)
    • makeIoExecutor

      private static ExecutorService makeIoExecutor(String name, boolean daemon)
    • throwAsRuntime

      public static void throwAsRuntime(Throwable throwable)
    • onThreadException

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

      public static Runnable wrapThreadWithTaskName(String name, Runnable task)
    • wrapThreadWithTaskName

      public static <V> Supplier<V> wrapThreadWithTaskName(String name, Supplier<V> task)
    • getRegisteredName

      public static <T> String getRegisteredName(Registry<T> registry, T value)
    • allOf

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

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

      public static <T> boolean isSymmetrical(int width, int height, List<T> list)
    • getPlatform

      public static Util.OS getPlatform()
    • parseAndValidateUntrustedUri

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

      public static Stream<String> getVmArguments()
    • lastOf

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

      public static <T> T findNextInIterable(Iterable<T> iterable, @Nullable T element)
    • findPreviousInIterable

      public static <T> T findPreviousInIterable(Iterable<T> iterable, @Nullable T current)
    • make

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

      public static <T> T make(T object, Consumer<? super T> consumer)
    • sequence

      public 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,
    • 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

      public static <T> Optional<T> ifElse(Optional<T> opt, Consumer<T> consumer, Runnable orElse)
    • name

      public static <T> Supplier<T> name(Supplier<T> item, Supplier<String> nameSupplier)
    • name

      public static Runnable name(Runnable item, Supplier<String> nameSupplier)
    • logAndPauseIfInIde

      public static void logAndPauseIfInIde(String error)
    • logAndPauseIfInIde

      public static void logAndPauseIfInIde(String message, Throwable error)
    • pauseInIde

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

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

      private static void doPause(String message)
    • describeError

      public static String describeError(Throwable throwable)
    • getRandom

      public static <T> T getRandom(T[] selections, RandomSource random)
    • getRandom

      public static int getRandom(int[] selections, RandomSource random)
    • getRandom

      public static <T> T getRandom(List<T> selections, RandomSource random)
    • getRandomSafe

      public static <T> Optional<T> getRandomSafe(List<T> selections, RandomSource random)
    • createRenamer

      private static BooleanSupplier createRenamer(Path filePath, Path newName)
    • createDeleter

      private static BooleanSupplier createDeleter(Path filePath)
    • createFileDeletedCheck

      private static BooleanSupplier createFileDeletedCheck(Path filePath)
    • createFileCreatedCheck

      private static BooleanSupplier createFileCreatedCheck(Path filePath)
    • executeInSequence

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

      private static boolean runWithRetries(int maxTries, String actionName, BooleanSupplier... suppliers)
    • safeReplaceFile

      public static void safeReplaceFile(Path current, Path latest, Path oldBackup)
    • safeReplaceOrMoveFile

      public static boolean safeReplaceOrMoveFile(Path current, Path latest, Path oldBackup, boolean p_212228_)
    • offsetByCodepoints

      public static int offsetByCodepoints(String text, int cursorPos, int direction)
    • prefix

      public static Consumer<String> prefix(String prefix, Consumer<String> expectedSize)
    • fixedSize

      public static com.mojang.serialization.DataResult<int[]> fixedSize(IntStream stream, int size)
    • fixedSize

      public static com.mojang.serialization.DataResult<long[]> fixedSize(LongStream stream, int expectedSize)
    • fixedSize

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

      public static void startTimerHackThread()
    • copyBetweenDirs

      public static void copyBetweenDirs(Path fromDirectory, Path toDirectory, Path filePath) throws IOException
      Throws:
      IOException
    • sanitizeName

      public static String sanitizeName(String fileName, CharPredicate characterValidator)
    • singleKeyCache

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

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

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

      public static <T> List<T> toShuffledList(Stream<T> stream, RandomSource random)
    • toShuffledList

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

      public static <T> List<T> shuffledCopy(T[] array, RandomSource random)
    • shuffledCopy

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

      public static <T> void shuffle(List<T> list, RandomSource random)
    • blockUntilDone

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

      public static <T> T blockUntilDone(Function<Executor,T> task, Predicate<T> donePredicate)
    • createIndexLookup

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

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

      public static <T> List<T> copyAndAdd(List<T> list, T value)
    • copyAndAdd

      public static <T> List<T> copyAndAdd(T value, List<T> list)
    • copyAndPut

      public static <K, V> Map<K,V> copyAndPut(Map<K,V> map, K key, V value)