geforkt von Mirrors/Paper
Add TNTPrimeEvent
Dieser Commit ist enthalten in:
Ursprung
f20fbf5477
Commit
30f16143ba
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
for (int k1 = i; k1 <= l; ++k1) {
|
for (int k1 = i; k1 <= l; ++k1) {
|
||||||
for (int l1 = j; l1 <= i1; ++l1) {
|
for (int l1 = j; l1 <= i1; ++l1) {
|
||||||
@@ -467,14 +494,61 @@
|
@@ -467,7 +494,11 @@
|
||||||
|
|
||||||
if (!iblockdata.isAir() && !iblockdata.is(BlockTags.DRAGON_TRANSPARENT)) {
|
if (!iblockdata.isAir() && !iblockdata.is(BlockTags.DRAGON_TRANSPARENT)) {
|
||||||
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) {
|
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) {
|
||||||
@ -113,11 +113,10 @@
|
|||||||
} else {
|
} else {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
@@ -476,6 +507,54 @@
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
||||||
+ // SPIGOT-4882: don't fire event if nothing hit
|
+ // SPIGOT-4882: don't fire event if nothing hit
|
||||||
+ if (!flag1) {
|
+ if (!flag1) {
|
||||||
@ -153,17 +152,23 @@
|
|||||||
+ Block.popResource(this.level(), blockposition, itemstack);
|
+ Block.popResource(this.level(), blockposition, itemstack);
|
||||||
+ });
|
+ });
|
||||||
+ craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, ItemStack.EMPTY, false);
|
+ 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((ServerLevel) this.level(), blockposition, this.explosionSource);
|
+ nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource);
|
||||||
+
|
+
|
||||||
+ this.level().removeBlock(blockposition, false);
|
+ this.level().removeBlock(blockposition, false);
|
||||||
}
|
+ }
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
BlockPos blockposition1 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
BlockPos blockposition1 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
||||||
@@ -531,7 +605,7 @@
|
|
||||||
|
@@ -531,7 +610,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kill(ServerLevel world) {
|
public void kill(ServerLevel world) {
|
||||||
@ -172,7 +177,7 @@
|
|||||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||||
if (this.dragonFight != null) {
|
if (this.dragonFight != null) {
|
||||||
this.dragonFight.updateDragon(this);
|
this.dragonFight.updateDragon(this);
|
||||||
@@ -540,7 +614,22 @@
|
@@ -540,7 +619,22 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +200,7 @@
|
|||||||
protected void tickDeath() {
|
protected void tickDeath() {
|
||||||
if (this.dragonFight != null) {
|
if (this.dragonFight != null) {
|
||||||
this.dragonFight.updateDragon(this);
|
this.dragonFight.updateDragon(this);
|
||||||
@@ -555,21 +644,44 @@
|
@@ -555,21 +649,44 @@
|
||||||
this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
|
this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +248,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,15 +704,15 @@
|
@@ -592,15 +709,15 @@
|
||||||
if (world1 instanceof ServerLevel) {
|
if (world1 instanceof ServerLevel) {
|
||||||
ServerLevel worldserver1 = (ServerLevel) world1;
|
ServerLevel worldserver1 = (ServerLevel) world1;
|
||||||
|
|
||||||
@ -262,7 +267,7 @@
|
|||||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -814,6 +926,7 @@
|
@@ -814,6 +931,7 @@
|
||||||
super.addAdditionalSaveData(nbt);
|
super.addAdditionalSaveData(nbt);
|
||||||
nbt.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
|
nbt.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
|
||||||
nbt.putInt("DragonDeathTime", this.dragonDeathTime);
|
nbt.putInt("DragonDeathTime", this.dragonDeathTime);
|
||||||
@ -270,7 +275,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -827,6 +940,11 @@
|
@@ -827,6 +945,11 @@
|
||||||
this.dragonDeathTime = nbt.getInt("DragonDeathTime");
|
this.dragonDeathTime = nbt.getInt("DragonDeathTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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());
|
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);
|
+ world.setBlock(blockposition, this.getStateWithAge(world, blockposition, l), 3);
|
||||||
} else {
|
} else {
|
||||||
- world.removeBlock(pos, false);
|
- 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();
|
Block block = iblockdata.getBlock();
|
||||||
|
|
||||||
if (block instanceof TntBlock) {
|
if (block instanceof TntBlock) {
|
||||||
- TntBlock.explode(world, pos);
|
- 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);
|
+ TntBlock.explode(world, blockposition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,9 +360,11 @@
|
@@ -310,9 +367,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,25 +11,37 @@
|
|||||||
|
|
||||||
public class TntBlock extends Block {
|
public class TntBlock extends Block {
|
||||||
|
|
||||||
@@ -47,7 +51,7 @@
|
@@ -47,7 +51,13 @@
|
||||||
@Override
|
@Override
|
||||||
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||||
if (!oldState.is(state.getBlock())) {
|
if (!oldState.is(state.getBlock())) {
|
||||||
- if (world.hasNeighborSignal(pos)) {
|
- if (world.hasNeighborSignal(pos)) {
|
||||||
+ if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
|
+ 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);
|
TntBlock.explode(world, pos);
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
}
|
}
|
||||||
@@ -57,7 +61,7 @@
|
@@ -57,7 +67,13 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
|
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
|
||||||
- if (world.hasNeighborSignal(pos)) {
|
- if (world.hasNeighborSignal(pos)) {
|
||||||
+ if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
|
+ 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);
|
TntBlock.explode(world, pos);
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
}
|
}
|
||||||
@@ -66,7 +70,7 @@
|
@@ -66,7 +82,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
|
public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
|
||||||
@ -38,7 +50,21 @@
|
|||||||
TntBlock.explode(world, pos);
|
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)) {
|
if (!stack.is(Items.FLINT_AND_STEEL) && !stack.is(Items.FIRE_CHARGE)) {
|
||||||
return super.useItemOn(stack, state, world, pos, player, hand, hit);
|
return super.useItemOn(stack, state, world, pos, player, hand, hit);
|
||||||
} else {
|
} else {
|
||||||
@ -47,10 +73,16 @@
|
|||||||
+ return InteractionResult.CONSUME;
|
+ return InteractionResult.CONSUME;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // 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);
|
TntBlock.explode(world, pos, player);
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
@@ -123,6 +132,11 @@
|
@@ -123,6 +157,17 @@
|
||||||
Entity entity = projectile.getOwner();
|
Entity entity = projectile.getOwner();
|
||||||
|
|
||||||
if (projectile.isOnFire() && projectile.mayInteract(worldserver, blockposition)) {
|
if (projectile.isOnFire() && projectile.mayInteract(worldserver, blockposition)) {
|
||||||
@ -59,6 +91,12 @@
|
|||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // 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);
|
TntBlock.explode(world, blockposition, entity instanceof LivingEntity ? (LivingEntity) entity : null);
|
||||||
world.removeBlock(blockposition, false);
|
world.removeBlock(blockposition, false);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren