Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible enum request for NoteBlockInstrument #1941

Open
Lethosos opened this issue Feb 5, 2025 · 4 comments
Open

Extensible enum request for NoteBlockInstrument #1941

Lethosos opened this issue Feb 5, 2025 · 4 comments
Labels
enhancement New (or improvement to existing) feature or request

Comments

@Lethosos
Copy link

Lethosos commented Feb 5, 2025

A request to open up the enum NoteBlockInstrument to allow easy insertion of sounds to allow the use of the property component .instrument(NoteBlockInstrument) without hacky workarounds.

Redirected by request by IHH54 from the Discord.

@Lethosos Lethosos added the enhancement New (or improvement to existing) feature or request label Feb 5, 2025
@XFactHD
Copy link
Member

XFactHD commented Feb 5, 2025

Note Blocks keep track of their active NoteBlockInstrument in their blockstate. This means that adding new instruments modifies the possible set of values of a blockstate property which is just as much of a bad idea as adding new blockstate properties to existing blocks.

@ChampionAsh5357
Copy link
Contributor

The way I can imagine this happening is a block extension method that returns the sound event holder. We could either hook in beforehand to allow the control the instrument has for tuning or we could just hijack the custom head instrument since it explicitly checks the block beneath iirc.

@XFactHD
Copy link
Member

XFactHD commented Feb 6, 2025

Hijaking the custom head instrument isn't an option because instruments of type NoteblockInstrument.Type.MOB_HEAD and NoteblockInstrument.Type.CUSTOM are set by the block being placed on top of the note block and take precedence while all other sounds of type NoteblockInstrument.Type.BASE_BLOCK are set by the block being placed below the note block. Apart from that, non-"base block" instruments cannot be tuned, they use a fixed pitch.
One solution that already exists is to subscribe to NoteBlockEvent.Play and, if the block below the note block is the relevant one, cancel the event and play the sound manually in the event handler.

@ChampionAsh5357
Copy link
Contributor

I think using NoteBlockEvent$Play makes sense, but then comes the issue of if a note block is supposed to play when there is a block above and below. The instrument in the noteblock holds the last updated instrument, but the event would functionally run both sound events at once, which is fine if that's what people want, but it is also annoying. Additionally, if you would like tuning, you effectively need to reimplement all of the logic of the event again.

In that case, it would be more useful to add a method to $Play that plays a sound that handles tuning, precedence, and canceling if desired based on a state of a block in one of the orthogonally adjacent directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

No branches or pull requests

3 participants