mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-04 03:37:59 -04:00
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:
parent
6de4924146
commit
2202cd01da
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user