Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Created May 2, 2021 11:48
Show Gist options
  • Save mmodrow/d638225329dd2ad13c6419d65b463799 to your computer and use it in GitHub Desktop.
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.
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