-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1678bb3
commit fb076b5
Showing
10 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.petrolpark.destroy.util; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
import net.minecraft.world.item.ItemStack; | ||
|
||
public class ItemHelper { | ||
|
||
/** | ||
* Copies an Item in an ItemStack a given number of times. | ||
* If the number exceeds the maximum stack size of the Item, it is split into multiple Item Stacks. | ||
*/ | ||
public static Collection<ItemStack> withCount(ItemStack stack, int count) { | ||
int maxStackSize = stack.getMaxStackSize(); | ||
List<ItemStack> stacks = new ArrayList<>(1 + (count / maxStackSize)); | ||
for (int i = 0; i < count / maxStackSize; i++) stacks.add(stack.copyWithCount(maxStackSize)); | ||
stacks.add(stack.copyWithCount(count % maxStackSize)); | ||
return stacks; | ||
}; | ||
}; |