2022-12-20 06:09:51 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 22 Oct 2021 16:25:07 -0700
2023-07-12 21:12:12 +02:00
Subject: [PATCH] Add exploded block state to BlockExplodeEvent and
EntityDamageByBlockEvent
2022-12-20 06:09:51 +01:00
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
2024-01-19 12:30:04 +01:00
index ed1277fad60992344b94f8a939febaca3edd9702..fc6903b20a6e084729306fc960a6fc80e094f76c 100644
2022-12-20 06:09:51 +01:00
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
2023-03-15 01:06:28 +01:00
@@ -52,6 +52,7 @@ public class DamageSource {
2022-12-20 06:09:51 +01:00
return this;
}
2023-03-15 01:06:28 +01:00
// CraftBukkit end
2022-12-20 06:09:51 +01:00
+ public @Nullable org.bukkit.block.BlockState explodedBlockState; // Paper - add exploded state
2023-03-15 01:06:28 +01:00
public String toString() {
return "DamageSource (" + this.type().msgId() + ")";
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSources.java b/src/main/java/net/minecraft/world/damagesource/DamageSources.java
2024-01-16 12:41:40 +01:00
index 8bde8c581796ed11809b80b9a30a33df86116745..f339475185645f7be30963e4f980ce81a6f7e536 100644
2023-03-15 01:06:28 +01:00
--- a/src/main/java/net/minecraft/world/damagesource/DamageSources.java
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSources.java
2023-06-08 10:47:19 +02:00
@@ -247,8 +247,17 @@ public class DamageSources {
2023-03-15 01:06:28 +01:00
return this.source(DamageTypes.SONIC_BOOM, attacker);
2022-12-20 06:09:51 +01:00
}
2024-01-16 12:41:40 +01:00
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - add exploded state
2023-03-15 01:06:28 +01:00
public DamageSource badRespawnPointExplosion(Vec3 position) {
- return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), position);
2024-01-16 12:41:40 +01:00
+ // Paper start - add exploded state
2023-03-15 01:06:28 +01:00
+ return this.badRespawnPointExplosion(position, null);
2022-12-20 06:09:51 +01:00
+ }
2023-03-15 01:06:28 +01:00
+
+ public DamageSource badRespawnPointExplosion(Vec3 position, @Nullable org.bukkit.block.BlockState explodedBlockState) {
+ DamageSource source = new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), position);
2022-12-20 06:09:51 +01:00
+ source.explodedBlockState = explodedBlockState;
+ return source;
2024-01-16 12:41:40 +01:00
+ // Paper end - add exploded state
2022-12-20 06:09:51 +01:00
}
2023-06-08 10:47:19 +02:00
public DamageSource outOfBorder() {
2022-12-20 06:09:51 +01:00
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
2024-01-24 15:57:53 +01:00
index c7075aaf417b1dc9eab4a19b72fac50d2a44286b..34159798e6617ce13b3ac8aae07d24d9bca6ee36 100644
2022-12-20 06:09:51 +01:00
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
2024-01-23 12:06:27 +01:00
@@ -367,7 +367,7 @@ public class Explosion {
2022-12-20 06:09:51 +01:00
bukkitBlocks = event.blockList();
2023-12-06 17:21:56 +01:00
this.yield = event.getYield();
2022-12-20 06:09:51 +01:00
} else {
2023-12-06 17:21:56 +01:00
- BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.yield);
2024-01-16 12:41:40 +01:00
+ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.yield, this.damageSource.explodedBlockState); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
this.level.getCraftServer().getPluginManager().callEvent(event);
2023-12-06 17:21:56 +01:00
this.wasCanceled = event.isCancelled();
2022-12-20 06:09:51 +01:00
bukkitBlocks = event.blockList();
diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java
2024-02-01 10:15:57 +01:00
index c5d892950b4027cf9879eafc1c0f4e4c62fb4f51..c14cddd42c61512c312231b1e93ccc6efbde620c 100644
2022-12-20 06:09:51 +01:00
--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java
2023-12-06 17:21:56 +01:00
@@ -96,6 +96,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
2022-12-20 06:09:51 +01:00
// CraftBukkit - moved world and biome check into EntityHuman
if (false && !BedBlock.canSetSpawn(world)) {
2024-01-16 12:41:40 +01:00
+ final org.bukkit.block.BlockState explodedBlockState = org.bukkit.craftbukkit.block.CraftBlockStates.getUnplacedBlockState(world, pos, state); // Paper - add exploded state (this won't be called due to the false, but it's good for reference)
2022-12-20 06:09:51 +01:00
world.removeBlock(pos, false);
BlockPos blockposition1 = pos.relative(((Direction) state.getValue(BedBlock.FACING)).getOpposite());
2023-12-06 17:21:56 +01:00
@@ -105,7 +106,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
2022-12-20 06:09:51 +01:00
Vec3 vec3d = pos.getCenter();
2023-03-15 01:06:28 +01:00
- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK);
2024-01-16 12:41:40 +01:00
+ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, explodedBlockState), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
return InteractionResult.SUCCESS;
} else if ((Boolean) state.getValue(BedBlock.OCCUPIED)) {
if (!this.kickVillagerOutOfBed(world, pos)) {
2023-12-06 17:21:56 +01:00
@@ -147,6 +148,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
2022-12-20 06:09:51 +01:00
private InteractionResult explodeBed(BlockState iblockdata, Level world, BlockPos blockposition) {
{
{
2024-01-16 12:41:40 +01:00
+ final org.bukkit.block.BlockState explodedBlockState = org.bukkit.craftbukkit.block.CraftBlockStates.getUnplacedBlockState(world, blockposition, iblockdata); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
world.removeBlock(blockposition, false);
BlockPos blockposition1 = blockposition.relative(((Direction) iblockdata.getValue(BedBlock.FACING)).getOpposite());
2023-12-06 17:21:56 +01:00
@@ -156,7 +158,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
2022-12-20 06:09:51 +01:00
Vec3 vec3d = blockposition.getCenter();
2023-03-15 01:06:28 +01:00
- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK);
2024-01-16 12:41:40 +01:00
+ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, explodedBlockState), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
return InteractionResult.SUCCESS;
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
2024-01-19 17:54:05 +01:00
index acd5ec218b8d4c096f44ae2eec1379eeaf30ddc5..088262f306755a9cb785c7a0cf0a9c66ed0965a8 100644
2022-12-20 06:09:51 +01:00
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
2023-12-06 17:21:56 +01:00
@@ -131,6 +131,7 @@ public class RespawnAnchorBlock extends Block {
2022-12-20 06:09:51 +01:00
}
private void explode(BlockState state, Level world, final BlockPos explodedPos) {
2024-01-16 12:41:40 +01:00
+ final org.bukkit.block.BlockState explodedBlockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(explodedPos, state, null); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
world.removeBlock(explodedPos, false);
2023-05-12 13:10:08 +02:00
Stream<Direction> stream = Direction.Plane.HORIZONTAL.stream(); // CraftBukkit - decompile error
2023-12-06 17:21:56 +01:00
@@ -147,7 +148,7 @@ public class RespawnAnchorBlock extends Block {
2022-12-20 06:09:51 +01:00
};
2023-05-12 13:10:08 +02:00
Vec3 vec3d = explodedPos.getCenter();
- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK);
2024-01-16 12:41:40 +01:00
+ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, explodedBlockState), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // Paper - add exploded state
2022-12-20 06:09:51 +01:00
}
public static boolean canSetSpawn(Level world) {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
2024-01-16 12:41:40 +01:00
index f81c0d07a5efc92942d8ab5c50a8260db033307d..8afc396c162d928902a9d9beb9f039b06630f755 100644
2022-12-20 06:09:51 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
2024-01-14 10:46:04 +01:00
@@ -276,6 +276,12 @@ public final class CraftBlockStates {
2022-12-20 06:09:51 +01:00
BlockEntity tileEntity = (blockEntityTag == null) ? null : BlockEntity.loadStatic(blockPosition, blockData, blockEntityTag);
return CraftBlockStates.getBlockState(null, blockPosition, blockData, tileEntity);
}
2024-01-16 12:41:40 +01:00
+ // Paper start - add exploded state
2022-12-20 06:09:51 +01:00
+ public static BlockState getUnplacedBlockState(net.minecraft.world.level.BlockGetter levelAccessor, BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockData) {
+ BlockEntity tileEntity = levelAccessor.getBlockEntity(blockPos);
+ return CraftBlockStates.getBlockState(null, blockPos, blockData, tileEntity);
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - add exploded state
2022-12-20 06:09:51 +01:00
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, TileEntity)
private static CraftBlockState getBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
2023-07-12 21:12:12 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2024-02-01 10:15:57 +01:00
index a1860e21fd53b801ffd651cd27f5a8f9fcd02ee0..52444c7c83e60e5fe40c485c13a59cca9ce5ee20 100644
2023-07-12 21:12:12 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
@@ -1045,7 +1045,7 @@ public class CraftEventFactory {
2023-07-12 21:12:12 +02:00
CraftEventFactory.entityDamage = null;
EntityDamageEvent event;
if (damager == null) {
- event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions);
2024-01-16 12:41:40 +01:00
+ event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions, source.explodedBlockState); // Paper - add exploded state
2023-07-12 21:12:12 +02:00
} else if (entity instanceof EnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) {
event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions);
} else {