mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-19 15:09:27 +00:00
49 lines
2.8 KiB
Diff
49 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Kieran Wallbanks <kieran.wallbanks@gmail.com>
|
|
Date: Thu, 11 Feb 2021 11:31:38 +0000
|
|
Subject: [PATCH] Fix NotePlayEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockNote.java b/src/main/java/net/minecraft/world/level/block/BlockNote.java
|
|
index feec1db88b22a4d13ffd3034633da79ed41b94fe..5b07037c0501d3ecf0c82f40b78bd135b81dbb75 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockNote.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockNote.java
|
|
@@ -61,10 +61,9 @@ public class BlockNote extends Block {
|
|
private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
|
|
if (world.getType(blockposition.up()).isAir()) {
|
|
// 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);
|
|
- }
|
|
+ // Haricot start - move NotePlayEvent call to fix instrument/note changes
|
|
+ world.playBlockAction(blockposition, this, 0, 0);
|
|
+ // Haricot end
|
|
// CraftBukkit end
|
|
}
|
|
|
|
@@ -93,12 +92,19 @@ public class BlockNote extends Block {
|
|
|
|
@Override
|
|
public boolean a(IBlockData iblockdata, World world, BlockPosition blockposition, int i, int j) {
|
|
- int k = (Integer) iblockdata.get(BlockNote.NOTE);
|
|
+ // Haricot start - move NotePlayEvent call to fix instrument/note changes
|
|
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, iblockdata.get(BlockNote.INSTRUMENT), iblockdata.get(BlockNote.NOTE));
|
|
+
|
|
+ int k = event.getNote().getId();
|
|
float f = (float) Math.pow(2.0D, (double) (k - 12) / 12.0D);
|
|
|
|
- world.playSound((EntityHuman) null, blockposition, ((BlockPropertyInstrument) iblockdata.get(BlockNote.INSTRUMENT)).b(), SoundCategory.RECORDS, 3.0F, f);
|
|
- world.addParticle(Particles.NOTE, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 1.2D, (double) blockposition.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
|
|
- return true;
|
|
+ if (!event.isCancelled()) {
|
|
+ world.playSound((EntityHuman) null, blockposition, BlockPropertyInstrument.valueOf(event.getInstrument().getName().toUpperCase()).b(), SoundCategory.RECORDS, 3.0F, f);
|
|
+ world.addParticle(Particles.NOTE, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 1.2D, (double) blockposition.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ // Haricot end
|
|
}
|
|
|
|
@Override
|