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

Dehardcode Jukebox to allow modders to extend. #9167

Open
wants to merge 17 commits into
base: 1.19.x
Choose a base branch
from

Conversation

Waterpicker
Copy link

It not currently possible to extend JukeboxEntity and RecordItem logic for inserting a record into a jukebox only works specifically for the vanilla jukebox.

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ChampionAsh5357 ChampionAsh5357 added Feature This request implements a new feature. Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. 1.19 labels Nov 29, 2022
@ChampionAsh5357
Copy link
Contributor

What about jukebox behavior on parrots and allays? In addition, it feels sort of strange to only have a method of inserting and not getting/removing. Could you justify this?

@Waterpicker
Copy link
Author

Thank you for bringing this up. A similar hardcoded situation exists for their AIs. Correcting that now.

@Waterpicker
Copy link
Author

And updated for Allay and Parrots.

Copy link
Contributor

@ChampionAsh5357 ChampionAsh5357 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I still think there needs to be justification for not including a getter or a removing method for the record.

@Waterpicker
Copy link
Author

In general, I still think there needs to be justification for not including a getter or a removing method for the record.

I can do the getter easily. The removing method is a bit tricky. The 'remove' logic of the jukebox is heavily coupled with the onUse method. Aka I would have to cobble together a method from scratch.

Copy link
Contributor

@sciwhiz12 sciwhiz12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making some notes on formatting and javadocs, and one note about the naming of the extension interface. I'll leave it up to others (or my future self) to review the functioning of the PR.

@sciwhiz12 sciwhiz12 removed the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Nov 30, 2022
Copy link
Contributor

@ChampionAsh5357 ChampionAsh5357 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some comments above you didn't address. Additionally, for the ones you did, you should resolve the conversation.

@sciwhiz12 sciwhiz12 added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Dec 12, 2022
@sciwhiz12 sciwhiz12 removed their request for review December 16, 2022 12:25
@autoforge autoforge bot removed the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Dec 30, 2022
if (this instanceof JukeboxBlock)
return !state.getValue(JukeboxBlock.HAS_RECORD);
else
return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a convenience, perhaps this could delegate to getRecord() if not a vanilla jukebox?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, why would a boolean method delegate to #getRecord? Additionally, #getRecord already delegates to this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What it could do is call this.getRecord(), then return whether that returned an non-empty item. That way custom jukebox blocks that don't have a cached has-record value could only implement getRecord(), and have hasRecord() do the right thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of #getRecord would be called twice, then. If that strategy was adopted, then it would make no sense to have a #hasRecord at all and just implement the logic into a single method.

This is not to mention I can see cases where somebody decides to check the item and wonder why the client and server are desynced to some capacity. To implement that more complex logic, they would need to properly handle any tags which may change the logic. They would be overriding both methods anyways in that case. As such, I don't think it makes sense to do so.

Copy link
Contributor

@ChampionAsh5357 ChampionAsh5357 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a quick aside, how it JukeboxBlock#dropRecording, JukeboxBlock#getAnalogOutputSignal, JukeboxBlockEntity#playRecordTick, and the save methods in the JukeboxBlockEntity being considered when dealing with the new extension interface for #getRecord, because it seems like that still doesn't redirect to these new calls.

@autoforge autoforge bot added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Mar 15, 2023
@autoforge
Copy link

autoforge bot commented Mar 15, 2023

@Waterpicker, this pull request has conflicts, please resolve them for this PR to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.19 Feature This request implements a new feature. Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants