mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
35 lines
2.2 KiB
Diff
35 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
|
Date: Mon, 26 Dec 2022 23:42:37 +0100
|
|
Subject: [PATCH] Add PreExplodeEvents
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
index 05fdb02b6f73c24f6985755effecf92c0b365cf0..4c7e4683c53afb0800b7f17c5964ba8ff31848d1 100644
|
|
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
@@ -670,6 +670,23 @@ public class ServerExplosion implements Explosion {
|
|
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
|
|
// Paper start - collision optimisations
|
|
this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
|
|
this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|