From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Encode42 Date: Tue, 12 Jul 2022 14:16:10 -0400 Subject: [PATCH] Add toggle for RNG manipulation Paper patches RNG maniplulation by using a shared (and locked) random source. This comes with a performance gain, but technical players may prefer the ability to manipulate RNG. diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 57376b7c0d281a7950a69348b5aa869e89719232..376acce7e0fd5dedfdf10fa94ced41bc473b7815 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -599,7 +599,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S this.bb = Entity.INITIAL_AABB; this.stuckSpeedMultiplier = Vec3.ZERO; this.nextStep = 1.0F; - this.random = SHARED_RANDOM; // Paper + this.random = world == null || world.purpurConfig.entitySharedRandom ? SHARED_RANDOM : RandomSource.create(); // Paper // Purpur this.remainingFireTicks = -this.getFireImmuneTicks(); this.fluidHeight = new Object2DoubleArrayMap(2); this.fluidOnEyes = new HashSet(); diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java index 88c238e492b1081d1a64a3b6f05d7baa17e5d8c9..dd7f2beabf0edad4143ac2365ac04a22edf1f75e 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Squid.java +++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java @@ -44,7 +44,7 @@ public class Squid extends WaterAnimal { public Squid(EntityType type, Level world) { super(type, world); - //this.random.setSeed((long)this.getId()); // Paper - we set the random to shared, do not clobber the seed + if (!world.purpurConfig.entitySharedRandom) this.random.setSeed((long) this.getId()); // Paper - we set the random to shared, do not clobber the seed // Purpur this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 453d4b1c1d6b9a1521ce7a2e179dfcec0bf52a3c..c4174f1f3e6993a38cdb3cbd57553af9807a327b 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -204,9 +204,11 @@ public class PurpurWorldConfig { public int entityLifeSpan = 0; public float entityLeftHandedChance = 0.05f; + public boolean entitySharedRandom = true; private void entitySettings() { entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan); entityLeftHandedChance = (float) getDouble("gameplay-mechanics.entity-left-handed-chance", entityLeftHandedChance); + entitySharedRandom = getBoolean("settings.entity.shared-random", entitySharedRandom); } public boolean infinityWorksWithoutArrows = false;