Paper/nms-patches/BlockNote.patch
2019-12-11 09:00:00 +11:00

47 lines
1.9 KiB
Diff

--- a/net/minecraft/server/BlockNote.java
+++ b/net/minecraft/server/BlockNote.java
@@ -27,7 +27,7 @@
if (flag1 != (Boolean) iblockdata.get(BlockNote.POWERED)) {
if (flag1) {
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
}
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag1), 3);
@@ -35,9 +35,14 @@
}
- private void play(World world, BlockPosition blockposition) {
+ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
if (world.getType(blockposition.up()).isAir()) {
- world.playBlockAction(blockposition, this, 0, 0);
+ // CraftBukkit start
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE));
+ if (!event.isCancelled()) {
+ world.playBlockAction(blockposition, this, 0, 0);
+ }
+ // CraftBukkit end
}
}
@@ -49,7 +54,7 @@
} else {
iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE);
world.setTypeAndData(blockposition, iblockdata, 3);
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
entityhuman.a(StatisticList.TUNE_NOTEBLOCK);
return EnumInteractionResult.SUCCESS;
}
@@ -58,7 +63,7 @@
@Override
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
if (!world.isClientSide) {
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
entityhuman.a(StatisticList.PLAY_NOTEBLOCK);
}
}