2022-07-23 01:42:13 +02: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/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2024-10-30 14:06:43 +01:00
|
|
|
index 586257fe5c9f5cddd0ed164254f46777c6e71d66..d555fd0b200c012f30ed0c0ec09a37b25a737b76 100644
|
2022-07-23 01:42:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2024-06-14 03:30:23 +02:00
|
|
|
@@ -72,7 +72,12 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2022-07-23 01:42:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2024-01-18 15:56:25 +01:00
|
|
|
+ // Paper start - Don't use level random in entity constructors (to make them thread-safe)
|
2022-07-23 01:42:13 +02:00
|
|
|
+ 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);
|
2024-01-18 15:56:25 +01:00
|
|
|
+ // Paper end - Don't use level random in entity constructors
|
2022-07-23 01:42:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2024-10-25 13:52:04 +02:00
|
|
|
index 45c224198135e48f94dc72312c805bf451bf7b0e..de87483600e55d88176fe25db621bbd3e464729f 100644
|
2022-07-23 01:42:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
2024-10-23 23:12:09 +02:00
|
|
|
@@ -68,7 +68,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
2022-07-23 01:42:13 +02:00
|
|
|
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;
|
2024-01-18 15:56:25 +01:00
|
|
|
+ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors
|
2022-07-23 01:42:13 +02:00
|
|
|
|
|
|
|
this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
|
|
|
this.setFuse(80);
|