mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Implement fluid item capabilities without item swapping
This commit is contained in:
1 parent
6f1a44a405
commit
eb6b3ea228
15 files changed
+437
-227
No files matched your search
@@ -98,9 +98,10 @@ public class ItemHandlerHelper
|
||||
* This is equivalent to the behaviour of a player picking up an item.
|
||||
* Note: This function stacks items without subtypes with different metadata together.
|
||||
*/
|
||||
public static ItemStack insertItemStacked(IItemHandler inventory, ItemStack stack, boolean simulate)
|
||||
@Nonnull
|
||||
public static ItemStack insertItemStacked(IItemHandler inventory, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if (inventory == null || stack == null)
|
||||
if (inventory == null || stack.func_190926_b())
|
||||
return stack;
|
||||
|
||||
// not stackable -> just insert into a new slot
|
||||
@@ -119,7 +120,7 @@ public class ItemHandlerHelper
|
||||
{
|
||||
stack = inventory.insertItem(i, stack, simulate);
|
||||
|
||||
if (stack == null)
|
||||
if (stack.func_190926_b())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -127,15 +128,15 @@ public class ItemHandlerHelper
|
||||
}
|
||||
|
||||
// insert remainder into empty slots
|
||||
if (stack != null)
|
||||
if (!stack.func_190926_b())
|
||||
{
|
||||
// find empty slot
|
||||
for (int i = 0; i < sizeInventory; i++)
|
||||
{
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i).func_190926_b())
|
||||
{
|
||||
stack = inventory.insertItem(i, stack, simulate);
|
||||
if (stack == null)
|
||||
if (stack.func_190926_b())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user