2022-03-04 20:47:30 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2022-08-01 16:01:20 +02:00
From: Nassim Jahnke <nassim@njahnke.dev>
2022-03-04 20:47:30 +01:00
Date: Fri, 4 Mar 2022 20:35:19 +0100
Subject: [PATCH] Fix falling block spawn methods
2022-04-30 18:27:41 +02:00
Restores the API behavior from previous versions of the server
- Do not call API events
- Do not replace the existing block in the world
2022-03-04 20:47:30 +01:00
2022-11-20 00:53:20 +01:00
== AT ==
public net.minecraft.world.entity.item.FallingBlockEntity <init>(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V
2022-03-04 20:47:30 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
2022-12-07 22:35:34 +01:00
index bb486249d409743b0fc9891ac5ae76a38034800b..e365081bf532488f2b41b22deb2fb2346d4f2322 100644
2022-03-04 20:47:30 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
2022-12-07 22:35:34 +01:00
@@ -570,7 +570,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
2022-03-04 20:47:30 +01:00
// 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
2022-12-08 20:06:54 +01:00
index a71886568581f39f91e3b06eada560aa60cf0c93..56f1952a4595df2b2647dc9e6632cee44e8299ce 100644
2022-03-04 20:47:30 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2022-12-07 22:35:34 +01:00
@@ -1394,7 +1394,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
2022-03-04 20:47:30 +01:00
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(material.isBlock(), "Material must be a block");
2022-04-30 18:27:41 +02:00
- 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
2022-03-04 20:47:30 +01:00
+ FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); // Paper
2022-04-30 18:27:41 +02:00
+ entity.time = 1;
+
+ this.world.addFreshEntity(entity, SpawnReason.CUSTOM);
+ // Paper end
return (FallingBlock) entity.getBukkitEntity();
}
2022-03-04 20:47:30 +01:00
2022-12-07 22:35:34 +01:00
@@ -1403,7 +1408,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
2022-03-04 20:47:30 +01:00
Validate.notNull(location, "Location cannot be null");
2022-04-30 18:27:41 +02:00
Validate.notNull(data, "BlockData cannot be null");
2022-03-04 20:47:30 +01:00
2022-04-30 18:27:41 +02:00
- 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();
}
2022-03-04 20:47:30 +01:00