mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-20 14:08:57 +01:00
SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall
By: BlackHole <black-hole@live.com>
This commit is contained in:
parent
ad484e5f73
commit
1a135e792f
1 changed files with 11 additions and 3 deletions
|
@ -9,7 +9,15 @@
|
||||||
public class EntityFallingBlock extends Entity {
|
public class EntityFallingBlock extends Entity {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
@@ -166,6 +168,12 @@
|
@@ -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);
|
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +30,7 @@
|
||||||
if (this.level.setBlock(blockposition, this.blockState, 3)) {
|
if (this.level.setBlock(blockposition, this.blockState, 3)) {
|
||||||
((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
|
((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
|
||||||
this.discard();
|
this.discard();
|
||||||
@@ -236,7 +244,7 @@
|
@@ -236,7 +245,7 @@
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,7 +39,7 @@
|
||||||
DamageSource damagesource1;
|
DamageSource damagesource1;
|
||||||
|
|
||||||
if (this.blockState.getBlock() instanceof Fallable) {
|
if (this.blockState.getBlock() instanceof Fallable) {
|
||||||
@@ -252,7 +260,9 @@
|
@@ -252,7 +261,9 @@
|
||||||
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
|
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
|
||||||
|
|
||||||
this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
|
this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue