mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 10:34:40 +00:00
Added support for StorageDrawers and Deep Storage API
This commit is contained in:
1 parent
275729d54e
commit
f44d846d32
16 files changed
+764
-56
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.inventory;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDrawerInventory extends ISidedInventory
|
||||
{
|
||||
/**
|
||||
* Gets a drawer's group slot index from an IInventory slot index.
|
||||
*
|
||||
* @param inventorySlot An IInventory slot index returned from getInventorySlot.
|
||||
*/
|
||||
int getDrawerSlot (int inventorySlot);
|
||||
|
||||
/**
|
||||
* Gets an IInventory slot index suitable for operations for the given type.
|
||||
*
|
||||
* @param drawerSlot The index of the drawer within its group.
|
||||
* @param type The type of IInventory slot to return an index for.
|
||||
*/
|
||||
int getInventorySlot (int drawerSlot, SlotType type);
|
||||
|
||||
/**
|
||||
* Gets the type associated with a given IInventory slot index.
|
||||
*
|
||||
* @param inventorySlot An IInventory slot index returned from getInventorySlot.
|
||||
*/
|
||||
SlotType getInventorySlotType (int inventorySlot);
|
||||
|
||||
boolean canInsertItem (int slot, ItemStack stack);
|
||||
|
||||
boolean canExtractItem (int slot, ItemStack stack);
|
||||
|
||||
boolean syncInventoryIfNeeded ();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.inventory;
|
||||
|
||||
/**
|
||||
* Classifies different IInventory slots according to how they should be used.
|
||||
*/
|
||||
public enum SlotType
|
||||
{
|
||||
/** An inventory slot for input-only operations; stack sizes artificially held low. */
|
||||
INPUT,
|
||||
|
||||
/** An inventory slot for output-only operations; stack sizes artificially held high. */
|
||||
OUTPUT;
|
||||
|
||||
public static final SlotType[] values = values();
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IDrawer
|
||||
{
|
||||
/**
|
||||
* Gets an ItemStack of size 1 representing the type, metadata, and tags of the stored items.
|
||||
* The returned ItemStack should not be modified for any reason. Make a copy if you need to store or modify it.
|
||||
*/
|
||||
ItemStack getStoredItemPrototype ();
|
||||
|
||||
/**
|
||||
* Gets an ItemStack initialized to the number of items stored in this drawer.
|
||||
* The returned ItemStack is guaranteed to be a new copy and can be used for any purpose. Does not affect drawer contents.
|
||||
*/
|
||||
ItemStack getStoredItemCopy ();
|
||||
|
||||
/**
|
||||
* Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced.
|
||||
*
|
||||
* @param itemPrototype An ItemStack representing the type, metadata, and tags of the item to store.
|
||||
* @param amount The amount to initialize the stored item count to.
|
||||
*/
|
||||
void setStoredItem (ItemStack itemPrototype, int amount);
|
||||
|
||||
/**
|
||||
* Gets the number of items stored in this drawer.
|
||||
*/
|
||||
int getStoredItemCount ();
|
||||
|
||||
/**
|
||||
* Sets the number of items stored in this drawer. Triggers syncing of inventories and client data.
|
||||
* Setting a drawer's count to 0 may also result in the item type being cleared, depending in implementation.
|
||||
*
|
||||
* @param amount The new amount of items stored in this drawer.
|
||||
*/
|
||||
void setStoredItemCount (int amount);
|
||||
|
||||
/**
|
||||
* Gets the maximum number of items that can be stored in this drawer.
|
||||
* This value will vary depending on the max stack size of the stored item type.
|
||||
*/
|
||||
int getMaxCapacity ();
|
||||
|
||||
/**
|
||||
* Gets the maximum number of items that could be stored in this drawer if it held the given item.
|
||||
*
|
||||
* @param itemPrototype The item type to query.
|
||||
*/
|
||||
int getMaxCapacity (ItemStack itemPrototype);
|
||||
|
||||
/**
|
||||
* Gets the number of items that could still be added to this drawer before it is full.
|
||||
*/
|
||||
int getRemainingCapacity ();
|
||||
|
||||
/**
|
||||
* Gets the max stack size of the item type stored in this drawer. Convenience method.
|
||||
*/
|
||||
int getStoredItemStackSize ();
|
||||
|
||||
/**
|
||||
* Gets whether or not an item of the given type and data can be stored in this drawer.
|
||||
*
|
||||
* Stack size and available capacity are not considered. For drawers that are not empty, this
|
||||
* method can allow ore-dictionary compatible items to be accepted into the drawer, as defined by what
|
||||
* the drawer considers to be an equivalent item.
|
||||
* For drawers that are empty, locking status is considered.
|
||||
*
|
||||
* @param itemPrototype An ItemStack representing the type, metadata, and tags of an item.
|
||||
*/
|
||||
boolean canItemBeStored (ItemStack itemPrototype);
|
||||
|
||||
/**
|
||||
* Gets whether or not an item of the given type and data can be extracted from this drawer.
|
||||
*
|
||||
* This is intended to allow outbound ore-dictionary conversions of compatible items, as defined by what
|
||||
* the drawer considers to be an equivalent item.
|
||||
*
|
||||
* @param itemPrototype An ItemStack representing the type, metadata, and tags of an item.
|
||||
*/
|
||||
boolean canItemBeExtracted (ItemStack itemPrototype);
|
||||
|
||||
/**
|
||||
* Gets whether or not the drawer has items.
|
||||
* A drawer set with an item type and 0 count is not considered empty.
|
||||
*/
|
||||
boolean isEmpty ();
|
||||
|
||||
/**
|
||||
* Gets auxiliary data that has been associated with this drawer.
|
||||
*
|
||||
* @param key The key used to identify the data.
|
||||
* @return An opaque object that was previously stored.
|
||||
*/
|
||||
Object getExtendedData (String key);
|
||||
|
||||
/**
|
||||
* Stores auxiliary data with this drawer, mainly for use in integration.
|
||||
* @param key The key to identify the data with.
|
||||
* @param data The data to store.
|
||||
*/
|
||||
void setExtendedData (String key, Object data);
|
||||
|
||||
void writeToNBT (NBTTagCompound tag);
|
||||
|
||||
void readFromNBT (NBTTagCompound tag);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
|
||||
public interface IDrawerGroup
|
||||
{
|
||||
/**
|
||||
* Gets the number of drawers contained within this group.
|
||||
*/
|
||||
int getDrawerCount ();
|
||||
|
||||
/**
|
||||
* Gets the drawer at the given slot within this group.
|
||||
*/
|
||||
IDrawer getDrawer (int slot);
|
||||
|
||||
/**
|
||||
* Gets whether the drawer in the given slot is usable.
|
||||
*/
|
||||
boolean isDrawerEnabled (int slot);
|
||||
|
||||
IDrawerInventory getDrawerInventory ();
|
||||
|
||||
boolean markDirtyIfNeeded ();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package powercrystals.minefactoryreloaded.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDeepStorageUnit
|
||||
{
|
||||
/**
|
||||
* @return A populated ItemStack with stackSize for the full amount of materials in the DSU.
|
||||
* May have a stackSize > getMaxStackSize(). May have a stackSize of 0 (indicating locked contents).
|
||||
*/
|
||||
ItemStack getStoredItemType();
|
||||
|
||||
/**
|
||||
* Sets the total amount of the item currently being stored, or zero if all items are to be removed.
|
||||
*/
|
||||
void setStoredItemCount(int amount);
|
||||
|
||||
/**
|
||||
* Sets the type of the stored item and initializes the number of stored items to amount.
|
||||
* Will overwrite any existing stored items.
|
||||
*/
|
||||
void setStoredItemType(ItemStack type, int amount);
|
||||
|
||||
/**
|
||||
* @return The maximum number of items the DSU can hold.
|
||||
* May change based on the current type stored.
|
||||
*/
|
||||
int getMaxStoredCount();
|
||||
}
|
||||
Reference in new issue
Block a user