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

Open container from type & some fixes #2504

Open
wants to merge 8 commits into
base: api-11
Choose a base branch
from

Conversation

MrHell228
Copy link
Contributor

@MrHell228 MrHell228 commented May 15, 2024

SpongeAPI | Sponge

@@ -64,7 +64,7 @@ public interface Chest extends NameableCarrierBlockEntity {
* @return The attachment type of this chest.
*/
default Value.Mutable<ChestAttachmentType> attachmentType() {
return this.requireValue(Keys.CHEST_ATTACHMENT_TYPE).asMutable();
return this.block().requireValue(Keys.CHEST_ATTACHMENT_TYPE).asMutable();
Copy link
Member

Choose a reason for hiding this comment

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

I know this is subtle, but why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because Keys.CHEST_ATTACHMENT_TYPE is registered for BlockState, not BlockEntity. And currently this method simply throw an exception

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that we have code (SpongeDataHolder#impl$delegateDataHolder) that could make this work on BlockEntity too.
e.g.
https://github.com/SpongePowered/Sponge/blob/api-12/src/main/java/org/spongepowered/common/world/server/SpongeServerLocation.java#L280

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's cool. I guess it would be better to use this method then

Copy link
Contributor Author

@MrHell228 MrHell228 Sep 13, 2024

Choose a reason for hiding this comment

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

Reverted change in Chest file, in impl made BlockEntity delegate DataHolder to its #block() and #block().type().
Also reverted Container#type() change since it's breaking (and in api-12 Faithcaio fixed this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants