mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
65bc2541a3
By: md_5 <git@md-5.net>
65 lines
3.6 KiB
Diff
65 lines
3.6 KiB
Diff
--- a/net/minecraft/world/level/block/BlockTNT.java
|
|
+++ b/net/minecraft/world/level/block/BlockTNT.java
|
|
@@ -27,6 +27,11 @@
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.block.TNTPrimeEvent.PrimeCause;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockTNT extends Block {
|
|
|
|
public static final MapCodec<BlockTNT> CODEC = simpleCodec(BlockTNT::new);
|
|
@@ -45,7 +50,7 @@
|
|
@Override
|
|
protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
|
|
if (!iblockdata1.is(iblockdata.getBlock())) {
|
|
- if (world.hasNeighborSignal(blockposition)) {
|
|
+ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
|
|
explode(world, blockposition);
|
|
world.removeBlock(blockposition, false);
|
|
}
|
|
@@ -55,7 +60,7 @@
|
|
|
|
@Override
|
|
protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
|
|
- if (world.hasNeighborSignal(blockposition)) {
|
|
+ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, blockposition1)) { // CraftBukkit - TNTPrimeEvent
|
|
explode(world, blockposition);
|
|
world.removeBlock(blockposition, false);
|
|
}
|
|
@@ -64,7 +69,7 @@
|
|
|
|
@Override
|
|
public IBlockData playerWillDestroy(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
|
|
- if (!world.isClientSide() && !entityhuman.isCreative() && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE)) {
|
|
+ if (!world.isClientSide() && !entityhuman.isCreative() && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.BLOCK_BREAK, entityhuman, null)) { // CraftBukkit - TNTPrimeEvent
|
|
explode(world, blockposition);
|
|
}
|
|
|
|
@@ -101,6 +106,11 @@
|
|
if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) {
|
|
return super.useItemOn(itemstack, iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock);
|
|
} else {
|
|
+ // CraftBukkit start - TNTPrimeEvent
|
|
+ if (!CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PLAYER, entityhuman, null)) {
|
|
+ return ItemInteractionResult.CONSUME;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
explode(world, blockposition, entityhuman);
|
|
world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11);
|
|
Item item = itemstack.getItem();
|
|
@@ -125,6 +135,11 @@
|
|
Entity entity = iprojectile.getOwner();
|
|
|
|
if (iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition)) {
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
explode(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null);
|
|
world.removeBlock(blockposition, false);
|
|
}
|