Class Util

java.lang.Object
net.minecraft.util.Util

public class Util extends Object
  • Field Details

    • LOGGER

      private 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 TracingExecutor BACKGROUND_EXECUTOR
    • IO_POOL

      private static final TracingExecutor IO_POOL
    • DOWNLOAD_POOL

      private static final TracingExecutor 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> key, Object value)
    • makeDescriptionId

      public static String makeDescriptionId(String prefix, @Nullable Identifier location)
    • getMillis

      public static long getMillis()
    • getNanos

      public static long getNanos()
    • getEpochMillis

      public static long getEpochMillis()
    • getFilenameFormattedDateTime

      public static String getFilenameFormattedDateTime()
    • makeExecutor

      private static TracingExecutor makeExecutor(String name)
    • maxAllowedExecutorThreads

      public static int maxAllowedExecutorThreads()
    • getMaxThreads

      private static int getMaxThreads()
    • backgroundExecutor

      public static TracingExecutor backgroundExecutor()
    • ioPool

      public static TracingExecutor ioPool()
    • nonCriticalIoPool

      public static TracingExecutor nonCriticalIoPool()
    • shutdownExecutors

      public static void shutdownExecutors()
    • makeIoExecutor

      private static TracingExecutor makeIoExecutor(String prefix, boolean daemon)
    • throwAsRuntime

      public static void throwAsRuntime(Throwable throwable)
    • onThreadException

      private static void onThreadException(Thread thread, Throwable throwable)
    • fetchChoiceType

      public static @Nullable Type<?> fetchChoiceType(DSL.TypeReference reference, String name)
    • doFetchChoiceType

      private static @Nullable Type<?> doFetchChoiceType(DSL.TypeReference reference, String name)
    • runNamed

      public static void runNamed(Runnable runnable, String name)
    • getRegisteredName

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

      public static <T> Predicate<T> allOf()
    • allOf

      public static <T> Predicate<T> allOf(Predicate<? super T> condition)
    • allOf

      public static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2)
    • allOf

      public static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3)
    • allOf

      public static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4)
    • allOf

      public static <T> Predicate<T> allOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4, Predicate<? super T> condition5)
    • allOf

      @SafeVarargs public static <T> Predicate<T> allOf(Predicate<? super T>... conditions)
    • allOf

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

      public static <T> Predicate<T> anyOf()
    • anyOf

      public static <T> Predicate<T> anyOf(Predicate<? super T> condition1)
    • anyOf

      public static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2)
    • anyOf

      public static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3)
    • anyOf

      public static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4)
    • anyOf

      public static <T> Predicate<T> anyOf(Predicate<? super T> condition1, Predicate<? super T> condition2, Predicate<? super T> condition3, Predicate<? super T> condition4, Predicate<? super T> condition5)
    • anyOf

      @SafeVarargs public static <T> Predicate<T> anyOf(Predicate<? super T>... conditions)
    • anyOf

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

      public static <T> boolean isSymmetrical(int width, int height, List<T> ingredients)
    • growByHalf

      public static int growByHalf(int currentSize, int minimalNewSize)
    • localizedDateFormatter

      public static DateTimeFormatter localizedDateFormatter(FormatStyle formatStyle)
    • getPlatform

      public static Util.OS getPlatform()
    • isAarch64

      public static boolean isAarch64()
    • parseAndValidateUntrustedUri

      public static URI parseAndValidateUntrustedUri(String uri) throws URISyntaxException
      Throws:
      URISyntaxException
    • findNextInIterable

      public static <T> T findNextInIterable(Iterable<T> collection, @Nullable T current)
    • findPreviousInIterable

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

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

      public static <T> T make(T t, Consumer<? super T> consumer)
    • makeEnumMap

      public static <K extends Enum<K>, V> Map<K,V> makeEnumMap(Class<K> keyType, Function<K,V> function)
    • mapValues

      public static <K,V1,V2> Map<K,V2> mapValues(Map<K,V1> map, Function<? super V1, V2> valueMapper)
    • mapValuesLazy

      public static <K,V1,V2> Map<K,V2> mapValuesLazy(Map<K,V1> map, com.google.common.base.Function<V1,V2> valueMapper)
    • allOfEnumExcept

      public static <T extends Enum<T>> Set<T> allOfEnumExcept(T value)
    • sequence

      public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures)
    • sequenceFailFast

      public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> futures)
    • sequenceFailFastAndCancel

      public static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> futures)
    • fallibleSequence

      private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> futures, Consumer<Throwable> failureHandler)
    • ifElse

      public static <T> Optional<T> ifElse(Optional<T> input, Consumer<T> onTrue, Runnable onFalse)
    • name

      public static <T> Supplier<T> name(Supplier<T> task, Supplier<String> nameGetter)
    • name

      public static Runnable name(Runnable task, Supplier<String> nameGetter)
    • logAndPauseIfInIde

      public static void logAndPauseIfInIde(String message)
    • logAndPauseIfInIde

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

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

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

      private static void doPause(String message)
    • describeError

      public static String describeError(Throwable err)
    • getRandom

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

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

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

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

      private static BooleanSupplier createRenamer(Path from, Path to, CopyOption... options)
    • createDeleter

      private static BooleanSupplier createDeleter(Path target)
    • createFileDeletedCheck

      private static BooleanSupplier createFileDeletedCheck(Path target)
    • createFileCreatedCheck

      private static BooleanSupplier createFileCreatedCheck(Path target)
    • executeInSequence

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

      private static boolean runWithRetries(int numberOfRetries, String description, BooleanSupplier... operations)
    • safeMoveFile

      public static boolean safeMoveFile(Path fromPath, Path toPath, CopyOption... options)
    • safeReplaceFile

      public static void safeReplaceFile(Path targetPath, Path newPath, Path backupPath)
    • safeReplaceOrMoveFile

      public static boolean safeReplaceOrMoveFile(Path targetPath, Path newPath, Path backupPath, boolean noRollback)
    • offsetByCodepoints

      public static int offsetByCodepoints(String input, int pos, int offset)
    • prefix

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

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

      public static DataResult<long[]> fixedSize(LongStream stream, int size)
    • fixedSize

      public static <T> DataResult<List<T>> fixedSize(List<T> list, int size)
    • startTimerHackThread

      public static void startTimerHackThread()
    • copyBetweenDirs

      public static void copyBetweenDirs(Path sourceDir, Path targetDir, Path sourcePath) throws IOException
      Throws:
      IOException
    • sanitizeName

      public static String sanitizeName(String value, CharPredicate isAllowedChar)
    • singleKeyCache

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

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

      public static <T,U,R> BiFunction<T,U,R> memoize(BiFunction<T,U,R> function)
    • 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> completionCheck)
    • createIndexLookup

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

      public static <T> ToIntFunction<T> createIndexIdentityLookup(List<T> values)
    • writeAndReadTypedOrThrow

      public static <A,B> Typed<B> writeAndReadTypedOrThrow(Typed<A> typed, Type<B> newType, UnaryOperator<Dynamic<?>> function)
    • readTypedOrThrow

      public static <T> Typed<T> readTypedOrThrow(Type<T> type, Dynamic<?> dynamic)
    • readTypedOrThrow

      public static <T> Typed<T> readTypedOrThrow(Type<T> type, Dynamic<?> dynamic, boolean acceptPartial)
    • copyAndAdd

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

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

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

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