177 lines
12 KiB
Diff
177 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Sat, 25 Mar 2023 20:02:59 +0900
|
|
Subject: [PATCH] Reduce create random instance
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
index f5bc3497831877e0c2b7dc1cbd8abe3a67d7695b..d157758282cc79d58134c056c52a43a24d443153 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
@@ -65,7 +65,7 @@ public class SpreadPlayersCommand {
|
|
if (maxY < j) {
|
|
throw SpreadPlayersCommand.ERROR_INVALID_MAX_HEIGHT.create(maxY, j);
|
|
} else {
|
|
- RandomSource randomsource = RandomSource.create();
|
|
+ RandomSource randomsource = worldserver.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? worldserver.getRandom() : RandomSource.create(); // Plazma
|
|
double d0 = (double) (center.x - maxRange);
|
|
double d1 = (double) (center.y - maxRange);
|
|
double d2 = (double) (center.x + maxRange);
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index f39b3f1b5b37d1939766952a985684279cb2bf2d..69d22bc9f0087dc419b840c6626746e12f621012 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -447,7 +447,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.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? worldserver.getRandom() : RandomSource.create()).nextInt(i1); // Plazma
|
|
|
|
for (int l1 = 0; l1 < i1; ++l1) {
|
|
int i2 = (k1 + j1 * l1) % i1;
|
|
@@ -484,7 +484,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.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()).nextInt(i1); // Plazma
|
|
|
|
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..dc111e0d1e7303c56cd12fa83be3ff85ab989e1b 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 = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216) : RandomSource.create().nextInt(16777216); // Plazma
|
|
this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
index b8c238287e0639b578170c6fec0d4db5a1a59fe7..9e5eab45d589db16b4f1ec563e40dc3890581bf4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
@@ -86,7 +86,7 @@ public class FishingHook extends Projectile {
|
|
|
|
private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckOfTheSeaLevel, int lureLevel) {
|
|
super(type, world);
|
|
- this.syncronizedRandom = RandomSource.create();
|
|
+ this.syncronizedRandom = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma
|
|
this.openWater = true;
|
|
this.currentState = FishingHook.FishHookState.FLYING;
|
|
this.noCulling = true;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
index f7399737548483905f3b5c08a03876b0da54b714..7ff8e19fcee67a33bbc8603f8c089a5b76ed23b6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -110,7 +110,7 @@ public class Raid {
|
|
|
|
public Raid(int id, ServerLevel world, BlockPos pos) {
|
|
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
|
|
- this.random = RandomSource.create();
|
|
+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma
|
|
this.waveSpawnPos = Optional.empty();
|
|
this.id = id;
|
|
this.level = world;
|
|
@@ -124,7 +124,7 @@ public class Raid {
|
|
|
|
public Raid(ServerLevel world, CompoundTag nbt) {
|
|
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
|
|
- this.random = RandomSource.create();
|
|
+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma
|
|
this.waveSpawnPos = Optional.empty();
|
|
this.level = world;
|
|
this.id = nbt.getInt("Id");
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index 4932374ab9a3d8582fb0ef024d817ad896dd23c4..fd9be520b838346555dee2dc13f54dcf0fe0e9d8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -81,7 +81,7 @@ public class Explosion {
|
|
}
|
|
|
|
public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
|
|
- this.random = RandomSource.create();
|
|
+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma
|
|
this.toBlow = new ObjectArrayList();
|
|
this.hitPlayers = Maps.newHashMap();
|
|
this.level = world;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 08f9af1d7aebba943096b59b6452818a1aafc94c..1d2c3147abfa09233976f4cc1cc417a9dab9ed44 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -124,7 +124,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
public final Thread thread;
|
|
private final boolean isDebug;
|
|
private int skyDarken;
|
|
- protected int randValue = RandomSource.create().nextInt();
|
|
+ protected int randValue = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? java.util.concurrent.ThreadLocalRandom.current().nextInt() : RandomSource.create().nextInt(); // Plazma
|
|
protected final int addend = 1013904223;
|
|
protected float oRainLevel;
|
|
public float rainLevel;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
index 7291e4056b8e46ab59b71818388ac55fbb12993f..5e5efeec92f70060b0d409252ceff65691155367 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
@@ -368,7 +368,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
|
|
}
|
|
|
|
private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) {
|
|
- Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), RandomSource.create(), pos);
|
|
+ Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()), pos); // Plazma
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
index 5b333bef255d7ef61c99510837536920c6fb6e8c..6331c068aefcdf07d2c880eef8df07add277f856 100644
|
|
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
@@ -472,7 +472,7 @@ public class EndDragonFight {
|
|
this.level.registryAccess().registry(Registries.CONFIGURED_FEATURE).flatMap((iregistry) -> {
|
|
return iregistry.getHolder(EndFeatures.END_GATEWAY_DELAYED);
|
|
}).ifPresent((holder_c) -> {
|
|
- ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos);
|
|
+ ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), pos);
|
|
});
|
|
}
|
|
|
|
@@ -490,7 +490,7 @@ public class EndDragonFight {
|
|
this.portalLocation = this.portalLocation.atY(this.level.getMinBuildHeight() + 1);
|
|
}
|
|
// Paper end
|
|
- worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation);
|
|
+ worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), this.portalLocation);
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
index 61477d98f10ce7d0ec29d51de8c7a3b42026dd2d..3e0d0d21dc73b2a5d033d8bcd43b08866e0d6923 100644
|
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
@@ -40,7 +40,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
public Misc misc;
|
|
public class Misc extends ConfigurationPart {
|
|
|
|
-
|
|
+ public boolean reduceCreateRandomInstance = DO_OPTIMIZE;
|
|
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
|
index 843cf772c18d2e9386bf5a7b1731a86c349d6b98..14987ceec693397602b5c8e1fe460a6fc212a0ee 100644
|
|
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
|
@@ -87,7 +87,7 @@ public class LevelConfigurations extends ConfigurationPart {
|
|
public Misc misc;
|
|
public class Misc extends ConfigurationPart {
|
|
|
|
-
|
|
+ public boolean reduceCreateRandomInstance = DO_OPTIMIZE;
|
|
|
|
}
|
|
}
|