From 846ba75d3ae2ff91148709f122752399147d6ab4 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 28 Oct 2017 14:21:05 +1100 Subject: [PATCH] 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. --- ClassicalSharp/Mode/Creative.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ClassicalSharp/Mode/Creative.cs b/ClassicalSharp/Mode/Creative.cs index cb32c763f..93bcb8ec5 100644 --- a/ClassicalSharp/Mode/Creative.cs +++ b/ClassicalSharp/Mode/Creative.cs @@ -55,13 +55,18 @@ namespace ClassicalSharp.Mode { // Is the currently selected block an empty slot if (inv[inv.SelectedIndex] == Block.Air) { - inv.Selected = old; return; + 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; }