-
Notifications
You must be signed in to change notification settings - Fork 234
Block Inventory article #246
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for nimble-elf-d9d491 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
JR1811
left a comment
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.
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`. |
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.
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.
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.
@JR1811 changed it to only output one item every second.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
|
rebased to latest main and applied changes requested by @its-miroma.
@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. |
its-miroma
left a comment
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.
lint fixes
reference/latest/src/main/java/com/example/docs/block/entity/ModBlockEntities.java
Outdated
Show resolved
Hide resolved
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>
JR1811
left a comment
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.
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", |
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.
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 |
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.
|
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! |
reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java
Show resolved
Hide resolved
Co-authored-by: Tenneb22 <126985099+Tenneb22@users.noreply.github.com>

Added an article about implementing
Inventoryin block entities. Some stuff (e.g.ImplementedInventory) copied over from wiki's "tutorial:inventory".Tutorial covers using the
ImplementedInventory& implementingSidedInventory, as well as some basic user interaction (inserting items on right-click).