generated from EpimorphicPioneers/ArchLoom-TemplateMod
-
Notifications
You must be signed in to change notification settings - Fork 5
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
6906174
commit 0845a58
Showing
3 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/main/java/com/epimorphismmc/gregiceng/api/misc/UnlimitedItemStackTransfer.java
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,70 @@ | ||
package com.epimorphismmc.gregiceng.api.misc; | ||
|
||
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer; | ||
import com.lowdragmc.lowdraglib.side.item.ItemTransferHelper; | ||
import net.minecraft.core.NonNullList; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class UnlimitedItemStackTransfer extends ItemStackTransfer { | ||
|
||
public UnlimitedItemStackTransfer() { | ||
} | ||
|
||
public UnlimitedItemStackTransfer(int size) { | ||
super(size); | ||
} | ||
|
||
public UnlimitedItemStackTransfer(NonNullList<ItemStack> stacks) { | ||
super(stacks); | ||
} | ||
|
||
public UnlimitedItemStackTransfer(ItemStack stack) { | ||
super(stack); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ItemStack extractItem(int slot, int amount, boolean simulate, boolean notifyChanges) { | ||
if (amount == 0) | ||
return ItemStack.EMPTY; | ||
|
||
validateSlotIndex(slot); | ||
|
||
ItemStack existing = this.stacks.get(slot); | ||
|
||
if (existing.isEmpty()) | ||
return ItemStack.EMPTY; | ||
|
||
if (existing.getCount() <= amount) { | ||
if (!simulate) { | ||
this.stacks.set(slot, ItemStack.EMPTY); | ||
if (notifyChanges) { | ||
onContentsChanged(slot); | ||
} | ||
return existing; | ||
} else { | ||
return existing.copy(); | ||
} | ||
} else { | ||
if (!simulate) { | ||
this.stacks.set(slot, ItemTransferHelper.copyStackWithSize(existing, existing.getCount() - amount)); | ||
if (notifyChanges) { | ||
onContentsChanged(slot); | ||
} | ||
} | ||
|
||
return ItemTransferHelper.copyStackWithSize(existing, amount); | ||
} | ||
} | ||
|
||
@Override | ||
public int getSlotLimit(int slot) { | ||
return Integer.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
protected int getStackLimit(int slot, @NotNull ItemStack stack) { | ||
return Integer.MAX_VALUE; | ||
} | ||
} |
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