From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Thu, 16 Feb 2023 17:25:01 +0800 Subject: [PATCH] Use vanilla random config diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 8e64aa46fab22ba507d9e4d1418dc103d53c61f6..15961ba0f3a70e680e1e32d0a502fcfb4cff705a 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -549,7 +549,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 = top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? RandomSource.create() : SHARED_RANDOM; // Paper // Leaves - vanilla plz this.remainingFireTicks = -this.getFireImmuneTicks(); this.fluidHeight = new Object2DoubleArrayMap(2); this.fluidOnEyes = new HashSet(); diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java index a87a34b0c4c8e5d0cf079025c230b1434c919b54..c56dd96ab35dae5331e9cec4bc27cdb78c1741fc 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java @@ -1036,7 +1036,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { BeeGoToHiveGoal() { super(); - this.travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues + this.travellingTicks = top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } 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 f60c4cd0543fd5d50fa7e2c1a9e8381227adb540..8c9c694744951dc11b9f8828f27e4d4a2210a3bc 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 (top.leavesmc.leaves.LeavesConfig.useVanillaRandom) this.random.setSeed(this.getId()); // Paper - we set the random to shared, do not clobber the seed // Leaves - vanilla plz this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java index 5dacb8896d8b78b0c467aa156c497a3eb35df26c..454bcdc843425d67e265e7ec7b56e9dd90dc0030 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -73,7 +73,13 @@ public class ItemEntity extends Entity implements TraceableEntity { // Paper start - Don't use level random in entity constructors (to make them thread-safe) this(EntityType.ITEM, world); this.setPos(x, y, z); - this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); + // Leaves start - vanilla yes, paper no + if (top.leavesmc.leaves.LeavesConfig.useVanillaRandom) { + this.setDeltaMovement(world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D); + } else { + this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); + } + // Leaves end - vanilla yes, paper no this.setItem(stack); // Paper end - Don't use level random in entity constructors // Leaves start - stackable shulker boxes diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java index 0b8f2affbea2b1e166aa574a432a51f30d60386f..defc764756f73b278d3e87216c2cb8c6739736ab 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java @@ -43,7 +43,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { this(EntityType.TNT, world); this.setPos(x, y, z); - double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors + double d3 = (top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? world.random.nextDouble() : this.random.nextDouble()) * 6.2831854820251465D; // Paper - Don't use level random in entity constructors // Leaves - why? this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); this.setFuse(80);