Commits

Black Hole authored and md_5 committed 74c0831230b
SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall
No tags

nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch

Modified
1 1 --- a/net/minecraft/world/entity/item/EntityFallingBlock.java
2 2 +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
3 3 @@ -46,6 +46,8 @@
4 4 import net.minecraft.world.phys.Vec3D;
5 5 import org.slf4j.Logger;
6 6
7 7 +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
8 8 +
9 9 public class EntityFallingBlock extends Entity {
10 10
11 11 private static final Logger LOGGER = LogUtils.getLogger();
12 -@@ -166,6 +168,12 @@
12 +@@ -81,6 +83,7 @@
13 +
14 + public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
15 + EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockProperties.WATERLOGGED) ? (IBlockData) iblockdata.setValue(BlockProperties.WATERLOGGED, false) : iblockdata);
16 ++ if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit
17 +
18 + world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
19 + world.addFreshEntity(entityfallingblock);
20 +@@ -166,6 +169,12 @@
13 21 this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
14 22 }
15 23
16 24 + // CraftBukkit start
17 25 + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
18 26 + this.discard(); // SPIGOT-6586 called before the event in previous versions
19 27 + return;
20 28 + }
21 29 + // CraftBukkit end
22 30 if (this.level.setBlock(blockposition, this.blockState, 3)) {
23 31 ((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
24 32 this.discard();
25 -@@ -236,7 +244,7 @@
33 +@@ -236,7 +245,7 @@
26 34 if (i < 0) {
27 35 return false;
28 36 } else {
29 37 - Predicate predicate;
30 38 + Predicate<Entity> predicate; // CraftBukkit - decompile error
31 39 DamageSource damagesource1;
32 40
33 41 if (this.blockState.getBlock() instanceof Fallable) {
34 -@@ -252,7 +260,9 @@
42 +@@ -252,7 +261,9 @@
35 43 float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
36 44
37 45 this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
38 46 + CraftEventFactory.entityDamage = this; // CraftBukkit
39 47 entity.hurt(damagesource1, f2);
40 48 + CraftEventFactory.entityDamage = null; // CraftBukkit
41 49 });
42 50 boolean flag = this.blockState.is(TagsBlock.ANVIL);
43 51

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut