Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions paper-api/src/main/java/org/bukkit/block/BlockType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.function.Consumer;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
import org.bukkit.Instrument;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.Registry;
Expand Down Expand Up @@ -2805,4 +2806,12 @@ private static <B extends BlockType> B getBlockType(@KeyPattern.Value final Stri
* @return false if this block never has collision, true if it <b>might</b> have collision
*/
boolean hasCollision();

/**
* Gets the {@link Instrument} associated with this block.
* This determines the instrument sound that would be played if a Note Block were placed directly above or below this block.
*
* @return the associated instrument
*/
Instrument getInstrument();
}
11 changes: 10 additions & 1 deletion paper-api/src/main/java/org/bukkit/block/data/BlockData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.block.data;

import org.bukkit.Color;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
Expand All @@ -13,7 +14,6 @@
import org.bukkit.block.structure.Mirror;
import org.bukkit.block.structure.StructureRotation;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -323,4 +323,13 @@ default float getDestroySpeed(final @NotNull ItemStack itemStack) {
* @return true if block is replaceable
*/
boolean isReplaceable();

/**
* Gets the {@link Instrument} associated with this block.
* This determines the instrument sound that would be played if a Note Block were placed directly above or below this block.
*
* @return the associated instrument
*/
@NotNull
Instrument getInstrument();
Comment thread
Lulu13022002 marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.phys.BlockHitResult;
import org.bukkit.Instrument;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.World;
Expand Down Expand Up @@ -251,4 +253,10 @@ public boolean hasCollision() {
return this.getHandle().hasCollision;
}
// Paper end - hasCollision API

@Override
public Instrument getInstrument() {
NoteBlockInstrument instrument = this.getHandle().defaultBlockState().instrument();
return CraftBlockData.fromVanilla(instrument, Instrument.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.apache.commons.lang3.mutable.MutableDouble;
import org.bukkit.Color;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundGroup;
Expand Down Expand Up @@ -656,4 +658,9 @@ public boolean isRandomlyTicked() {
public boolean isReplaceable() {
return this.state.canBeReplaced();
}

@Override
public Instrument getInstrument() {
return fromVanilla(this.state.instrument(), Instrument.class);
}
}