mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 03:32:46 +01:00
f17519338b
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: masmc05 <masmc05@gmail.com>
117 lines
7.4 KiB
Diff
117 lines
7.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
|
Date: Mon, 16 Jul 2018 00:05:05 +0300
|
|
Subject: [PATCH] Add TNTPrimeEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
index 3e2f83e2c695b024bdec2c5e11ab38596730ed4a..789823dbaaf2e23942749145dbb64071539624aa 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
@@ -557,6 +557,11 @@ public class EnderDragon extends Mob implements Enemy {
|
|
});
|
|
craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, ItemStack.EMPTY, false);
|
|
}
|
|
+ // Paper start - TNTPrimeEvent
|
|
+ org.bukkit.block.Block tntBlock = CraftBlock.at(this.level(), blockposition);
|
|
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent())
|
|
+ continue;
|
|
+ // Paper end - TNTPrimeEvent
|
|
nmsBlock.wasExploded(this.level(), blockposition, this.explosionSource);
|
|
|
|
this.level().removeBlock(blockposition, false);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
index c7c4b04dede992991229b149b96ff6a81f499ae3..886b8d2284e3ae85184c842b24869029b9ee4ebe 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
@@ -302,12 +302,19 @@ public class FireBlock extends BaseFireBlock {
|
|
|
|
world.setBlock(blockposition, this.getStateWithAge(world, blockposition, l), 3);
|
|
} else {
|
|
- 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) {
|
|
+ // 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);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/TntBlock.java b/src/main/java/net/minecraft/world/level/block/TntBlock.java
|
|
index 21b83d4d5b58da22ba1fadb0ca376a0076f2e23c..ff872a91effaed7394848fe5c1ab4d2bbac0b5fc 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/TntBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/TntBlock.java
|
|
@@ -50,6 +50,12 @@ public class TntBlock extends Block {
|
|
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
|
if (!oldState.is(state.getBlock())) {
|
|
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);
|
|
}
|
|
@@ -60,6 +66,12 @@ public class TntBlock extends Block {
|
|
@Override
|
|
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
|
if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, sourcePos)) { // 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);
|
|
}
|
|
@@ -78,6 +90,13 @@ public class TntBlock extends Block {
|
|
@Override
|
|
public void wasExploded(Level world, BlockPos pos, Explosion explosion) {
|
|
if (!world.isClientSide) {
|
|
+ // Paper start - TNTPrimeEvent
|
|
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
|
|
+ org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.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();
|
|
|
|
@@ -110,6 +129,12 @@ public class TntBlock extends Block {
|
|
return ItemInteractionResult.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 ItemInteractionResult.FAIL;
|
|
+ }
|
|
+ // Paper end - TNTPrimeEvent
|
|
TntBlock.explode(world, pos, player);
|
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
|
|
Item item = stack.getItem();
|
|
@@ -139,6 +164,12 @@ public class TntBlock extends Block {
|
|
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);
|
|
}
|