--- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java
@@ -79,8 +79,24 @@
     private static final int DEFAULT_MAX_THREADS = 255;
     private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads";
     private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1);
-    private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap");
-    private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
+    private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap", -2); // Paper - add -2 priority
+    private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority
+    // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
+    public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
+
+        private final AtomicInteger count = new AtomicInteger();
+
+        @Override
+        public Thread newThread(Runnable run) {
+            Thread ret = new Thread(run);
+            ret.setName("Profile Lookup Executor #" + this.count.getAndIncrement());
+            ret.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> {
+                LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable);
+            });
+            return ret;
+        }
+    });
+    // Paper end - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
     private static final ExecutorService IO_POOL = makeIoExecutor();
     private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT);
     public static TimeSource.NanoTimeSource timeSource = System::nanoTime;
@@ -96,6 +112,7 @@
     }).findFirst().orElseThrow(() -> {
         return new IllegalStateException("No jar file system provider found");
     });
+    public static final double COLLISION_EPSILON = 1.0E-7; // Paper
     private static Consumer<String> thePauser = (message) -> {
     };
 
@@ -116,7 +133,7 @@
     }
 
     public static long getNanos() {
-        return timeSource.getAsLong();
+        return System.nanoTime(); // Paper
     }
 
     public static long getEpochMillis() {
@@ -127,14 +144,30 @@
         return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now());
     }
 
-    private static ExecutorService makeExecutor(String name) {
-        int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, getMaxThreads());
+    private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
+        // Paper start - use simpler thread pool that allows 1 thread
+        // Paper start - also try to avoid suffocating the system with the worldgen workers
+        int cpus = Runtime.getRuntime().availableProcessors() / 2;
+        int i;
+        if (cpus <= 4) {
+            i = cpus <= 2 ? 1 : 2;
+        } else if (cpus <= 8) {
+            // [5, 8]
+            i = Math.max(3, cpus - 2);
+        } else {
+            i = cpus * 2 / 3;
+        }
+        i = Math.min(8, i);
+        // Paper end - also try to avoid suffocating the system with the worldgen workers
+        i = Integer.getInteger("Paper.WorkerThreadCount", i);
         ExecutorService executorService;
+
         if (i <= 0) {
             executorService = MoreExecutors.newDirectExecutorService();
         } else {
-            executorService = new ForkJoinPool(i, (forkJoinPool) -> {
-                ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(forkJoinPool) {
+            executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
+        }
+        /*
                     @Override
                     protected void onTermination(Throwable throwable) {
                         if (throwable != null) {
@@ -150,6 +183,7 @@
                 return forkJoinWorkerThread;
             }, Util::onThreadException, true);
         }
+        }*/ // Paper end
 
         return executorService;
     }
@@ -376,7 +410,7 @@
     }
 
     public static <K> Hash.Strategy<K> identityStrategy() {
-        return Util.IdentityStrategy.INSTANCE;
+        return (Hash.Strategy<K>) Util.IdentityStrategy.INSTANCE; // Paper - decompile fix
     }
 
     public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
@@ -855,17 +889,7 @@
         }
 
         public void openUrl(URL url) {
-            try {
-                Process process = AccessController.doPrivileged((PrivilegedExceptionAction<Process>)(() -> {
-                    return Runtime.getRuntime().exec(this.getOpenUrlArguments(url));
-                }));
-                process.getInputStream().close();
-                process.getErrorStream().close();
-                process.getOutputStream().close();
-            } catch (IOException | PrivilegedActionException var3) {
-                Util.LOGGER.error("Couldn't open url '{}'", url, var3);
-            }
-
+            throw new IllegalStateException("This method is not useful on dedicated servers."); // Paper
         }
 
         public void openUri(URI uri) {
