PaperMC/patches/server/fix-Instruments.patch
Nassim Jahnke 17f71281d2 Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
dfe1fb48 PR-906: Add missing MinecraftExperimental annotation to Bundles
825ab30d PR-905: Add missing MapCursor.Type and update documentation
e03d10e6 PR-903: Make BARRIER Waterlogged
1961ead6 PR-898: Use Java Consumer instead of Bukkit Consumer

CraftBukkit Changes:
f71a799f0 Make BARRIER Waterlogged
172f76a45 Upgrade specialsource-maven-plugin
f0702775c SPIGOT-7486: Alternate approach to null profile names
069495671 SPIGOT-7485: Allow air entity items since required for Vanilla logic
5dfd33dc2 SPIGOT-7484: Cancelling PlayerEditBookEvent does not update client's book contents
02d490788 PR-1250: Standardize and centralize Bukkit / Minecraft registry conversion
9024a09b9 PR-1251: Use Java Consumer instead of Bukkit Consumer
6d4b25bf1 Increase diff stability
2023-09-23 12:06:03 +10:00

53 lines
2.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 9 Dec 2022 01:47:23 -0800
Subject: [PATCH] fix Instruments
properly handle Player#playNote
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (this.getHandle().connection == null) return;
- Sound instrumentSound = switch (instrument.ordinal()) {
- case 0 -> Sound.BLOCK_NOTE_BLOCK_HARP;
- case 1 -> Sound.BLOCK_NOTE_BLOCK_BASEDRUM;
- case 2 -> Sound.BLOCK_NOTE_BLOCK_SNARE;
- case 3 -> Sound.BLOCK_NOTE_BLOCK_HAT;
- case 4 -> Sound.BLOCK_NOTE_BLOCK_BASS;
- case 5 -> Sound.BLOCK_NOTE_BLOCK_FLUTE;
- case 6 -> Sound.BLOCK_NOTE_BLOCK_BELL;
- case 7 -> Sound.BLOCK_NOTE_BLOCK_GUITAR;
- case 8 -> Sound.BLOCK_NOTE_BLOCK_CHIME;
- case 9 -> Sound.BLOCK_NOTE_BLOCK_XYLOPHONE;
- case 10 -> Sound.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE;
- case 11 -> Sound.BLOCK_NOTE_BLOCK_COW_BELL;
- case 12 -> Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO;
- case 13 -> Sound.BLOCK_NOTE_BLOCK_BIT;
- case 14 -> Sound.BLOCK_NOTE_BLOCK_BANJO;
- case 15 -> Sound.BLOCK_NOTE_BLOCK_PLING;
- case 16 -> Sound.BLOCK_NOTE_BLOCK_XYLOPHONE;
- default -> null;
- };
-
- float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
- this.getHandle().connection.send(new ClientboundSoundPacket(CraftSound.bukkitToMinecraftHolder(instrumentSound), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong()));
+ // Paper start - fix all this (modeled off of NoteBlock)
+ net.minecraft.world.level.block.state.properties.NoteBlockInstrument noteBlockInstrument = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class);
+ float pitch;
+ if (noteBlockInstrument.isTunable()) {
+ pitch = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
+ } else {
+ pitch = 1.0f;
+ }
+ if (!noteBlockInstrument.hasCustomSound()) {
+ this.getHandle().connection.send(new ClientboundSoundPacket(noteBlockInstrument.getSoundEvent(), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, pitch, this.getHandle().getRandom().nextLong()));
+ }
+ // Paper end
}
@Override