2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
2023-09-22 02:40:00 +10:00
@@ -49,6 +49,10 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.phys.Vec3D;
2022-03-01 02:00:00 +11:00
import org.slf4j.Logger;
2014-11-26 08:32:16 +11:00
2023-06-24 17:15:05 +10:00
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
2014-11-26 08:32:16 +11:00
+
public class EntityFallingBlock extends Entity {
2022-03-01 02:00:00 +11:00
private static final Logger LOGGER = LogUtils.getLogger();
2023-06-24 17:15:05 +10:00
@@ -83,10 +87,17 @@
2022-04-18 11:05:12 +10:00
}
2022-03-11 16:24:02 +11:00
public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
2022-04-18 11:05:12 +10:00
+ // CraftBukkit start
2022-04-18 11:05:15 +10:00
+ return fall(world, blockposition, iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
2022-04-18 11:05:12 +10:00
+ }
+
2022-04-18 11:05:15 +10:00
+ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
2022-04-18 11:05:12 +10:00
+ // CraftBukkit end
2022-03-11 16:24:02 +11: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);
2023-06-24 17:15:05 +10:00
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
2022-03-11 16:24:02 +11:00
world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
2022-04-18 11:05:12 +10:00
- world.addFreshEntity(entityfallingblock);
2022-04-18 11:05:15 +10:00
+ world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
2022-04-18 11:05:12 +10:00
return entityfallingblock;
}
2023-06-24 17:15:05 +10:00
@@ -169,6 +180,12 @@
2021-11-22 09:00:00 +11:00
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
2019-04-23 12:00:00 +10:00
}
2016-03-22 18:04:02 +11:00
2019-04-23 12:00:00 +10:00
+ // CraftBukkit start
2023-06-24 17:15:05 +10:00
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) {
2021-11-22 09:00:00 +11:00
+ this.discard(); // SPIGOT-6586 called before the event in previous versions
2015-02-26 22:41:06 +00:00
+ return;
+ }
+ // CraftBukkit end
2023-06-08 01:30:00 +10:00
if (this.level().setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition)));
2021-11-22 09:00:00 +11:00
this.discard();
2023-06-24 17:15:05 +10:00
@@ -255,7 +272,9 @@
2021-11-22 09:00:00 +11:00
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
2021-06-11 15:00:00 +10:00
2023-06-08 01:30:00 +10:00
this.level().getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
2014-11-26 08:32:16 +11:00
+ CraftEventFactory.entityDamage = this; // CraftBukkit
2023-06-08 01:30:00 +10:00
entity.hurt(damagesource2, f2);
2014-11-26 08:32:16 +11:00
+ CraftEventFactory.entityDamage = null; // CraftBukkit
2021-06-11 15:00:00 +10:00
});
2022-03-01 02:00:00 +11:00
boolean flag = this.blockState.is(TagsBlock.ANVIL);
2014-11-26 08:32:16 +11:00