Skip to content

Add chests#1739

Merged
IntegratedQuantum merged 14 commits into
masterfrom
MnAChest
Aug 7, 2025
Merged

Add chests#1739
IntegratedQuantum merged 14 commits into
masterfrom
MnAChest

Conversation

@IntegratedQuantum

@IntegratedQuantum IntegratedQuantum commented Aug 5, 2025

Copy link
Copy Markdown
Member

Progress:

fixes #1060

@ikabod-kee

Copy link
Copy Markdown
Collaborator

What happens if the player gets out of render distance while the chest is still open?

I don't understand this one. How can the player reach a chest that far away?

@IntegratedQuantum

IntegratedQuantum commented Aug 5, 2025

Copy link
Copy Markdown
Member Author

The player can move while the chest is open. (gravity)

@ikabod-kee

Copy link
Copy Markdown
Collaborator

Just make it so the player can only access a chest from a limited range.

@Argmaster

Copy link
Copy Markdown
Collaborator

Just make it so the player can only access a chest from a limited range.

That is a very not "just" a feature.

@IntegratedQuantum

Copy link
Copy Markdown
Member Author

Yeah, that would be another 5 week project :​P

@ikabod-kee

Copy link
Copy Markdown
Collaborator

Okay, then it should boot the player out of the chest UI.

@IntegratedQuantum

Copy link
Copy Markdown
Member Author

Yep, you have named exactly the hard part :​P

@ikabod-kee

Copy link
Copy Markdown
Collaborator

How big should chests be, and what are the dimensions of their slots?

@codemob-dev

Copy link
Copy Markdown
Contributor

Yep, you have named exactly the hard part :​P

Does this cause problems with multiplayer if someone breaks a chest while you are using it?

@IntegratedQuantum

Copy link
Copy Markdown
Member Author

Yeah, right that falls into the same category.

@IntegratedQuantum IntegratedQuantum marked this pull request as ready for review August 6, 2025 18:04
@IntegratedQuantum

Copy link
Copy Markdown
Member Author

If anyone wants to review the code, now is the chance

@Argmaster

Copy link
Copy Markdown
Collaborator

I will, but I need 1-2h before I can sit to PC

@Argmaster

Argmaster commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

Alright, so (1) if you use /set to replace the chest block with something like stone ofc nothing drops, (2) if you place chest back it still contains what it contained.

When you do (1) and then leave world you get a crash:

thread 35976 panic: reached unreachable code
C:\Users\argma\dev\Cubyz4\src\chunk.zig:414:15: 0x7ff7303e8d2d in decreaseRefCount (Cubyzig_zcu.obj)
   self.deinit();
              ^
C:\Users\argma\dev\Cubyz4\src\server\server.zig:444:14: 0x7ff73043ce6f in start (Cubyzig_zcu.obj)
 defer deinit();
             ^
C:\Users\argma\dev\Cubyz4\compiler\zig\lib\std\Thread.zig:623:30: 0x7ff7303c1467 in entryFn (Cubyzig_zcu.obj)
                return callFn(f, self.fn_args);

There is no other special effects when you restart the game and replace the stone with the chest again, the chest it empty.

Probably an issue material?

Comment thread src/Inventory.zig
const inv = &inventories.items[@intFromEnum(invId)];
for(inv.inv._items) |*itemStack| {
if(itemStack.amount == 0) continue;
main.server.world.?.drop(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IMO the way items drop need some more love, now they just drop to the ground within volume of the chest, but that is probably a separate issue material, if you do agree it could be improved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, how would you suggest to do it instead?
And yeah, that's definitely a separate issue.

@Argmaster

Copy link
Copy Markdown
Collaborator

Eh, I kind of red through it, but I am to exhausted after work to focus enough to actually understand implications of crucial parts of the code. If you are willing to wait until Saturday for me to be able to think, I can review it then, its unlikely I will be less exhausted before. If you are confident that the code is OK, then I don't want to block this PR anymore, it mostly seems fine, considering that there are children issues listing known limitations of the implementation.

@IntegratedQuantum

Copy link
Copy Markdown
Member Author

About worldedit, it seems that it doesn't remove the block entity properly.
I will try to find a fix for this here, however I think we may need to rethink some things with how omnipresent the inventory synchronization mutex is becoming.

If you are confident that the code is OK, then I don't want to block this PR anymore

Yeah I'm confident that it works, but I'll do some more testing just to be sure.
Also you don't need to feel obligated to review my code. It sure is nice to have a second pair of eyes looking at things, but you shouldn't need to look at my code all night when you are already exhausted from work.

…y mutex on blueprint pasting, this is needed for the chests right now.
@IntegratedQuantum

Copy link
Copy Markdown
Member Author

I'm not really happy with the fix, but it works for now. I definitely need to redesign how the inventory system interacts with block updates at some point. It really is too involved for now.

@IntegratedQuantum IntegratedQuantum merged commit aa53722 into master Aug 7, 2025
1 check passed
@IntegratedQuantum IntegratedQuantum mentioned this pull request Aug 14, 2025
5 tasks
@IntegratedQuantum IntegratedQuantum deleted the MnAChest branch January 16, 2026 20:34
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.

Add chests

4 participants