Fix being able to duplicate held block under rare circumstances. (Thanks Cybertoon)

Could be accomplished by (with default inventory), scroll to log, press G, scroll to dirt, middle click grass, grass will now be put in the empty slot. Hence it now appears twice in the inventory.
This commit is contained in:
UnknownShadow200 2017-10-28 14:21:05 +11:00
parent 663ac22524
commit 846ba75d3a

View File

@ -58,10 +58,15 @@ namespace ClassicalSharp.Mode {
inv.Selected = old; return;
}
// Try to replace same block or empty slots first.
// Try to replace same block
for (int i = 0; i < Inventory.BlocksPerRow; i++) {
if (inv[i] != old && inv[i] != Block.Air) continue;
if (inv[i] != old) continue;
inv.SelectedIndex = i; return;
}
// Try to replace empty slots
for (int i = 0; i < Inventory.BlocksPerRow; i++) {
if (inv[i] != Block.Air) continue;
inv[i] = old;
inv.SelectedIndex = i; return;
}