2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
2022-02-28 16:00:00 +01:00
@@ -46,6 +46,8 @@
2021-03-15 23:00:00 +01:00
import net.minecraft.world.phys.Vec3D;
2022-02-28 16:00:00 +01:00
import org.slf4j.Logger;
2014-11-25 22:32:16 +01:00
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFallingBlock extends Entity {
2022-02-28 16:00:00 +01:00
private static final Logger LOGGER = LogUtils.getLogger();
2022-04-18 03:05:12 +02:00
@@ -80,10 +82,17 @@
}
2022-03-11 06:24:02 +01:00
public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
2022-04-18 03:05:12 +02:00
+ // CraftBukkit start
2022-04-18 03:05:15 +02:00
+ return fall(world, blockposition, iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
2022-04-18 03:05:12 +02:00
+ }
+
2022-04-18 03:05:15 +02:00
+ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
2022-04-18 03:05:12 +02:00
+ // CraftBukkit end
2022-03-11 06:24:02 +01:00
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);
2022-04-18 03:05:12 +02:00
- world.addFreshEntity(entityfallingblock);
2022-04-18 03:05:15 +02:00
+ world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
2022-04-18 03:05:12 +02:00
return entityfallingblock;
}
@@ -166,6 +175,12 @@
2021-11-21 23:00:00 +01:00
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
2019-04-23 04:00:00 +02:00
}
2016-03-22 08:04:02 +01:00
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
2021-06-11 07:00:00 +02:00
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
2021-11-21 23:00:00 +01:00
+ this.discard(); // SPIGOT-6586 called before the event in previous versions
2015-02-26 23:41:06 +01:00
+ return;
+ }
+ // CraftBukkit end
2021-11-21 23:00:00 +01:00
if (this.level.setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
this.discard();
2022-04-18 03:05:12 +02:00
@@ -236,7 +251,7 @@
2021-06-11 07:00:00 +02:00
if (i < 0) {
return false;
} else {
- Predicate predicate;
+ Predicate<Entity> predicate; // CraftBukkit - decompile error
DamageSource damagesource1;
2014-11-25 22:32:16 +01:00
2021-06-11 07:00:00 +02:00
if (this.blockState.getBlock() instanceof Fallable) {
2022-04-18 03:05:12 +02:00
@@ -252,7 +267,9 @@
2021-11-21 23:00:00 +01:00
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
2021-06-11 07:00:00 +02:00
2021-11-21 23:00:00 +01:00
this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
2014-11-25 22:32:16 +01:00
+ CraftEventFactory.entityDamage = this; // CraftBukkit
2021-11-21 23:00:00 +01:00
entity.hurt(damagesource1, f2);
2014-11-25 22:32:16 +01:00
+ CraftEventFactory.entityDamage = null; // CraftBukkit
2021-06-11 07:00:00 +02:00
});
2022-02-28 16:00:00 +01:00
boolean flag = this.blockState.is(TagsBlock.ANVIL);
2014-11-25 22:32:16 +01:00