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 2cac12d2b788b0962b719a83b43dc23177b76ac6..ec6187bc3f445acb86e69161ab1b82248b6e99e0 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -597,7 +597,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 - Share random for entities to make them more random + this.random = world == null || world.purpurConfig.entitySharedRandom ? SHARED_RANDOM : RandomSource.create(); // Paper - Share random for entities to make them more random // 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 fa15e43d19482125e1793e049d1a1380aced906c..38d1eb5680281b2812f2396677ffb959a6e089ce 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 - Share random for entities to make them more random + if (!world.purpurConfig.entitySharedRandom) this.random.setSeed((long)this.getId()); // Paper - Share random for entities to make them more random // 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 6e30be26888422187c145c5e7c81d24804119b90..7d0d298bd68ecba2ba1e2f3336d9aad4567dfde2 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;