mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
couple more instrument/note fixes
This commit is contained in:
parent
9495a33cc9
commit
2ad5f6f66b
@ -1,13 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 9 Dec 2022 01:34:03 -0800
|
||||
Subject: [PATCH] fix Instrument enum
|
||||
Subject: [PATCH] fix Instruments
|
||||
|
||||
Add missing instrument enums
|
||||
fix some wrong javadocs
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Instrument.java b/src/main/java/org/bukkit/Instrument.java
|
||||
index 92194803bcdfbcfdb99567835906ce9219eabd04..654945bef4b71f87d86c204772bed259ce03451b 100644
|
||||
index 92194803bcdfbcfdb99567835906ce9219eabd04..ec36b0a685bbaf80ae563ad169a94a62298edd88 100644
|
||||
--- a/src/main/java/org/bukkit/Instrument.java
|
||||
+++ b/src/main/java/org/bukkit/Instrument.java
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public enum Instrument {
|
||||
|
||||
/**
|
||||
- * Piano is the standard instrument for a note block.
|
||||
+ * Piano (Harp) is the standard instrument for a note block.
|
||||
*/
|
||||
PIANO(0x0),
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ public enum Instrument {
|
||||
*/
|
||||
SNARE_DRUM(0x2),
|
||||
/**
|
||||
- * Sticks are normally played when a note block is on top of a glass
|
||||
+ * Sticks (Hat) are normally played when a note block is on top of a glass
|
||||
* block.
|
||||
*/
|
||||
STICKS(0x3),
|
||||
@@ -74,7 +74,44 @@ public enum Instrument {
|
||||
/**
|
||||
* Pling is normally played when a note block is on top of a glowstone block.
|
||||
@ -54,3 +74,18 @@ index 92194803bcdfbcfdb99567835906ce9219eabd04..654945bef4b71f87d86c204772bed259
|
||||
|
||||
private final byte type;
|
||||
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 1e27b9de47f111b9c000243214e22890e323f7fc..19995314b01f19c312efa2a4584ccfba2d700c52 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -393,9 +393,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
public void playNote(@NotNull Location loc, byte instrument, byte note);
|
||||
|
||||
/**
|
||||
- * Play a note for a player at a location. This requires a note block
|
||||
- * at the particular location (as far as the client is concerned). This
|
||||
- * will not work without a note block. This will not work with cake.
|
||||
+ * Play a note for a player at a location.
|
||||
*
|
||||
* @param loc The location of a note block
|
||||
* @param instrument The instrument
|
76
patches/server/0944-fix-Instruments.patch
Normal file
76
patches/server/0944-fix-Instruments.patch
Normal file
@ -0,0 +1,76 @@
|
||||
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 c628cbff6302e4b559964824fa61a1566b83cd9f..57ace8a66b3e5ea3f79462f02f0d7605e7410d98 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -766,62 +766,9 @@ 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;
|
||||
- }
|
||||
+ net.minecraft.world.level.block.state.properties.NoteBlockInstrument nms = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class); // Paper - really?
|
||||
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()));
|
||||
+ 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
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue
Block a user