Last active
May 15, 2017 17:22
-
-
Save loordgek/da24860d0c95c57c59abc237ebd14a90 to your computer and use it in GitHub Desktop.
IItemHanderV2
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
package loordgek.loordcore; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.NonNullList; | |
import javax.annotation.Nonnull; | |
public interface IItemHanderV2 { | |
enum Void{ | |
ALLAYS, | |
WHENFULL, | |
NOT | |
} | |
/** | |
* @return the content from this inventory. | |
* recommended is to return a {@link Collections.UnmodifiableList}. | |
*/ | |
List<ItemStack> getContent(); | |
default Void isSlotVoid(int slot){ | |
return Void.NOT; | |
} | |
/** | |
* @param slot Slot to check if it can accept the stack. | |
* @param stack ItemStack to check. | |
* @return if the inventory can accept the stack in slot. | |
*/ | |
boolean isStackVaildForSlot(int slot, ItemStack stack); | |
/** | |
* @return if the slot in the inventory can be extracted. | |
*/ | |
boolean canExtractFromSlot(int slot); | |
/** | |
* Returns the number of slots available | |
* | |
* @return The number of slots available | |
**/ | |
int getSlots(); | |
/** | |
* Returns the ItemStack in a given slot. | |
* | |
* The result's stack size may be greater than the itemstacks max size. | |
* | |
* If the result is ItemStack.EMPTY, then the slot is empty. | |
* | |
* THIS WILL NOT WORK SEE https://github.com/MinecraftForge/MinecraftForge/issues/3493 | |
* If the result is not null but the stack size is zero, then it represents | |
* an empty slot that will only accept* a specific itemstack. | |
* | |
* <p/> | |
* IMPORTANT: This ItemStack MUST NOT be modified. This method is not for | |
* altering an inventories contents. Any implementers who are able to detect | |
* modification through this method should throw an exception. | |
* <p/> | |
* SERIOUSLY: DO NOT MODIFY THE RETURNED ITEMSTACK | |
* | |
* @param slot Slot to query | |
* @return ItemStack in given slot. Can be ItemStack.EMPTY. | |
**/ | |
@Nonnull | |
ItemStack getStackInSlot(int slot); | |
/** | |
* Inserts an ItemStack into the given slot and return the remainder. | |
* The ItemStack should not be modified in this function! | |
* Note: This behaviour is subtly different from IFluidHandlers.fill() | |
* | |
* @param slot Slot to insert into. | |
* @param stack ItemStack to insert. | |
* @param simulate If true, the insertion is only simulated | |
* @return The remaining ItemStack that was not inserted (if the entire stack is accepted, then return ItemStack.EMPTY). | |
* May be the same as the input ItemStack if unchanged, otherwise a new ItemStack. | |
**/ | |
@Nonnull | |
ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate); | |
/** | |
* Extracts an ItemStack from the given slot. The returned value must be ItemStack.EMPTY | |
* if nothing is extracted, otherwise it's stack size must not be greater than amount or the | |
* itemstacks getMaxStackSize(). | |
* | |
* @param slot Slot to extract from. | |
* @param amount Amount to extract (may be greater than the current stacks max limit) | |
* @param simulate If true, the extraction is only simulated | |
* @return ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted | |
**/ | |
@Nonnull | |
ItemStack extractItem(int slot, int amount, boolean simulate); | |
/** | |
* Retrieves the maximum stack size allowed to exist in the given slot. | |
* | |
* @param slot Slot to query. | |
* @return The maximum stack size allowed in the slot. | |
*/ | |
int getSlotLimit(int slot); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment