mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
--------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> Co-authored-by: Fortern <blueten.ki@gmail.com> Co-authored-by: MC_XiaoHei <xor7xiaohei@gmail.com> Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com> Co-authored-by: MC_XiaoHei <xiaohei.xor7@outlook.com>
87 lines
6.1 KiB
Diff
87 lines
6.1 KiB
Diff
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] Configurable vanilla random
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 632a1cb5eee13d7287915433e9e646ec4a3a1a09..0e5c4aa2b8856c7b88ff90031715a55c4a1bf89e 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -261,7 +261,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
public double yOld;
|
|
public double zOld;
|
|
public boolean noPhysics;
|
|
- public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
|
|
+ public final RandomSource random = org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? RandomSource.create() : SHARED_RANDOM; // Paper - Share random for entities to make them more random // Leaves - but mojang use it, optimize? no!
|
|
public int tickCount;
|
|
private int remainingFireTicks = -this.getFireImmuneTicks();
|
|
public boolean wasTouchingWater;
|
|
diff --git a/net/minecraft/world/entity/animal/Bee.java b/net/minecraft/world/entity/animal/Bee.java
|
|
index edca2fa21e600fa1e7ef91af673adaae7d4c86c4..9007128a4619ab6130424786ae81c23ae38e55e9 100644
|
|
--- a/net/minecraft/world/entity/animal/Bee.java
|
|
+++ b/net/minecraft/world/entity/animal/Bee.java
|
|
@@ -801,7 +801,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
@VisibleForDebug
|
|
public class BeeGoToHiveGoal extends Bee.BaseBeeGoal {
|
|
public static final int MAX_TRAVELLING_TICKS = 2400;
|
|
- int travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
|
+ int travellingTicks = org.leavesmc.leaves.LeavesConfig.modify.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
|
|
private static final int MAX_BLACKLISTED_TARGETS = 3;
|
|
final List<BlockPos> blacklistedTargets = Lists.newArrayList();
|
|
@Nullable
|
|
@@ -917,7 +917,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
|
|
public class BeeGoToKnownFlowerGoal extends Bee.BaseBeeGoal {
|
|
private static final int MAX_TRAVELLING_TICKS = 2400;
|
|
- int travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
|
+ int travellingTicks = org.leavesmc.leaves.LeavesConfig.modify.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
|
|
|
|
BeeGoToKnownFlowerGoal() {
|
|
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
|
diff --git a/net/minecraft/world/entity/animal/Squid.java b/net/minecraft/world/entity/animal/Squid.java
|
|
index 58e1bc90cbc32669fa6c66d214119f0c459ff38c..ea41360af5e5d49c96ca24e9c36bd52cfdd7d40c 100644
|
|
--- a/net/minecraft/world/entity/animal/Squid.java
|
|
+++ b/net/minecraft/world/entity/animal/Squid.java
|
|
@@ -46,7 +46,7 @@ public class Squid extends AgeableWaterCreature {
|
|
|
|
public Squid(EntityType<? extends Squid> entityType, Level level) {
|
|
super(entityType, level);
|
|
- //this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom) this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random // Leaves - vanilla plz
|
|
this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
|
index b0e60d1d2a44bb35c87c35e82a172a38406b6c54..0cb2d5cd37171cd6e01748ed3d2ce99da1a15e3f 100644
|
|
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -70,7 +70,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, level);
|
|
this.setPos(posX, posY, posZ);
|
|
- this.setDeltaMovement(this.random.nextDouble() * 0.2 - 0.1, 0.2, this.random.nextDouble() * 0.2 - 0.1);
|
|
+ // Leaves start - vanilla yes, safe no
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom) {
|
|
+ this.setDeltaMovement(level.random.nextDouble() * 0.2 - 0.1, 0.2, level.random.nextDouble() * 0.2 - 0.1);
|
|
+ } else {
|
|
+ this.setDeltaMovement(this.random.nextDouble() * 0.2 - 0.1, 0.2, this.random.nextDouble() * 0.2 - 0.1);
|
|
+ }
|
|
+ // Leaves end - vanilla yes, safe no
|
|
this.setItem(itemStack);
|
|
// Paper end - Don't use level random in entity constructors
|
|
}
|
|
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index 0f28b1befd42a85ffa5462e86d5cde142f9d1196..8cbcae0ef84b160d08b677972dc70cabfb5b6c5f 100644
|
|
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -69,7 +69,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
|
|
this(EntityType.TNT, level);
|
|
this.setPos(x, y, z);
|
|
- double d = this.random.nextDouble() * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors
|
|
+ double d = (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? level.random.nextDouble() : this.random.nextDouble()) * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors // Leaves - why?
|
|
this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02);
|
|
this.setFuse(80);
|
|
this.xo = x;
|