craftbukkit/nms-patches/net/minecraft/world/level/block/BlockNote.patch

24 lines
1.4 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/level/block/BlockNote.java
+++ b/net/minecraft/world/level/block/BlockNote.java
2024-04-24 01:15:00 +10:00
@@ -83,6 +83,7 @@
2021-11-22 09:00:00 +11:00
if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) {
2019-04-23 12:00:00 +10:00
if (flag1) {
2022-12-08 03:00:00 +11:00
this.playNote((Entity) null, iblockdata, world, blockposition);
2021-11-22 09:00:00 +11:00
+ iblockdata = world.getBlockState(blockposition); // CraftBukkit - SPIGOT-5617: update in case changed in event
2018-07-15 10:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3);
2024-04-24 01:15:00 +10:00
@@ -92,6 +93,12 @@
2018-07-15 10:00:00 +10:00
2022-12-08 03:00:00 +11:00
private void playNote(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
2023-06-08 01:30:00 +10:00
if (((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).worksAboveNoteBlock() || world.getBlockState(blockposition.above()).isAir()) {
2018-07-15 10:00:00 +10:00
+ // CraftBukkit start
2022-12-08 03:00:00 +11:00
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, iblockdata.getValue(BlockNote.INSTRUMENT), iblockdata.getValue(BlockNote.NOTE));
2022-06-08 02:00:00 +10:00
+ if (event.isCancelled()) {
+ return;
2018-07-15 10:00:00 +10:00
+ }
+ // CraftBukkit end
2022-06-08 02:00:00 +10:00
world.blockEvent(blockposition, this, 0, 0);
2024-04-24 01:15:00 +10:00
world.gameEvent(entity, (Holder) GameEvent.NOTE_BLOCK_PLAY, blockposition);
2018-07-15 10:00:00 +10:00
}