mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
1a135e792f
By: BlackHole <black-hole@live.com>
51 lines
3 KiB
Diff
51 lines
3 KiB
Diff
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
|
|
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
|
|
@@ -46,6 +46,8 @@
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import org.slf4j.Logger;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
+
|
|
public class EntityFallingBlock extends Entity {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -81,6 +83,7 @@
|
|
|
|
public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
|
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);
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit
|
|
|
|
world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
|
|
world.addFreshEntity(entityfallingblock);
|
|
@@ -166,6 +169,12 @@
|
|
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
|
|
+ this.discard(); // SPIGOT-6586 called before the event in previous versions
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
if (this.level.setBlock(blockposition, this.blockState, 3)) {
|
|
((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
|
|
this.discard();
|
|
@@ -236,7 +245,7 @@
|
|
if (i < 0) {
|
|
return false;
|
|
} else {
|
|
- Predicate predicate;
|
|
+ Predicate<Entity> predicate; // CraftBukkit - decompile error
|
|
DamageSource damagesource1;
|
|
|
|
if (this.blockState.getBlock() instanceof Fallable) {
|
|
@@ -252,7 +261,9 @@
|
|
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
|
|
|
|
this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
|
|
+ CraftEventFactory.entityDamage = this; // CraftBukkit
|
|
entity.hurt(damagesource1, f2);
|
|
+ CraftEventFactory.entityDamage = null; // CraftBukkit
|
|
});
|
|
boolean flag = this.blockState.is(TagsBlock.ANVIL);
|
|
|