03a4e7ac75
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: 37262de8 PR-812: Add Registry#match(String) d6b40162 SPIGOT-4569: Add more BlockData API f9691891 PR-809: Throw a more clear error for BlockIterators with zero direction, add Vector#isZero() 91e79e19 PR-804: Added methods to get translation keys for materials, itemstacks and more 426b00d3 PR-795: Add new BiomeParameterPoint passed to BiomeProvider#getBiome 0e91ea52 SPIGOT-7224: Add events for brewing stands and campfires starting their actions CraftBukkit Changes: a50301aa5 Fix issues with fluid tag conversion and fluid #isTagged 6aeb5e4c3 SPIGOT-4569: Implement more BlockData API 7dbf862c2 PR-1131: Added methods to get translation keys for materials, itemstacks and more 7167588b1 PR-1117: Add new BiomeParameterPoint passed to BiomeProvider#getBiome 7c44152eb SPIGOT-7224: Add events for brewing stands and campfires starting their actions
86 Zeilen
3.5 KiB
Diff
86 Zeilen
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 18c2c1454f8f3319b2a0b7649b99d25933cc18a6..ab11ed9d587b633f0f86f13dcb63adac63c3ff78 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -767,62 +767,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
|