2022-07-22 23:42:13 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Sun, 10 Jul 2022 14:13:22 -0700
|
|
|
|
Subject: [PATCH] Don't use level random in entity constructors
|
|
|
|
|
|
|
|
Paper makes the entity random thread-safe
|
|
|
|
and constructing an entity off the main thread
|
|
|
|
should be supported. Some entities (for whatever
|
|
|
|
reason) use the level's random in some places.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
2022-10-23 18:52:40 +00:00
|
|
|
index 87f8d46cb2032474008811ca11dc7ff1f7859f7e..2e05c953182c27e3571b2c33eceeb379e60b54be 100644
|
2022-07-22 23:42:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
|
|
@@ -1028,7 +1028,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
|
|
|
|
|
|
BeeGoToHiveGoal() {
|
|
|
|
super();
|
|
|
|
- this.travellingTicks = Bee.this.level.random.nextInt(10);
|
|
|
|
+ this.travellingTicks = Bee.this./* level. */random.nextInt(10); // Paper - use entity random
|
|
|
|
this.blacklistedTargets = Lists.newArrayList();
|
|
|
|
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
|
|
|
}
|
|
|
|
@@ -1145,7 +1145,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
|
|
|
|
|
|
BeeGoToKnownFlowerGoal() {
|
|
|
|
super();
|
|
|
|
- this.travellingTicks = Bee.this.level.random.nextInt(10);
|
|
|
|
+ this.travellingTicks = Bee.this./* level. */random.nextInt(10); // Paper - use entity random
|
|
|
|
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2022-07-27 21:50:05 +00:00
|
|
|
index 4c78c04ed031ec2e04642ebe5d79527e848d95f6..fcc5444a1268931a0fd2df1e6bbbc17cfd5a61e0 100644
|
2022-07-22 23:42:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
|
|
@@ -64,7 +64,12 @@ public class ItemEntity extends Entity {
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemEntity(Level world, double x, double y, double z, ItemStack stack) {
|
|
|
|
- this(world, x, y, z, stack, world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D);
|
|
|
|
+ // Paper start - don't use world random in entity constructor
|
|
|
|
+ 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);
|
|
|
|
+ this.setItem(stack);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
2022-10-23 18:52:40 +00:00
|
|
|
index 65f0aa076dbfc4cd72d14ec485d1edf5533d825e..438de71a17d7bfaed8fbb1b4f7aa7f53538603a2 100644
|
2022-07-22 23:42:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
|
|
@@ -35,7 +35,7 @@ public class PrimedTnt extends Entity {
|
|
|
|
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
|
|
|
|
this(EntityType.TNT, world);
|
|
|
|
this.setPos(x, y, z);
|
|
|
|
- double d3 = world.random.nextDouble() * 6.2831854820251465D;
|
|
|
|
+ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - don't use world random in entity constructor
|
|
|
|
|
|
|
|
this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
|
|
|
this.setFuse(80);
|