mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 14:06:17 +01:00
71c84c8132
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent 258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD CraftBukkit Changes: 98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent 5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class 76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor Spigot Changes: e9ec5485 Rebuild patches f1b62e0c Rebuild patches
42 lines
2.5 KiB
Diff
42 lines
2.5 KiB
Diff
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
|
|
index 78acc580d66917e52d89632e3f0b7c1e979714d4..d0dac3dc89b9bb645a1d8498802fb8c6bff6a78e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -67,7 +67,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 16f9d38687c0fdda18468b5bfb61b09b98254968..e712bd07ea2946167782473a536e0c72fab4bccd 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -44,7 +44,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);
|