mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix note block sound property on player heads (#9158)
This commit is contained in:
parent
41ea1348fd
commit
be21be4029
3 changed files with 21 additions and 19 deletions
|
@ -194,14 +194,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * recipes.
|
+ * recipes.
|
||||||
*
|
*
|
||||||
- * This includes it's name, description and other visible tags.
|
- * This includes it's name, description and other visible tags.
|
||||||
+ * This includes its name, description and other visible tags.
|
|
||||||
*
|
|
||||||
- * @return a AdvancementDisplay object, or null if not set.
|
|
||||||
+ * @return the display info
|
+ * @return the display info
|
||||||
*/
|
+ */
|
||||||
- @Nullable
|
+ @Nullable
|
||||||
- AdvancementDisplay getDisplay();
|
|
||||||
+ @org.jetbrains.annotations.Nullable
|
|
||||||
+ io.papermc.paper.advancement.AdvancementDisplay getDisplay();
|
+ io.papermc.paper.advancement.AdvancementDisplay getDisplay();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
@ -210,7 +205,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * completes the advancement. Will return the same as
|
+ * completes the advancement. Will return the same as
|
||||||
+ * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an
|
+ * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an
|
||||||
+ * {@link io.papermc.paper.advancement.AdvancementDisplay} is present.
|
+ * {@link io.papermc.paper.advancement.AdvancementDisplay} is present.
|
||||||
+ *
|
*
|
||||||
|
- * @return a AdvancementDisplay object, or null if not set.
|
||||||
+ * @return the display name
|
+ * @return the display name
|
||||||
+ * @see io.papermc.paper.advancement.AdvancementDisplay#displayName()
|
+ * @see io.papermc.paper.advancement.AdvancementDisplay#displayName()
|
||||||
+ */
|
+ */
|
||||||
|
@ -220,8 +216,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Gets the parent advancement, if any.
|
+ * Gets the parent advancement, if any.
|
||||||
+ *
|
+ *
|
||||||
+ * @return the parent advancement
|
+ * @return the parent advancement
|
||||||
+ */
|
*/
|
||||||
+ @org.jetbrains.annotations.Nullable
|
@Nullable
|
||||||
|
- AdvancementDisplay getDisplay();
|
||||||
+ Advancement getParent();
|
+ Advancement getParent();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
|
|
@ -9,7 +9,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/event/block/NotePlayEvent.java
|
--- a/src/main/java/org/bukkit/event/block/NotePlayEvent.java
|
||||||
+++ b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
|
+++ b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
|
||||||
@@ -0,0 +0,0 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
|
@@ -0,0 +0,0 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
|
||||||
|
|
||||||
|
/**
|
||||||
* Overrides the {@link Instrument} to be used.
|
* Overrides the {@link Instrument} to be used.
|
||||||
|
+ * <p>
|
||||||
|
+ * Only works when the note block isn't under a player head.
|
||||||
|
+ * For this specific case the 'note_block_sound' property of the
|
||||||
|
+ * player head state takes the priority.
|
||||||
*
|
*
|
||||||
* @param instrument the Instrument. Has no effect if null.
|
* @param instrument the Instrument. Has no effect if null.
|
||||||
- * @deprecated no effect on newer Minecraft versions
|
- * @deprecated no effect on newer Minecraft versions
|
||||||
|
|
|
@ -28,14 +28,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
world.gameEvent(entity, GameEvent.NOTE_BLOCK_PLAY, pos);
|
world.gameEvent(entity, GameEvent.NOTE_BLOCK_PLAY, pos);
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public class NoteBlock extends Block {
|
@@ -0,0 +0,0 @@ public class NoteBlock extends Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) {
|
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) {
|
||||||
|
NoteBlockInstrument blockpropertyinstrument = (NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT);
|
||||||
+ // Paper start - move NotePlayEvent call to fix instrument/note changes
|
+ // Paper start - move NotePlayEvent call to fix instrument/note changes
|
||||||
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, state.getValue(INSTRUMENT), state.getValue(NOTE));
|
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, blockpropertyinstrument, state.getValue(NOTE));
|
||||||
+ if (event.isCancelled()) return false;
|
+ if (event.isCancelled()) return false;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
NoteBlockInstrument blockpropertyinstrument = (NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT);
|
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
if (blockpropertyinstrument.isTunable()) {
|
if (blockpropertyinstrument.isTunable()) {
|
||||||
|
@ -45,11 +44,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
f = (float) Math.pow(2.0D, (double) (k - 12) / 12.0D);
|
f = (float) Math.pow(2.0D, (double) (k - 12) / 12.0D);
|
||||||
world.addParticle(ParticleTypes.NOTE, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.2D, (double) pos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
|
world.addParticle(ParticleTypes.NOTE, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.2D, (double) pos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
|
||||||
@@ -0,0 +0,0 @@ public class NoteBlock extends Block {
|
@@ -0,0 +0,0 @@ public class NoteBlock extends Block {
|
||||||
holder = blockpropertyinstrument.getSoundEvent();
|
|
||||||
|
holder = Holder.direct(SoundEvent.createVariableRangeEvent(minecraftkey));
|
||||||
|
} else {
|
||||||
|
- holder = blockpropertyinstrument.getSoundEvent();
|
||||||
|
+ holder = org.bukkit.craftbukkit.block.data.CraftBlockData.toNMS(event.getInstrument(), NoteBlockInstrument.class).getSoundEvent(); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
- world.playSeededSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, holder, SoundSource.RECORDS, 3.0F, f, world.random.nextLong());
|
world.playSeededSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, holder, SoundSource.RECORDS, 3.0F, f, world.random.nextLong());
|
||||||
+ world.playSeededSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, org.bukkit.craftbukkit.block.data.CraftBlockData.toNMS(event.getInstrument(), NoteBlockInstrument.class).getSoundEvent(), SoundSource.RECORDS, 3.0F, f, world.random.nextLong()); // Paper
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue