Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9953)
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: 96340858 PR-938: Various Sound API improvements cbfe0ff0 PR-937: Minor improvements to World#rayTrace documentation e979ee95 PR-935: Change Consumer and Predicates to super 27ae46dc SPIGOT-3641, SPIGOT-7479, PR-931: Add missing values to EntityEffect 0616ec8b Add eclipse .factorypath file to .gitignore CraftBukkit Changes: 8e162d008 PR-1301: Various Sound API improvements eeb7dfc2d SPIGOT-7520: Attribute LootTableSeed missing for generated containers with attached LootTable d433f086d PR-1297: Change Consumer and Predicates to super 864f616da SPIGOT-7518: Fix NullPointerException when calling Block#applyBoneMeal() 5a2d905af Add eclipse .factorypath file to .gitignore 7c6bf15d4 Fix SkullMeta configuration serialization / deserialization with note block sound Spigot Changes: 7de1049b Rebuild patches
This commit is contained in:
@@ -10,44 +10,47 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- 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 {
|
||||
Sound instrumentSound = instrument.getSound();
|
||||
if (instrumentSound == null) return;
|
||||
|
||||
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()));
|
||||
+ }
|
||||
- float pitch = note.getPitch();
|
||||
+ // Paper start - use correct pitch (modeled off of NoteBlock)
|
||||
+ final net.minecraft.world.level.block.state.properties.NoteBlockInstrument noteBlockInstrument = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class);
|
||||
+ final float pitch = noteBlockInstrument.isTunable() ? note.getPitch() : 1.0f;
|
||||
+ // Paper end
|
||||
this.getHandle().connection.send(new ClientboundSoundPacket(CraftSound.bukkitToMinecraftHolder(instrumentSound), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, pitch, this.getHandle().getRandom().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java b/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.block;
|
||||
+
|
||||
+import java.util.Arrays;
|
||||
+import java.util.stream.Stream;
|
||||
+import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
+import org.bukkit.Instrument;
|
||||
+import org.bukkit.craftbukkit.CraftSound;
|
||||
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.junit.jupiter.params.ParameterizedTest;
|
||||
+import org.junit.jupiter.params.provider.MethodSource;
|
||||
+
|
||||
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
+
|
||||
+class InstrumentSoundTest extends AbstractTestingBase {
|
||||
+
|
||||
+ static Stream<Instrument> bukkitInstruments() {
|
||||
+ return Arrays.stream(Instrument.values()).filter(i -> i.getSound() != null);
|
||||
+ }
|
||||
+
|
||||
+ @ParameterizedTest
|
||||
+ @MethodSource("bukkitInstruments")
|
||||
+ void checkInstrumentSound(final Instrument bukkit) {
|
||||
+ final NoteBlockInstrument nms = CraftBlockData.toNMS(bukkit, NoteBlockInstrument.class);
|
||||
+ assertEquals(nms.getSoundEvent(), CraftSound.bukkitToMinecraftHolder(bukkit.getSound()));
|
||||
+ }
|
||||
+}
|
||||
|
||||
Reference in New Issue
Block a user