aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-17 10:24:53 -0700
committerSpottedleaf <[email protected]>2024-07-17 10:28:32 -0700
commit00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch)
tree82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch
parent967f98aa81da851740aeb429778e46159fd188df (diff)
downloadPaper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz
Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch')
-rw-r--r--patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch b/patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch
new file mode 100644
index 0000000000..cb41bd38c5
--- /dev/null
+++ b/patches/server/0727-Don-t-use-level-random-in-entity-constructors.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+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/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+index 5448a0f54080ac02bc4ce8ad5645173b67841e1a..30056568a9701fcb664682f329175d3bfee79b60 100644
+--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
++++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+@@ -72,7 +72,12 @@ public class ItemEntity extends Entity implements TraceableEntity {
+ }
+
+ 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 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);
++ this.setItem(stack);
++ // Paper end - Don't use level random in entity constructors
+ }
+
+ 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
+index 47f2a480f6a4b15e55cedbfa8a58459d33516a97..42bd2d9a1528b6210e4dfb56233062fd97c9743b 100644
+--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
++++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+@@ -62,7 +62,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 = world.random.nextDouble() * 6.2831854820251465D;
++ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors
+
+ this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
+ this.setFuse(80);