mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Add IItemHandler capability
Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
This commit is contained in:
1 parent
b8238e7f22
commit
a1e41f5464
20 files changed
+1299
-1
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package net.minecraftforge.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemHandler
|
||||
{
|
||||
/**
|
||||
* 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 null, then the slot is empty.
|
||||
* 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. May be null.
|
||||
**/
|
||||
ItemStack getStackInSlot(int slot);
|
||||
|
||||
/**
|
||||
* Inserts an ItemStack into the given slot and return the remainder.
|
||||
* 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 null)
|
||||
**/
|
||||
ItemStack insertItem(int slot, ItemStack stack, boolean simulate);
|
||||
|
||||
/**
|
||||
* Extracts an ItemStack from the given slot. The returned value must be null
|
||||
* 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 null, if nothing can be extracted
|
||||
**/
|
||||
ItemStack extractItem(int slot, int amount, boolean simulate);
|
||||
}
|
||||
Reference in new issue
Block a user