Add TNTPrimeEvent
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,24 +275,40 @@
|
||||
@@ -241,24 +275,47 @@
|
||||
return state.hasProperty(BlockStateProperties.WATERLOGGED) && (Boolean) state.getValue(BlockStateProperties.WATERLOGGED) ? 0 : this.igniteOdds.getInt(state.getBlock());
|
||||
}
|
||||
|
||||
@@ -159,18 +159,25 @@
|
||||
+ world.setBlock(blockposition, this.getStateWithAge(world, blockposition, l), 3);
|
||||
} else {
|
||||
- world.removeBlock(pos, false);
|
||||
+ world.removeBlock(blockposition, false);
|
||||
+ if(iblockdata.getBlock() != Blocks.TNT) world.removeBlock(blockposition, false); // Paper - TNTPrimeEvent; We might be cancelling it below, move the setAir down
|
||||
}
|
||||
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof TntBlock) {
|
||||
- TntBlock.explode(world, pos);
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition);
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.FIRE, null).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ world.removeBlock(blockposition, false);
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
+ TntBlock.explode(world, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,9 +360,11 @@
|
||||
@@ -310,9 +367,11 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,25 +11,37 @@
|
||||
|
||||
public class TntBlock extends Block {
|
||||
|
||||
@@ -47,7 +51,7 @@
|
||||
@@ -47,7 +51,13 @@
|
||||
@Override
|
||||
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
if (!oldState.is(state.getBlock())) {
|
||||
- if (world.hasNeighborSignal(pos)) {
|
||||
+ if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
TntBlock.explode(world, pos);
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
@@ -57,7 +61,7 @@
|
||||
@@ -57,7 +67,13 @@
|
||||
|
||||
@Override
|
||||
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
|
||||
- if (world.hasNeighborSignal(pos)) {
|
||||
+ if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
TntBlock.explode(world, pos);
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
@@ -66,7 +70,7 @@
|
||||
@@ -66,7 +82,7 @@
|
||||
|
||||
@Override
|
||||
public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
|
||||
@@ -38,7 +50,21 @@
|
||||
TntBlock.explode(world, pos);
|
||||
}
|
||||
|
||||
@@ -101,6 +105,11 @@
|
||||
@@ -75,6 +91,13 @@
|
||||
|
||||
@Override
|
||||
public void wasExploded(ServerLevel world, BlockPos pos, Explosion explosion) {
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
|
||||
+ org.bukkit.entity.Entity source = explosion.getDirectSourceEntity() != null ? explosion.getDirectSourceEntity().getBukkitEntity() : null;
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
PrimedTnt entitytntprimed = new PrimedTnt(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity());
|
||||
int i = entitytntprimed.getFuse();
|
||||
|
||||
@@ -101,6 +124,17 @@
|
||||
if (!stack.is(Items.FLINT_AND_STEEL) && !stack.is(Items.FIRE_CHARGE)) {
|
||||
return super.useItemOn(stack, state, world, pos, player, hand, hit);
|
||||
} else {
|
||||
@@ -47,10 +73,16 @@
|
||||
+ return InteractionResult.CONSUME;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) {
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
TntBlock.explode(world, pos, player);
|
||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
|
||||
Item item = stack.getItem();
|
||||
@@ -123,6 +132,11 @@
|
||||
@@ -123,6 +157,17 @@
|
||||
Entity entity = projectile.getOwner();
|
||||
|
||||
if (projectile.isOnFire() && projectile.mayInteract(worldserver, blockposition)) {
|
||||
@@ -59,6 +91,12 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // Paper start - TNTPrimeEvent
|
||||
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition);
|
||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.PROJECTILE, projectile.getBukkitEntity()).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - TNTPrimeEvent
|
||||
TntBlock.explode(world, blockposition, entity instanceof LivingEntity ? (LivingEntity) entity : null);
|
||||
world.removeBlock(blockposition, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user