aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0866-Fix-falling-block-spawn-methods.patch
blob: 3829e10ee5893f7d8d8b8804c881d9f69a9fe1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <jahnke.nassim@gmail.com>
Date: Fri, 4 Mar 2022 20:35:19 +0100
Subject: [PATCH] Fix falling block spawn methods

Restores the API behavior from previous versions of the server
- Do not call API events
- Do not replace the existing block in the world

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
index 850131e601047ab1c585a6f8883ac3c0d0e97ba1..99cb7625d50d5da4ce0999e10fb84403958a7ffe 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -549,7 +549,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
             // Paper end
         } else if (FallingBlock.class.isAssignableFrom(clazz)) {
             BlockPos pos = new BlockPos(x, y, z);
-            entity = FallingBlockEntity.fall(world, pos, this.getHandle().getBlockState(pos));
+            entity = new FallingBlockEntity(world, x, y, z, this.getHandle().getBlockState(pos)); // Paper
         } else if (Projectile.class.isAssignableFrom(clazz)) {
             if (Snowball.class.isAssignableFrom(clazz)) {
                 entity = new net.minecraft.world.entity.projectile.Snowball(world, x, y, z);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 85f2dfcd7f4ccba9c6a719c3fb66bbb9d5e9b0a7..99c39f3271d0c3bfb0f854962b79a689cd560b9d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1423,7 +1423,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
         Validate.notNull(material, "Material cannot be null");
         Validate.isTrue(material.isBlock(), "Material must be a block");
 
-        FallingBlockEntity entity = FallingBlockEntity.fall(world, new BlockPos(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM);
+        // Paper start - restore API behavior for spawning falling blocks
+        FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); // Paper
+        entity.time = 1;
+
+        this.world.addFreshEntity(entity, SpawnReason.CUSTOM);
+        // Paper end
         return (FallingBlock) entity.getBukkitEntity();
     }
 
@@ -1432,7 +1437,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
         Validate.notNull(location, "Location cannot be null");
         Validate.notNull(data, "BlockData cannot be null");
 
-        FallingBlockEntity entity = FallingBlockEntity.fall(world, new BlockPos(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM);
+        // Paper start - restore API behavior for spawning falling blocks
+        FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState());
+        entity.time = 1;
+
+        this.world.addFreshEntity(entity, SpawnReason.CUSTOM);
+        // Paper end
         return (FallingBlock) entity.getBukkitEntity();
     }