Use a hash for the tool seed to ensure that server and client side have the same seed.

This does mean that the same source materials always result in the same tool, but I guess that is just a minor change.

fixes #879
This commit is contained in:
IntegratedQuantum 2025-01-02 20:04:47 +01:00
parent 6de4924146
commit 2202cd01da

View File

@ -1436,7 +1436,15 @@ fn update(self: Inventory) void {
}
}
if(nonEmpty) {
self._items[self._items.len - 1].item = Item{.tool = Tool.initFromCraftingGrid(availableItems, @intCast(std.time.nanoTimestamp() & 0xffffffff))}; // TODO
var hash = std.hash.Crc32.init();
for(availableItems) |item| {
if(item != null) {
hash.update(item.?.id);
} else {
hash.update("none");
}
}
self._items[self._items.len - 1].item = Item{.tool = Tool.initFromCraftingGrid(availableItems, hash.final())};
self._items[self._items.len - 1].amount = 1;
}
}