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
2023-09-23 04:06:03 +02:00
index c0186224fd64d70770a0e16752d17c0870121d8f..30a893f7f63961b752e043b81dda20d946cd63aa 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
2023-09-23 04:06:03 +02:00
@@ -599,7 +599,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
2022-03-04 20:47:30 +01:00
// Paper end
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
2023-03-14 21:55:49 +01:00
BlockPos pos = BlockPos.containing(x, y, z);
2022-03-04 20:47:30 +01:00
- 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
2023-09-24 04:35:16 +02:00
index 261eb8e2a5b161ca566dda46e9c54593e17d6125..a4c6dc704dc5c72261dc069f1cfdb6f4db9542be 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
2023-09-24 04:35:16 +02:00
@@ -1396,7 +1396,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
2023-06-13 01:51:45 +02:00
Preconditions.checkArgument(material != null, "Material cannot be null");
Preconditions.checkArgument(material.isBlock(), "Material.%s must be a block", material);
2022-03-04 20:47:30 +01:00
2023-03-14 21:55:49 +01:00
- FallingBlockEntity entity = FallingBlockEntity.fall(world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM);
2022-04-30 18:27:41 +02:00
+ // 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
2023-09-24 04:35:16 +02:00
@@ -1405,7 +1410,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
2023-06-13 01:51:45 +02:00
Preconditions.checkArgument(location != null, "Location cannot be null");
Preconditions.checkArgument(data != null, "BlockData cannot be null");
2022-03-04 20:47:30 +01:00
2023-03-14 21:55:49 +01:00
- FallingBlockEntity entity = FallingBlockEntity.fall(world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM);
2022-04-30 18:27:41 +02:00
+ // 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