Created
May 2, 2021 11:48
-
-
Save mmodrow/d638225329dd2ad13c6419d65b463799 to your computer and use it in GitHub Desktop.
Takes an integer and translates it into <#> stack + <#> singles, useful to calculate Minecraft item amounts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AsStacks{ | |
param([int]$count, [int]$size = 64, [string]$stackLabel = "Stacks") | |
[float]$divisor = [float]([float]$count / [float]$size) | |
$floatingPointDigits = $divisor % 1 | |
$stacks = $divisor - $floatingPointDigits | |
$singles = [int]($floatingPointDigits * $size) | |
Write-Host ("$stacks $stackLabel + $singles") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment