PaperMC/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch
2021-06-20 08:48:15 +10:00

52 lines
2.7 KiB
Diff

--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
@@ -45,6 +45,8 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFallingBlock extends Entity {
private IBlockData blockState;
@@ -114,7 +116,7 @@
if (this.time++ == 0) {
blockposition = this.getChunkCoordinates();
- if (this.level.getType(blockposition).a(block)) {
+ if (this.level.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
this.level.a(blockposition, false);
} else if (!this.level.isClientSide) {
this.die();
@@ -165,6 +167,12 @@
this.blockState = (IBlockData) this.blockState.set(BlockProperties.WATERLOGGED, true);
}
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
+ this.die(); // SPIGOT-6586 called before the event in previous versions
+ return;
+ }
+ // CraftBukkit end
if (this.level.setTypeAndData(blockposition, this.blockState, 3)) {
((WorldServer) this.level).getChunkProvider().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getType(blockposition)));
this.die();
@@ -238,7 +246,7 @@
if (i < 0) {
return false;
} else {
- Predicate predicate;
+ Predicate<Entity> predicate; // CraftBukkit - decompile error
DamageSource damagesource1;
if (this.blockState.getBlock() instanceof Fallable) {
@@ -254,7 +262,9 @@
float f2 = (float) Math.min(MathHelper.d((float) i * this.fallDamagePerDistance), this.fallDamageMax);
this.level.getEntities(this, this.getBoundingBox(), predicate).forEach((entity) -> {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entity.damageEntity(damagesource1, f2);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
});
boolean flag = this.blockState.a((Tag) TagsBlock.ANVIL);