src/main/java/com/github/klikli_dev/occultism/util/StorageUtil.java
/**
     * Clears the crafting matrix of the open container, if that container implements IStorageControllerContainer
     *
     * @param player          the player to clear the crafting matrix for.
     * @param sendStackUpdate true to resend the current stacks to the client.
     */
Clears the crafting matrix of the open container, if that container implements IStorageControllerContainer
@param player          the player to clear the crafting matrix for.
@param sendStackUpdate true to resend the current stacks to the client.
Clears the crafting matrix of the open container if that container implements IStorageControllerContainer @param player the player to clear the crafting matrix for . @param sendStackUpdate true to resend the current stacks to the client .
public static void clearOpenCraftingMatrix(ServerPlayerEntity player, boolean sendStackUpdate) {
        if (player.containerMenu instanceof IStorageControllerContainer) {
            IStorageControllerContainer container = (IStorageControllerContainer) player.containerMenu;
            CraftingInventory craftMatrix = container.getCraftMatrix();
            IStorageController storageController = container.getStorageController();
            if (storageController == null) {
                return;
            }
            for (int i = 0; i < 9; i++) {
                ItemStack stackInSlot = craftMatrix.getItem(i);
                if (stackInSlot.isEmpty()) {
                    continue;
                }
                int amountBeforeInsert = stackInSlot.getCount();
                int remainingAfterInsert = storageController.insertStack(stackInSlot.copy(), false);
                if (amountBeforeInsert == remainingAfterInsert) {
                    continue;
                }
                if (remainingAfterInsert == 0)
                    craftMatrix.setItem(i, ItemStack.EMPTY);
                else
                    craftMatrix.setItem(i,
                            ItemHandlerHelper.copyStackWithSize(stackInSlot, remainingAfterInsert));
            }
            if (sendStackUpdate) {
                OccultismPackets.sendTo(player, storageController.getMessageUpdateStacks());
                ((Container) container).broadcastChanges();
            }
        }
    }
public static void clearOpenCraftingMatrix ( ServerPlayerEntity player , boolean sendStackUpdate ) { if ( player . containerMenu instanceof IStorageControllerContainer ) { IStorageControllerContainer container = ( IStorageControllerContainer ) player . containerMenu ; CraftingInventory craftMatrix = container . getCraftMatrix ( ) ; IStorageController storageController = container . getStorageController ( ) ; if ( storageController == null ) { return ; } for ( int i = 0 ; i < 9 ; i ++ ) { ItemStack stackInSlot = craftMatrix . getItem ( i ) ; if ( stackInSlot . isEmpty ( ) ) { continue ; } int amountBeforeInsert = stackInSlot . getCount ( ) ; int remainingAfterInsert = storageController . insertStack ( stackInSlot . copy ( ) , false ) ; if ( amountBeforeInsert == remainingAfterInsert ) { continue ; } if ( remainingAfterInsert == 0 ) craftMatrix . setItem ( i , ItemStack . EMPTY ) ; else craftMatrix . setItem ( i , ItemHandlerHelper . copyStackWithSize ( stackInSlot , remainingAfterInsert ) ) ; } if ( sendStackUpdate ) { OccultismPackets . sendTo ( player , storageController . getMessageUpdateStacks ( ) ) ; ( ( Container ) container ) . broadcastChanges ( ) ; } } }
Clears the crafting matrix of the open container, if that container implements IStorageControllerContainer
 @param player          the player to clear the crafting matrix for.
Clears the crafting matrix of the open container if that container implements IStorageControllerContainer @param player the player to clear the crafting matrix for .
//ignore already cleared slots //move items into storage, and if storage is full, keep remainder in crafting matrix //finally if requested, send the updated storage controller contents to the player.