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

48 lines
2.1 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
2021-11-22 09:00:00 +11:00
@@ -48,7 +48,8 @@
2018-07-15 10:00:00 +10:00
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) {
2021-11-22 09:00:00 +11:00
- this.playNote(world, blockposition);
+ this.playNote(world, blockposition, iblockdata); // CraftBukkit
+ 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);
@@ -56,9 +57,14 @@
2018-07-15 10:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
- private void playNote(World world, BlockPosition blockposition) {
+ private void playNote(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
if (world.getBlockState(blockposition.above()).isAir()) {
- world.blockEvent(blockposition, this, 0, 0);
2018-07-15 10:00:00 +10:00
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.getValue(BlockNote.INSTRUMENT), data.getValue(BlockNote.NOTE));
2018-07-15 10:00:00 +10:00
+ if (!event.isCancelled()) {
2021-11-22 09:00:00 +11:00
+ world.blockEvent(blockposition, this, 0, 0);
2018-07-15 10:00:00 +10:00
+ }
+ // CraftBukkit end
}
}
2021-11-22 09:00:00 +11:00
@@ -70,7 +76,7 @@
2018-07-15 10:00:00 +10:00
} else {
2021-11-22 09:00:00 +11:00
iblockdata = (IBlockData) iblockdata.cycle(BlockNote.NOTE);
world.setBlock(blockposition, iblockdata, 3);
- this.playNote(world, blockposition);
+ this.playNote(world, blockposition, iblockdata); // CraftBukkit
entityhuman.awardStat(StatisticList.TUNE_NOTEBLOCK);
2020-06-25 10:00:00 +10:00
return EnumInteractionResult.CONSUME;
2018-07-15 10:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
@@ -79,7 +85,7 @@
2019-04-23 12:00:00 +10:00
@Override
2018-07-15 10:00:00 +10:00
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
if (!world.isClientSide) {
2021-11-22 09:00:00 +11:00
- this.playNote(world, blockposition);
+ this.playNote(world, blockposition, iblockdata); // CraftBukkit
entityhuman.awardStat(StatisticList.PLAY_NOTEBLOCK);
2018-07-15 10:00:00 +10:00
}
}