Files
Purpur/patches/server/0293-Add-PreExplodeEvents.patch
granny d05e78bdb1 drop two config options in favor of PurpurExtras impl
dropped options:
- `mobs.snow_golem.drop-pumpkin-when-sheared`
- `mobs.sheep.jeb-shear-random-color`
2024-01-07 16:58:34 -08:00

35 lines
1.7 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/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 0c08a07d3d1efa35646dbaa5cc887bf9d62cae42..3e69f176eee01b7e093a90f5f3c19009c0a22fa7 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -429,6 +429,23 @@ public class Explosion {
return;
}
// CraftBukkit end
+
+ // Purpur start - add PreExplodeEvents
+ if(this.source != null){
+ Location location = new Location(this.level.getWorld(), this.x, this.y, this.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).callEvent()) {
+ this.wasCanceled = true;
+ return;
+ }
+ }else {
+ Location location = new Location(this.level.getWorld(), this.x, this.y, this.z);
+ if(!new org.purpurmc.purpur.event.PreBlockExplodeEvent(location.getBlock(), this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, this.damageSource.explodedBlockState).callEvent()) {
+ this.wasCanceled = true;
+ return;
+ }
+ }
+ //Purpur end
+
this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z));
Set<BlockPos> set = Sets.newHashSet();
boolean flag = true;