44 lines
2.6 KiB
Diff
44 lines
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
|
Date: Thu, 1 Jul 2021 12:17:44 +0000
|
|
Subject: [PATCH] Don't create new random instance
|
|
|
|
Original code by PatinaMC, licensed under GNU General Public License v3.0
|
|
You can find the original code on https://github.com/PatinaMC/Patina
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index e5af7ef4ada68922a70f593ccec555ecb50627a9..eb634c540842a06bfea196bc9fe4bfbd73012bf1 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -380,7 +380,7 @@ public class ServerPlayer extends Player {
|
|
long l = k * k;
|
|
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
|
|
int j1 = this.getCoprime(i1);
|
|
- int k1 = RandomSource.create().nextInt(i1);
|
|
+ int k1 = worldserver.random.nextInt(i1); // Patina - don't create new random instance
|
|
|
|
for (int l1 = 0; l1 < i1; ++l1) {
|
|
int i2 = (k1 + j1 * l1) % i1;
|
|
@@ -417,7 +417,7 @@ public class ServerPlayer extends Player {
|
|
long l = k * k;
|
|
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
|
|
int j1 = this.getCoprime(i1);
|
|
- int k1 = RandomSource.create().nextInt(i1);
|
|
+ int k1 = world.random.nextInt(i1); // Patina - don't create new random instance
|
|
|
|
for (int l1 = 0; l1 < i1; ++l1) {
|
|
int i2 = (k1 + j1 * l1) % i1;
|
|
diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
index 1ef089dbf83de35d875c00efdf468c397be56978..c345f10cbf7f3451edc604f97cdf959d70639e17 100644
|
|
--- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
@@ -349,7 +349,7 @@ public class QueryThreadGs4 extends GenericThread {
|
|
this.identBytes[2] = bs[5];
|
|
this.identBytes[3] = bs[6];
|
|
this.ident = new String(this.identBytes, StandardCharsets.UTF_8);
|
|
- this.challenge = RandomSource.create().nextInt(16777216);
|
|
+ this.challenge = java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216); // Patina - don't create new random instance
|
|
this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8);
|
|
}
|
|
|