Skip to content

Conversation

@natri0
Copy link
Contributor

@natri0 natri0 commented Dec 30, 2024

Added an article about implementing Inventory in block entities. Some stuff (e.g. ImplementedInventory) copied over from wiki's "tutorial:inventory".

Tutorial covers using the ImplementedInventory & implementing SidedInventory, as well as some basic user interaction (inserting items on right-click).

@natri0 natri0 requested a review from a team as a code owner December 30, 2024 20:50
@netlify
Copy link

netlify bot commented Dec 30, 2024

Deploy Preview for nimble-elf-d9d491 ready!

Name Link
🔨 Latest commit 5305509
🔍 Latest deploy log https://app.netlify.com/projects/nimble-elf-d9d491/deploys/693cc2f97591b30009b3cfdb
😎 Deploy Preview https://deploy-preview-246--nimble-elf-d9d491.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@IMB11 IMB11 marked this pull request as draft December 30, 2024 20:52
@IMB11 IMB11 added new-content A new page or set of pages todo:verify This needs to be reviewed labels Dec 30, 2024
@its-miroma

This comment was marked as outdated.

@IMB11

This comment was marked as outdated.

@natri0

This comment was marked as outdated.

@natri0 natri0 marked this pull request as ready for review January 16, 2025 08:59
Copy link
Contributor

@JR1811 JR1811 left a comment

Choose a reason for hiding this comment

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

This looks pretty good so far!

I think it would be interesting to also expand this page to explain how storing things like ItemStacks, Fluids, Energy, and so on, could be stored and retrieved. Also on that note, an example on how to use the Fabric Transfer API might be useful for that too. Or this could get its extra page, if necessary.


@[code transcludeWith=:::3](@/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java)

The `DuplicatorBlock` should now have a `getTicker` method that returns a reference to `DuplicatorBlockEntity::tick`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need a ticking functionality here?
From what I can see, it's just copying the slot and is returning it asap.

So this could be handled in the block interaction method in the custom block class, right?

Or do something like duplicating the slot every 10 ticks and then storing it in the inventory, until it's being retrieved or the stack has hit its max size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JR1811 changed it to only output one item every second.

@its-miroma its-miroma mentioned this pull request Jan 29, 2025
9 tasks
@its-miroma

This comment was marked as outdated.

@its-miroma its-miroma marked this pull request as draft February 28, 2025 16:42
@natri0

This comment was marked as outdated.

natri0 added 4 commits May 14, 2025 17:00
Basically the same content as the article on the fabric wiki: https://wiki.fabricmc.net/tutorial:inventory

Uses the same `ImplementedInventory` class as that one to implement `Inventory` on the custom block entity

Now updated for latest!
Maybe we should get a Checkstyle rule to allow comments after blocks? It's making me do stuff like this:

// :::1
if (condition) {
    // code...
}

// :::1

...which is IMO kinda ugly
some wording stuff and also redid the DuplicatorBlockEntity ticker so that it has a reason to exist.
@natri0
Copy link
Contributor Author

natri0 commented May 14, 2025

rebased to latest main and applied changes requested by @its-miroma.

Also on that note, an example on how to use the Fabric Transfer API might be useful for that too. Or this could get its extra page, if necessary.

@JR1811 i think a separate page (maybe "under" this one like Block Entities -> Block Entity Renderers) and a note about the existence of Fabric Transfer API would be better? don't want it to get too long/complex with marginally related parts all in the same article.

@natri0 natri0 marked this pull request as ready for review May 14, 2025 15:35
@natri0 natri0 requested a review from its-miroma May 14, 2025 15:35
Copy link
Member

@its-miroma its-miroma left a comment

Choose a reason for hiding this comment

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

lint fixes

natri0 and others added 3 commits May 15, 2025 09:21
only one missing is .mp4 -> .webm, need to reencode.

Co-authored-by: Miroma <136986257+its-miroma@users.noreply.github.com>
Co-authored-by: Miroma <136986257+its-miroma@users.noreply.github.com>
@natri0 natri0 requested a review from its-miroma May 20, 2025 06:41
@its-miroma its-miroma requested a review from JR1811 May 20, 2025 12:22
Copy link
Contributor

@JR1811 JR1811 left a comment

Choose a reason for hiding this comment

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

Small changes, nothing major 👍🏻

"develop.blocks.blockstates": "Block States",
"develop.blocks.block-entities": "Block Entities",
"develop.blocks.block-entity-renderer": "Block Entity Renderers",
"develop.blocks.inventory": "Block Inventories",
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the address to reflect the entry being listed in Blocks > Block Entity instead of Blocks

(For more information, see requested changes in develop.ts file).


private final DefaultedList<ItemStack> items = DefaultedList.ofSize(1, ItemStack.EMPTY);

// :::3
Copy link
Contributor

Choose a reason for hiding this comment

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

Reference comments are displayed in the code view?

grafik

@its-miroma
Copy link
Member

its-miroma commented Sep 23, 2025

Hi @natri0, sorry for the long wait, do you think you could address the last few reviews, and check if anything changed in 1.21.10, so we can get this merged? Thank you!

@its-miroma its-miroma added the priority:low This is nice to have, but it can wait a little label Sep 23, 2025
@its-miroma its-miroma marked this pull request as draft October 6, 2025 07:33
cassiancc and others added 2 commits December 12, 2025 20:32
Co-authored-by: Tenneb22 <126985099+Tenneb22@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-content A new page or set of pages priority:low This is nice to have, but it can wait a little todo:verify This needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants