Files
Purpur/patches/server/0263-Add-toggle-for-RNG-manipulation.patch
granny 1f589eb065 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@487109f Readd 0414 use distance map to optimise entity tracker (#9868)
PaperMC/Paper@230682d Add raw iron & raw copper blocks to anti xray defaults (#7622)
PaperMC/Paper@44057da Remove duplicate water-sensitivity damage for unaware mobs (#9908)
PaperMC/Paper@f78d7ce Remove "fix-curing-zombie-villager-discount" exploit option (#9895)
PaperMC/Paper@aa6c4c1 Include packet class name in packet encoding error messages (#9907)
PaperMC/Paper@6592fed Use a server impl for hopper event to track get/setItem calls (#9905)
PaperMC/Paper@bffb08c Deprecate Player#boostElytra (#9899)
PaperMC/Paper@43c3432 Add entity API for getting the combined gene of a Panda (#9891)
PaperMC/Paper@15a0de2 Make Team extend ForwardingAudience (#9852)
PaperMC/Paper@0cdce89 Fix a bunch of stuff with player spawn locations (#9887)
PaperMC/Paper@8a3980c Add API to get the collision shape of a block before it's placed (#9821)
PaperMC/Paper@23860da Add predicate for block when raytracing (#9691)
PaperMC/Paper@75d04e9 Broadcast take item packets with collector as source (#9884)
PaperMC/Paper@2553f30 fix secure profile with proxy online mode (#9700)
PaperMC/Paper@e289acc Add more API to LingeringPotionSplashEvent (#9901)
PaperMC/Paper@8cafc07 Added missing enchantables to material tags (#9888)
2023-11-04 20:29:02 -07:00

51 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
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 bf48e496f4988f45ea8c92eb45544f44753e5738..af06a919673f2e4f41d1cd712caa5b002d12ae71 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -594,7 +594,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
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<? extends Squid> 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 4351793923ea16e3c3fe7ed547c1236cae0e952a..07b8826509d158e60ee6c3c847f7855b7469325f 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;