From 1c7bbfcd0d55ddd8ec829ec91ffb978d184dc156 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Mon, 29 Apr 2024 23:49:45 +0200 Subject: Regenerate generated API, rename EntityDamageByBlockEvent patches --- .../destroystokyo/paper/entity/ai/VanillaGoal.java | 2 +- .../io/papermc/paper/registry/keys/BiomeKeys.java | 2 +- .../papermc/paper/registry/keys/GameEventKeys.java | 2 +- .../papermc/paper/registry/keys/StructureKeys.java | 2 +- .../paper/registry/keys/StructureTypeKeys.java | 2 +- .../paper/registry/keys/TrimMaterialKeys.java | 2 +- .../paper/registry/keys/TrimPatternKeys.java | 2 +- ...d-block-state-to-BlockExplodeEvent-and-En.patch | 84 ---------------------- ...d-block-state-to-EntityDamageByBlockEvent.patch | 83 +++++++++++++++++++++ ...d-block-state-to-BlockExplodeEvent-and-En.patch | 68 ------------------ ...d-block-state-to-EntityDamageByBlockEvent.patch | 67 +++++++++++++++++ 11 files changed, 157 insertions(+), 159 deletions(-) delete mode 100644 patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch create mode 100644 patches/api/0394-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch delete mode 100644 patches/server/0812-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch create mode 100644 patches/server/0812-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch diff --git a/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java index 7ff40b6c33..43f4deacef 100644 --- a/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -70,7 +70,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") public interface VanillaGoal extends Goal { GoalKey RANDOM_STAND = create("random_stand", AbstractHorse.class); diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java index 3bd15016b0..173550253f 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class BiomeKeys { /** diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java index 26ce70c2ab..f220c63b8a 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class GameEventKeys { /** diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java index 8b679c044e..22d644aa24 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class StructureKeys { /** diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java index 8e7628c6a4..bd36a38558 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class StructureTypeKeys { /** diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java index e52bb12173..0635cecd49 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class TrimMaterialKeys { /** diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java index 72d23426af..b3e92fbbe2 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.20.5") +@GeneratedFrom("1.20.6") @ApiStatus.Experimental public final class TrimPatternKeys { /** diff --git a/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch b/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch deleted file mode 100644 index a1998880e0..0000000000 --- a/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -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 8309b030c2120f1496d244f3ebc1094def41c869..a7c297364805c58ae16895055d8eae0484384b7d 100644 ---- a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java -+++ b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java -@@ -32,6 +32,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { - this.cancel = false; - } - -+ @io.papermc.paper.annotation.DoNotUse // Paper - @Deprecated(forRemoval = true) - public BlockExplodeEvent(@NotNull final Block what, @NotNull final List blocks, final float yield) { - this(what, what.getState(), blocks, yield); -diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java -index 467a0d6cabc5e860628be3b1e62de773efde5d2e..1fb15e2ade8ff3c4d662eca87b078b4577f786e1 100644 ---- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java -+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java -@@ -11,28 +11,35 @@ import org.jetbrains.annotations.Nullable; - - /** - * Called when an entity is damaged by a block -+ *

-+ * 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 - - @Deprecated(forRemoval = true) - public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { -- this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), damage); -+ this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), damage, null); // Paper - } - -- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { -+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper - super(damagee, cause, damageSource, damage); - this.damager = damager; -+ this.damagerBlockState = damagerBlockState; // Paper - } - - @Deprecated(forRemoval = true) - public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { -- this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions); -+ this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions, null); // Paper - } - -- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { -+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper - super(damagee, cause, damageSource, modifiers, modifierFunctions); - this.damager = damager; -+ this.damagerBlockState = damagerBlockState; // Paper - } - - /** -@@ -44,4 +51,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. -+ *

-+ * 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 - } diff --git a/patches/api/0394-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch b/patches/api/0394-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch new file mode 100644 index 0000000000..88530a6a65 --- /dev/null +++ b/patches/api/0394-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch @@ -0,0 +1,83 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Fri, 22 Oct 2021 16:24:17 -0700 +Subject: [PATCH] Add exploded block state to EntityDamageByBlockEvent + + +diff --git a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +index 8309b030c2120f1496d244f3ebc1094def41c869..a7c297364805c58ae16895055d8eae0484384b7d 100644 +--- a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java ++++ b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +@@ -32,6 +32,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { + this.cancel = false; + } + ++ @io.papermc.paper.annotation.DoNotUse // Paper + @Deprecated(forRemoval = true) + public BlockExplodeEvent(@NotNull final Block what, @NotNull final List blocks, final float yield) { + this(what, what.getState(), blocks, yield); +diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +index 467a0d6cabc5e860628be3b1e62de773efde5d2e..1fb15e2ade8ff3c4d662eca87b078b4577f786e1 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +@@ -11,28 +11,35 @@ import org.jetbrains.annotations.Nullable; + + /** + * Called when an entity is damaged by a block ++ *

++ * 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 + + @Deprecated(forRemoval = true) + public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { +- this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), damage); ++ this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), damage, null); // Paper + } + +- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { ++ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper + super(damagee, cause, damageSource, damage); + this.damager = damager; ++ this.damagerBlockState = damagerBlockState; // Paper + } + + @Deprecated(forRemoval = true) + public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { +- this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions); ++ this(damager, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions, null); // Paper + } + +- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { ++ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper + super(damagee, cause, damageSource, modifiers, modifierFunctions); + this.damager = damager; ++ this.damagerBlockState = damagerBlockState; // Paper + } + + /** +@@ -44,4 +51,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. ++ *

++ * 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 + } diff --git a/patches/server/0812-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch b/patches/server/0812-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch deleted file mode 100644 index 413455c787..0000000000 --- a/patches/server/0812-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Fri, 22 Oct 2021 16:25:07 -0700 -Subject: [PATCH] Add exploded block state to BlockExplodeEvent and - EntityDamageByBlockEvent - -== AT == -public org.bukkit.craftbukkit.block.CraftBlockStates getBlockState(Lorg/bukkit/World;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lorg/bukkit/craftbukkit/block/CraftBlockState; - -diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSources.java b/src/main/java/net/minecraft/world/damagesource/DamageSources.java -index 89928dad3182a0131c3fba19c9c131d6997028eb..349d1683458ec5d641c9823aa7a68dec8820a664 100644 ---- a/src/main/java/net/minecraft/world/damagesource/DamageSources.java -+++ b/src/main/java/net/minecraft/world/damagesource/DamageSources.java -@@ -265,6 +265,7 @@ public class DamageSources { - return this.source(DamageTypes.SONIC_BOOM, attacker); - } - -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - add exploded state - public DamageSource badRespawnPointExplosion(Vec3 position) { - // CraftBukkit start - return this.badRespawnPointExplosion(position, null, null, null); -@@ -273,7 +274,7 @@ public class DamageSources { - public DamageSource badRespawnPointExplosion(Vec3 vec3d, net.minecraft.world.level.Level world, net.minecraft.world.level.block.state.BlockState blockData, net.minecraft.core.BlockPos position) { - DamageSource damageSource = new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d); - if (world != null && blockData != null && position != null) { -- damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, position, blockData, null); -+ damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world.getWorld(), position, blockData, world.getBlockEntity(position)); // Paper - } - return damageSource; - // CraftBukkit end -diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index c52cb55cd1da988ec646e4e1484ec1a72513291d..0ab1cf162016422007426698dec60ffd875631a0 100644 ---- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1070,7 +1070,7 @@ public class CraftEventFactory { - Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCausingEntity(); - if (source.is(DamageTypeTags.IS_EXPLOSION)) { - if (damager == null) { -- return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled); -+ return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.blockState); // Paper - Include BlockState for damage - } - DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; - return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API -@@ -1117,7 +1117,7 @@ public class CraftEventFactory { - } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, source.getDirectBlock(), source.getMsgId())); - } -- return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled); -+ return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.blockState); // Paper - Include BlockState for damage - } - - DamageCause cause; -@@ -1170,8 +1170,13 @@ public class CraftEventFactory { - return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); - } - -- private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { -- EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions); -+ // Paper start -+ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { // Paper -+ return callEntityDamageEvent(damager, damagee, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, null); -+ } -+ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled, @Nullable org.bukkit.block.BlockState explodedBlockState) { -+ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, explodedBlockState); -+ // Paper end - return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); - } - diff --git a/patches/server/0812-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch b/patches/server/0812-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch new file mode 100644 index 0000000000..f880ce7d71 --- /dev/null +++ b/patches/server/0812-Add-exploded-block-state-to-EntityDamageByBlockEvent.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Fri, 22 Oct 2021 16:25:07 -0700 +Subject: [PATCH] Add exploded block state to EntityDamageByBlockEvent + +== AT == +public org.bukkit.craftbukkit.block.CraftBlockStates getBlockState(Lorg/bukkit/World;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lorg/bukkit/craftbukkit/block/CraftBlockState; + +diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSources.java b/src/main/java/net/minecraft/world/damagesource/DamageSources.java +index 89928dad3182a0131c3fba19c9c131d6997028eb..349d1683458ec5d641c9823aa7a68dec8820a664 100644 +--- a/src/main/java/net/minecraft/world/damagesource/DamageSources.java ++++ b/src/main/java/net/minecraft/world/damagesource/DamageSources.java +@@ -265,6 +265,7 @@ public class DamageSources { + return this.source(DamageTypes.SONIC_BOOM, attacker); + } + ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - add exploded state + public DamageSource badRespawnPointExplosion(Vec3 position) { + // CraftBukkit start + return this.badRespawnPointExplosion(position, null, null, null); +@@ -273,7 +274,7 @@ public class DamageSources { + public DamageSource badRespawnPointExplosion(Vec3 vec3d, net.minecraft.world.level.Level world, net.minecraft.world.level.block.state.BlockState blockData, net.minecraft.core.BlockPos position) { + DamageSource damageSource = new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d); + if (world != null && blockData != null && position != null) { +- damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, position, blockData, null); ++ damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world.getWorld(), position, blockData, world.getBlockEntity(position)); // Paper + } + return damageSource; + // CraftBukkit end +diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +index c52cb55cd1da988ec646e4e1484ec1a72513291d..0ab1cf162016422007426698dec60ffd875631a0 100644 +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -1070,7 +1070,7 @@ public class CraftEventFactory { + Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCausingEntity(); + if (source.is(DamageTypeTags.IS_EXPLOSION)) { + if (damager == null) { +- return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.blockState); // Paper - Include BlockState for damage + } + DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; + return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API +@@ -1117,7 +1117,7 @@ public class CraftEventFactory { + } else { + throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, source.getDirectBlock(), source.getMsgId())); + } +- return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.blockState); // Paper - Include BlockState for damage + } + + DamageCause cause; +@@ -1170,8 +1170,13 @@ public class CraftEventFactory { + return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); + } + +- private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { +- EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions); ++ // Paper start ++ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { // Paper ++ return callEntityDamageEvent(damager, damagee, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, null); ++ } ++ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled, @Nullable org.bukkit.block.BlockState explodedBlockState) { ++ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, explodedBlockState); ++ // Paper end + return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); + } + -- cgit v1.2.3