mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Add PreExplodeEvents
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
this.center = center;
|
||||
this.fire = fire;
|
||||
this.blockInteraction = blockInteraction;
|
||||
@@ -649,7 +_,7 @@
|
||||
@@ -649,10 +_,27 @@
|
||||
|
||||
public void explode() {
|
||||
// CraftBukkit start
|
||||
@@ -18,3 +18,23 @@
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Purpur start - add PreExplodeEvents
|
||||
+ if (this.source != null) {
|
||||
+ Location location = new Location(this.level.getWorld(), this.center.x, this.center.y, this.center.z);
|
||||
+ if(!new org.purpurmc.purpur.event.entity.PreEntityExplodeEvent(this.source.getBukkitEntity(), location, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, org.bukkit.craftbukkit.CraftExplosionResult.toBukkit(getBlockInteraction())).callEvent()) {
|
||||
+ this.wasCanceled = true;
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ Location location = new Location(this.level.getWorld(), this.center.x, this.center.y, this.center.z);
|
||||
+ org.bukkit.block.Block block = location.getBlock();
|
||||
+ org.bukkit.block.BlockState blockState = (this.damageSource.getDirectBlockState() != null) ? this.damageSource.getDirectBlockState() : block.getState();
|
||||
+ if(!new org.purpurmc.purpur.event.PreBlockExplodeEvent(location.getBlock(), this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, blockState, org.bukkit.craftbukkit.CraftExplosionResult.toBukkit(getBlockInteraction())).callEvent()) {
|
||||
+ this.wasCanceled = true;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Add PreExplodeEvents
|
||||
// Paper start - collision optimisations
|
||||
this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
|
||||
this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
||||
|
||||
Reference in New Issue
Block a user