Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/Inventory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2132,25 +2132,6 @@ pub fn canHold(self: Inventory, sourceStack: ItemStack) bool {
return false;
}

// TODO: Remove after #480
pub fn loadFromZon(self: Inventory, zon: ZonElement) void {
for(self._items, 0..) |*stack, i| {
stack.clear();
var buf: [1024]u8 = undefined;
const stackZon = zon.getChild(buf[0..std.fmt.printInt(&buf, i, 10, .lower, .{})]);
if(stackZon == .object) {
stack.item = Item.init(stackZon) catch |err| {
const msg = stackZon.toStringEfficient(main.stackAllocator, "");
defer main.stackAllocator.free(msg);
std.log.err("Couldn't find item {s}: {s}", .{msg, @errorName(err)});
stack.clear();
continue;
};
stack.amount = stackZon.get(u16, "amount", 0);
}
}
}

pub fn toBytes(self: Inventory, writer: *BinaryWriter) void {
writer.writeVarInt(u32, @intCast(self._items.len));
for(self._items) |stack| {
Expand Down
1 change: 0 additions & 1 deletion src/game.zig
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ pub const Player = struct { // MARK: Player

fn loadFrom(zon: ZonElement) void {
super.loadFrom(zon);
inventory.loadFromZon(zon.getChild("inventory"));
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this can be removed just like that?
If understand this correctly this would break loading the initial player inventory from the server.

Copy link
Contributor Author

@codemob-dev codemob-dev Oct 9, 2025

Choose a reason for hiding this comment

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

Is the inventory still sent as zon from the server?

Copy link
Member

Choose a reason for hiding this comment

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

Try it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I played as much as I could and it is saving the inventory correctly, even in multiplayer.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, where is the inventory then loaded from network on the client side? Can we maybe even remove the parent function as well?

}

pub fn setPosBlocking(newPos: Vec3d) void {
Expand Down
Loading
Loading