Paper/patches/server/0908-fix-Instruments.patch
Nassim Jahnke 4af62f6d1d
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
2d009e64 Update SnakeYAML javadoc link
b4fd213c Switch Player#updateInventory deprecation for internal API annotation

CraftBukkit Changes:
f3b2b2210 SPIGOT-7376: Exception with getBlockData when hasBlockData is false
725545630 SPIGOT-7375: Fix crash breeding certain entities
b9873b0d4 Update Brigadier version with fix
68b320562 SPIGOT-7266: Found typo in CraftBukkit package
98b4d2ff8 SPIGOT-7372, SPIGOT-7373: Signs can't be edited, issues with SignChangeEvent
5f7bd4d78 SPIGOT-7371: Sign does not open edit text on placement
b4cf99d24 SPIGOT-7371: Fix editing signs with API
a2b6c2744 PR-1200: Implement open sign by side
a345bb940 SPIGOT-7368: Downgrade SpecialSource version

Spigot Changes:
723951c3 Rebuild patches
b655c57d Drop old collision API deprecated since 1.9.4
55b0fed4 Rebuild patches
2023-06-08 15:25:35 +02:00

86 lines
3.5 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 82ba1b4d0fbfb72bd858eafe942555f46577ca1e..b4f19650ae6486991bb83147b9fb589474aadb2d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -744,62 +744,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void playNote(Location loc, Instrument instrument, Note note) {
if (this.getHandle().connection == null) return;
- String instrumentName = null;
- switch (instrument.ordinal()) {
- case 0:
- instrumentName = "harp";
- break;
- case 1:
- instrumentName = "basedrum";
- break;
- case 2:
- instrumentName = "snare";
- break;
- case 3:
- instrumentName = "hat";
- break;
- case 4:
- instrumentName = "bass";
- break;
- case 5:
- instrumentName = "flute";
- break;
- case 6:
- instrumentName = "bell";
- break;
- case 7:
- instrumentName = "guitar";
- break;
- case 8:
- instrumentName = "chime";
- break;
- case 9:
- instrumentName = "xylophone";
- break;
- case 10:
- instrumentName = "iron_xylophone";
- break;
- case 11:
- instrumentName = "cow_bell";
- break;
- case 12:
- instrumentName = "didgeridoo";
- break;
- case 13:
- instrumentName = "bit";
- break;
- case 14:
- instrumentName = "banjo";
- break;
- case 15:
- instrumentName = "pling";
- break;
- case 16:
- instrumentName = "xylophone";
- break;
+ // Paper start - fix all this (modeled off of NoteBlock)
+ net.minecraft.world.level.block.state.properties.NoteBlockInstrument nms = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class);
+ float f;
+ if (nms.isTunable()) {
+ f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
+ } else {
+ f = 1.0f;
}
- float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
- this.getHandle().connection.send(new ClientboundSoundPacket(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong()));
+ if (!nms.hasCustomSound()) {
+ this.getHandle().connection.send(new ClientboundSoundPacket(nms.getSoundEvent(), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong()));
+ }
+ // Paper end
}
@Override