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
base: 1.19.x
Are you sure you want to change the base?
Conversation
|
patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch
Outdated
Show resolved
Hide resolved
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? |
Thank you for bringing this up. A similar hardcoded situation exists for their AIs. Correcting that now. |
And updated for Allay and Parrots. |
There was a problem hiding this 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.
patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
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. |
There was a problem hiding this 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.
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukebox.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/net/minecraftforge/common/extensions/IForgeJukeboxBlock.java
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch
Outdated
Show resolved
Hide resolved
patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch
Outdated
Show resolved
Hide resolved
if (this instanceof JukeboxBlock) | ||
return !state.getValue(JukeboxBlock.HAS_RECORD); | ||
else | ||
return false; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
@Waterpicker, this pull request has conflicts, please resolve them for this PR to move forward. |
It not currently possible to extend JukeboxEntity and RecordItem logic for inserting a record into a jukebox only works specifically for the vanilla jukebox.