summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockNote.patch
blob: 246b882bc816870971ab2184d230201be20cb5b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- a/net/minecraft/server/BlockNote.java
+++ b/net/minecraft/server/BlockNote.java
@@ -24,7 +24,7 @@
 
         if (flag != ((Boolean) iblockdata.get(BlockNote.POWERED)).booleanValue()) {
             if (flag) {
-                this.play(world, blockposition);
+                this.play(world, blockposition, iblockdata); // CraftBukkit
             }
 
             world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, Boolean.valueOf(flag)), 3);
@@ -32,9 +32,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
         }
 
     }
@@ -45,7 +50,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 true;
         }
@@ -53,7 +58,7 @@
 
     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);
         }
     }