File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
common/src/main/java/com/periut/chisel/gui Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -136,17 +136,20 @@ public void onClosed(PlayerEntity player) {
136136 ItemStack hand = player .getHandItems ().iterator ().next ();
137137 if (!hand .isOf (Chisel .chiselSupplier .get ()))
138138 {
139- ItemStack itemStack = ItemStack .EMPTY ;
140- // Prevents duplication
139+ ItemStack chiselStack = ItemStack .EMPTY ;
140+ int chiselSlot = -1 ;
141+
142+ // Find the chisel in inventory
141143 for (int i = 0 ; i < player .getInventory ().size (); i ++)
142144 {
143145 if (player .getInventory ().getStack (i ).isOf (Chisel .chiselSupplier .get ()))
144146 {
145- itemStack = player .getInventory ().getStack (i );
146- player .getInventory ().removeStack (i );
147+ chiselStack = player .getInventory ().getStack (i );
148+ chiselSlot = i ;
149+ break ; // Stop at the first chisel found
147150 }
148151 }
149- player .getInventory ().setStack (0 , itemStack );
152+ player .getInventory ().setStack (0 , chiselStack );
150153 }
151154 hand .getOrCreateNbt ().copyFrom (InventoryUtil .createCompound (inventory ));
152155 }
You can’t perform that action at this time.
0 commit comments