mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 08:57:35 +01:00
2fa8efce9b
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 82af5dc6 SPIGOT-7396: Add PlayerSignOpenEvent 3f0281ca SPIGOT-7063, PR-763: Add DragonBattle#initiateRespawn with custom EnderCrystals f83c8df4 PR-873: Add PlayerRecipeBookClickEvent 14560d39 SPIGOT-7435: Add TeleportCause#EXIT_BED 2cc6db92 SPIGOT-7422, PR-887: Add API to set sherds on decorated pots 36022f02 PR-883: Add ItemFactory#getSpawnEgg 12eb5c46 PR-881: Update Scoreboard Javadocs, remove explicit exception throwing f6d8d44a PR-882: Add modern time API methods to ban API 21a7b710 Upgrade some Maven plugins to reduce warnings 11fd1225 PR-886: Deprecate the SmithingRecipe constructor as it now does nothing dbd1761d SPIGOT-7406: Improve documentation for getDragonBattle CraftBukkit Changes: d548daac2 SPIGOT-7446: BlockState#update not updating a spawner's type to null 70e0bc050 SPIGOT-7447: Fix --forceUpgrade 6752f1d63 SPIGOT-7396: Add PlayerSignOpenEvent 847b4cad5 SPIGOT-7063, PR-1071: Add DragonBattle#initiateRespawn with custom EnderCrystals c335a555f PR-1212: Add PlayerRecipeBookClickEvent 4be756ecb SPIGOT-7445: Fix opening smithing inventory db70bd6ed SPIGOT-7441: Fix issue placing certain items in creative/op f7fa6d993 SPIGOT-7435: Add TeleportCause#EXIT_BED b435e8e8d SPIGOT-7349: Player#setDisplayName not working when message/format unmodified a2fafdd1d PR-1232: Re-add fix for player rotation 7cf863de1 PR-1233: Remove some old MC bug fixes now fixed in vanilla 08ec344ad Fix ChunkGenerator#generateCaves never being called 5daeb502a SPIGOT-7422, PR-1228: Add API to set sherds on decorated pots 52faa6b32 PR-1224: Add ItemFactory#getSpawnEgg 01cae71b7 SPIGOT-7429: Fix LEFT_CLICK_AIR not working for passable entities and spectators a94277a18 PR-1223: Remove non-existent scoreboard display name/prefix/suffix limits 36b107660 PR-1225: Add modern time API methods to ban API 59ead25bc Upgrade some Maven plugins to reduce warnings 202fc5c4e Increase outdated build delay ce545de57 SPIGOT-7398: TextDisplay#setInterpolationDuration incorrectly updates the line width Spigot Changes: b41c46db Rebuild patches 3374045a SPIGOT-7431: Fix EntityMountEvent returning opposite entities 0ca4eb66 Rebuild patches
131 lines
6.1 KiB
Diff
131 lines
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Fri, 22 Oct 2021 16:24:17 -0700
|
|
Subject: [PATCH] Add exploded block state to BlockExplodeEvent and
|
|
EntityDamageByBlockEvent
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java
|
|
index 641c71ab66bd2499b35cf3c1d533fd105d096e10..7dcbb75170296c1dd1d784a032bf369602328b29 100644
|
|
--- a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java
|
|
@@ -10,18 +10,31 @@ import org.jetbrains.annotations.NotNull;
|
|
* Called when a block explodes interacting with blocks. The
|
|
* event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING}
|
|
* is disabled as no block interaction will occur.
|
|
+ * <p>
|
|
+ * The {@link Block} returned by this event is not necessarily
|
|
+ * the block that caused the explosion, just the block at the location where
|
|
+ * the explosion originated. See {@link #getExplodedBlockState()}
|
|
*/
|
|
public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|
private static final HandlerList handlers = new HandlerList();
|
|
private boolean cancel;
|
|
private final List<Block> blocks;
|
|
private float yield;
|
|
+ private final org.bukkit.block.BlockState explodedBlockState; // Paper
|
|
|
|
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper
|
|
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
|
|
+ // Paper start
|
|
+ this(what, blocks, yield, null);
|
|
+ }
|
|
+ @org.jetbrains.annotations.ApiStatus.Internal
|
|
+ public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield, @org.jetbrains.annotations.Nullable org.bukkit.block.BlockState explodedBlockState) {
|
|
+ // Paper end
|
|
super(what);
|
|
this.blocks = blocks;
|
|
this.yield = yield;
|
|
this.cancel = false;
|
|
+ this.explodedBlockState = explodedBlockState; // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -34,6 +47,22 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|
this.cancel = cancel;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Get a capture of the block that directly caused
|
|
+ * the explosion, like a bed or respawn anchor. This
|
|
+ * block state is not placed so {@link org.bukkit.block.BlockState#isPlaced}
|
|
+ * will be false.
|
|
+ * <p>
|
|
+ * Can be null if no block directly caused the explosion.
|
|
+ *
|
|
+ * @return the exploded block state or null if not applicable
|
|
+ */
|
|
+ public @org.jetbrains.annotations.Nullable org.bukkit.block.BlockState getExplodedBlockState() {
|
|
+ return this.explodedBlockState;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Returns the list of blocks that would have been removed or were removed
|
|
* from the explosion event.
|
|
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
|
index 461727dc7f06efb3550fc370e0db5bd04ba89711..ab18f35b686ec79551c307dde9e43c7dfad1b182 100644
|
|
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
|
@@ -9,18 +9,38 @@ import org.jetbrains.annotations.Nullable;
|
|
|
|
/**
|
|
* Called when an entity is damaged by a block
|
|
+ * <p>
|
|
+ * For explosions, the Block returned by {@link #getDamager()} has
|
|
+ * already been cleared. See {@link #getDamagerBlockState()} for a snapshot
|
|
+ * of the block if it has already been changed.
|
|
*/
|
|
public class EntityDamageByBlockEvent extends EntityDamageEvent {
|
|
private final Block damager;
|
|
+ private final org.bukkit.block.BlockState damagerBlockState; // Paper
|
|
|
|
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
|
|
+ // Paper start
|
|
+ this(damager, damagee, cause, damage, null);
|
|
+ }
|
|
+ @org.jetbrains.annotations.ApiStatus.Internal
|
|
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage, final @Nullable org.bukkit.block.BlockState damagerBlockState) {
|
|
+ // Paper end
|
|
super(damagee, cause, damage);
|
|
this.damager = damager;
|
|
+ this.damagerBlockState = damagerBlockState; // Paper
|
|
}
|
|
|
|
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
|
|
+ // Paper start
|
|
+ this(damager, damagee, cause, modifiers, modifierFunctions, null);
|
|
+ }
|
|
+
|
|
+ @org.jetbrains.annotations.ApiStatus.Internal
|
|
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, final @Nullable org.bukkit.block.BlockState damagerBlockState) {
|
|
+ // Paper end
|
|
super(damagee, cause, modifiers, modifierFunctions);
|
|
this.damager = damager;
|
|
+ this.damagerBlockState = damagerBlockState; // Paper
|
|
}
|
|
|
|
/**
|
|
@@ -32,4 +52,20 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent {
|
|
public Block getDamager() {
|
|
return damager;
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Get a capture of the block that directly caused
|
|
+ * the damage, like a bed or respawn anchor. This
|
|
+ * block state is not placed so {@link org.bukkit.block.BlockState#isPlaced}
|
|
+ * will be false.
|
|
+ * <p>
|
|
+ * Can be null if the block wasn't changed before the event
|
|
+ *
|
|
+ * @return the damager block state or null if not applicable
|
|
+ */
|
|
+ public @Nullable org.bukkit.block.BlockState getDamagerBlockState() {
|
|
+ return this.damagerBlockState;
|
|
+ }
|
|
+ // Paper end
|
|
}
|