make it compile

This commit is contained in:
granny
2024-04-29 19:21:50 -07:00
parent 7a08bb73c9
commit 69403e54d0
2 changed files with 9 additions and 8 deletions

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] Add PreExplodeEvents
diff --git a/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java diff --git a/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..32602b398ede24a35ed8a996faa2b23455615a7b index 0000000000000000000000000000000000000000..8ea97ddceedb7c719e8a50a0dd8f3f0919ca1647
--- /dev/null --- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java +++ b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
@@ -0,0 +1,54 @@ @@ -0,0 +1,53 @@
+package org.purpurmc.purpur.event; +package org.purpurmc.purpur.event;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@@ -18,7 +18,6 @@ index 0000000000000000000000000000000000000000..32602b398ede24a35ed8a996faa2b234
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExplodeEvent; +import org.bukkit.event.block.BlockExplodeEvent;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import java.util.Collections; +import java.util.Collections;
+ +
+/** +/**
@@ -29,8 +28,8 @@ index 0000000000000000000000000000000000000000..32602b398ede24a35ed8a996faa2b234
+ private boolean cancelled; + private boolean cancelled;
+ private final float yield; + private final float yield;
+ +
+ public PreBlockExplodeEvent(@NotNull final Block what, final float yield, @Nullable BlockState explodedBlockState) { + public PreBlockExplodeEvent(@NotNull final Block what, final float yield, @NotNull BlockState explodedBlockState) {
+ super(what, Collections.emptyList(), yield, explodedBlockState); + super(what, explodedBlockState, Collections.emptyList(), yield);
+ this.yield = yield; + this.yield = yield;
+ this.cancelled = false; + this.cancelled = false;
+ } + }

View File

@@ -5,10 +5,10 @@ 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 diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index ed31528ddfec06e723827a505daeca5938dba865..58aa5059c484c9e8acf429a3ae4f07d83594f991 100644 index 69d8ff6a97335b6fe4b20a8229a77f2591b0f050..f5e84bf8817e2d53557e0909d8c9e0e0e8206a16 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -430,6 +430,23 @@ public class Explosion { @@ -430,6 +430,25 @@ public class Explosion {
return; return;
} }
// CraftBukkit end // CraftBukkit end
@@ -22,7 +22,9 @@ index ed31528ddfec06e723827a505daeca5938dba865..58aa5059c484c9e8acf429a3ae4f07d8
+ } + }
+ }else { + }else {
+ Location location = new Location(this.level.getWorld(), this.x, this.y, this.z); + 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()) { + org.bukkit.block.Block block = location.getBlock();
+ org.bukkit.block.BlockState blockState = (this.damageSource.blockState != null) ? this.damageSource.blockState : 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).callEvent()) {
+ this.wasCanceled = true; + this.wasCanceled = true;
+ return; + return;
+ } + }