SPIGOT-519: Add TNTPrimeEvent
Thanks to Pokechu22 for an earlier implementation By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,12 +269,24 @@
|
||||
@@ -234,12 +269,28 @@
|
||||
return iblockdata.hasProperty(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockProperties.WATERLOGGED) ? 0 : this.igniteOdds.getInt(iblockdata.getBlock());
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (iblockdata.getBlock() instanceof BlockTNT && !CraftEventFactory.callTNTPrimeEvent(world, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.FIRE, null, sourceposition)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (randomsource.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
|
||||
|
||||
@@ -1,11 +1,62 @@
|
||||
--- a/net/minecraft/world/level/block/BlockTNT.java
|
||||
+++ b/net/minecraft/world/level/block/BlockTNT.java
|
||||
@@ -121,6 +121,11 @@
|
||||
@@ -25,6 +25,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 BlockStateBoolean UNSTABLE = BlockProperties.UNSTABLE;
|
||||
@@ -37,7 +42,7 @@
|
||||
@Override
|
||||
public 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);
|
||||
}
|
||||
@@ -47,7 +52,7 @@
|
||||
|
||||
@Override
|
||||
public 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);
|
||||
}
|
||||
@@ -56,7 +61,7 @@
|
||||
|
||||
@Override
|
||||
public void 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);
|
||||
}
|
||||
|
||||
@@ -95,6 +100,11 @@
|
||||
if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) {
|
||||
return super.use(iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock);
|
||||
} else {
|
||||
+ // CraftBukkit start - TNTPrimeEvent
|
||||
+ if (!CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PLAYER, entityhuman, null)) {
|
||||
+ return EnumInteractionResult.CONSUME;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
explode(world, blockposition, entityhuman);
|
||||
world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11);
|
||||
Item item = itemstack.getItem();
|
||||
@@ -121,6 +131,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()).isCancelled()) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled() || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
Reference in New Issue
Block a user