Paper/patches/server/0787-Fix-falling-block-spawn-methods.patch
Nassim Jahnke 4af62f6d1d
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
2d009e64 Update SnakeYAML javadoc link
b4fd213c Switch Player#updateInventory deprecation for internal API annotation

CraftBukkit Changes:
f3b2b2210 SPIGOT-7376: Exception with getBlockData when hasBlockData is false
725545630 SPIGOT-7375: Fix crash breeding certain entities
b9873b0d4 Update Brigadier version with fix
68b320562 SPIGOT-7266: Found typo in CraftBukkit package
98b4d2ff8 SPIGOT-7372, SPIGOT-7373: Signs can't be edited, issues with SignChangeEvent
5f7bd4d78 SPIGOT-7371: Sign does not open edit text on placement
b4cf99d24 SPIGOT-7371: Fix editing signs with API
a2b6c2744 PR-1200: Implement open sign by side
a345bb940 SPIGOT-7368: Downgrade SpecialSource version

Spigot Changes:
723951c3 Rebuild patches
b655c57d Drop old collision API deprecated since 1.9.4
55b0fed4 Rebuild patches
2023-06-08 15:25:35 +02:00

58 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
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
== AT ==
public net.minecraft.world.entity.item.FallingBlockEntity <init>(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
index c738fb984ffd120e5adccdb5828833f180e72e80..5c8e905bbf56dd2af5b30d34371793c3f98801ab 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -599,7 +599,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
// Paper end
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
BlockPos pos = BlockPos.containing(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 5c59bc81676b9d53961058fd324990633086326d..adaa7eaf1a0a39f1d75061c7c1504b61f49ad845 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1387,7 +1387,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, BlockPos.containing(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();
}
@@ -1396,7 +1401,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, BlockPos.containing(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();
}