Remove support for MFR Deep Storage Unit API, add StorageDrawers API

This commit is contained in:
Raoul Van den Berge
2016-06-06 22:30:01 +02:00
parent 6ffeca4c54
commit 94d01a1ac7
53 changed files with 1101 additions and 105 deletions

View File

@@ -0,0 +1,26 @@
package com.jaquadro.minecraft.storagedrawers.api;
import com.jaquadro.minecraft.storagedrawers.api.config.IUserConfig;
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry;
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
public interface IStorageDrawersApi {
/**
* Recipe handlers are used to make custom recipes compatible with compacting drawers.
*/
IRecipeHandlerRegistry recipeHandlerRegistry();
IRenderRegistry renderRegistry();
IWailaRegistry wailaRegistry();
//IPackBlockFactory packFactory ();
/**
* User-managed configuration for the Storage Drawers mod.
*/
IUserConfig userConfig();
//void registerStandardPackRecipes (IExtendedDataResolver resolver);
}

View File

@@ -0,0 +1,28 @@
package com.jaquadro.minecraft.storagedrawers.api;
/**
* Entry point for the public API.
*/
public class StorageDrawersApi {
private static IStorageDrawersApi instance;
public static final String VERSION = "1.7.10-1.2.0";
/**
* API entry point.
*
* @return The {@link IStorageDrawersApi} instance or null if the API or Storage Drawers is unavailable.
*/
public static IStorageDrawersApi instance() {
if (instance == null) {
try {
Class classApi = Class.forName("com.jaquadro.minecraft.storagedrawers.core.Api");
instance = (IStorageDrawersApi) classApi.getField("instance").get(null);
} catch (Throwable t) {
return null;
}
}
return instance;
}
}

View File

@@ -0,0 +1,20 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
public interface IAddonConfig {
/**
* Gets whether the user has configured a preference for addon packs to hide their blocks and items from Vanilla
* creative tabs.
*/
boolean showAddonItemsNEI();
/**
* Gets whether the user has configured a preference for addon packs to hide their blocks and items from NEI.
*/
boolean showAddonItemsVanilla();
/**
* Gets whether the user has configured a preference for addon packs to provide their blocks and items through
* their own vanilla tab.
*/
boolean addonItemsUseSeparateTab();
}

View File

@@ -0,0 +1,13 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration;
public interface IBlockConfig {
String getBlockConfigName(BlockConfiguration blockConfig);
boolean isBlockEnabled(String blockConfigName);
int getBlockRecipeOutput(String blockConfigName);
int getBaseCapacity(String blockConfigName);
}

View File

@@ -0,0 +1,5 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
public interface IIntegrationConfig {
boolean isRefinedRelocationEnabled();
}

View File

@@ -0,0 +1,21 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
/**
* The main hub for user-managed mod configuration.
*/
public interface IUserConfig {
/**
* Configuration options related to third party addon packs for Storage Drawers.
*/
IAddonConfig addonConfig();
/**
* Configuration options related to individual blocks.
*/
IBlockConfig blockConfig();
/**
* Configuration options related to third party mod integration.
*/
IIntegrationConfig integrationConfig();
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|config", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.config;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,18 @@
package com.jaquadro.minecraft.storagedrawers.api.event;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* This event is called when a drawer has been bound to a new item. This is
* and opportunity for mods to cache extended data with the drawer.
* <p>
* This event is also called when the drawer is changed to empty.
*/
public class DrawerPopulatedEvent extends Event {
public final IDrawer drawer;
public DrawerPopulatedEvent(IDrawer drawer) {
this.drawer = drawer;
}
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|event", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.event;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,34 @@
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();
}

View File

@@ -0,0 +1,15 @@
package com.jaquadro.minecraft.storagedrawers.api.inventory;
import net.minecraft.item.ItemStack;
public interface IInventoryAdapter {
ItemStack getInventoryStack(SlotType slotType);
void setInStack(ItemStack stack);
void setOutStack(ItemStack stack);
void syncInventory();
boolean syncInventoryIfNeeded();
}

View File

@@ -0,0 +1,18 @@
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();
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|inventory", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.inventory;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,49 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
import com.jaquadro.minecraft.storagedrawers.api.storage.EnumBasicDrawer;
public enum BlockConfiguration {
BasicFull1(BlockType.Drawers, EnumBasicDrawer.FULL1),
BasicFull2(BlockType.Drawers, EnumBasicDrawer.FULL2),
BasicFull4(BlockType.Drawers, EnumBasicDrawer.FULL4),
BasicHalf2(BlockType.Drawers, EnumBasicDrawer.HALF2),
BasicHalf4(BlockType.Drawers, EnumBasicDrawer.HALF4),
SortingFull1(BlockType.DrawersSorting, EnumBasicDrawer.FULL1),
SortingFull2(BlockType.DrawersSorting, EnumBasicDrawer.FULL2),
SortingFull4(BlockType.DrawersSorting, EnumBasicDrawer.FULL4),
SortingHalf2(BlockType.DrawersSorting, EnumBasicDrawer.HALF2),
SortingHalf4(BlockType.DrawersSorting, EnumBasicDrawer.HALF4),
Trim(BlockType.Trim, null),
TrimSorting(BlockType.TrimSorting, null);
private final BlockType type;
private final EnumBasicDrawer drawer;
BlockConfiguration(BlockType type, EnumBasicDrawer drawer) {
this.type = type;
this.drawer = drawer;
}
public BlockType getBlockType() {
return type;
}
public int getDrawerCount() {
return (drawer != null) ? drawer.getDrawerCount() : 0;
}
public boolean isHalfDepth() {
return (drawer != null) && drawer.isHalfDepth();
}
public static BlockConfiguration by(BlockType type, EnumBasicDrawer drawer) {
for (BlockConfiguration config : values()) {
if (config.type == type && config.drawer == drawer)
return config;
}
return null;
}
}

View File

@@ -0,0 +1,8 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum BlockType {
Drawers,
DrawersSorting,
Trim,
TrimSorting
}

View File

@@ -0,0 +1,63 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
public class ExtendedDataResolver extends StandardDataResolver implements IExtendedDataResolver
{
private Block[] planks = new Block[16];
private int[] planksMeta = new int[16];
private Block[] slabs = new Block[16];
private int[] slabsMeta = new int [16];
public ExtendedDataResolver (String modID, String[] unlocalizedNames) {
super(modID, unlocalizedNames);
}
public ExtendedDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
super(modID, unlocalizedNames, creativeTab);
}
@Override
public Block getBlock (BlockConfiguration blockConfig) {
return null;
}
@Override
public Block getPlankBlock (int meta) {
return planks[meta];
}
@Override
public Block getSlabBlock (int meta) {
return slabs[meta];
}
@Override
public int getPlankMeta (int meta) {
return planksMeta[meta];
}
@Override
public int getSlabMeta (int meta) {
return slabsMeta[meta];
}
public void init () {
}
protected void setPlankSlab (int meta, Block plank, int plankMeta, Block slab, int slabMeta) {
if (plank != null) {
planks[meta] = plank;
planksMeta[meta] = plankMeta;
}
if (slab != null) {
slabs[meta] = slab;
slabsMeta[meta] = slabMeta;
}
}
}
*/

View File

@@ -0,0 +1,17 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
public interface IExtendedDataResolver extends IPackDataResolver
{
Block getBlock (BlockConfiguration blockConfig);
Block getPlankBlock (int meta);
Block getSlabBlock (int meta);
int getPlankMeta (int meta);
int getSlabMeta (int meta);
}
*/

View File

@@ -0,0 +1,7 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;/*package com.jaquadro.minecraft.storagedrawers.api.pack;
public interface IPackBlock
{
IPackDataResolver getDataResolver ();
}
*/

View File

@@ -0,0 +1,33 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
public interface IPackBlockFactory
{
Block createBlock (BlockConfiguration blockConfig, IPackDataResolver dataResolver);
/**
* Registers a factory-produced block with an appropriate item class.
*/
//void registerBlock (Block block, String name);
/**
* Associates a sorting variant of a block with its corresponding basic block.
* <p>
* Hides block from NEI if NEI is active.
* <p>
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
//void bindSortingBlock (Block basicBlock, Block sortingBlock);
/**
* Hides block from NEI if NEI is active.
*/
//void hideBlock (String blockID);
/**
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
//void registerResolver (IExtendedDataResolver resolver);
//}

View File

@@ -0,0 +1,19 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
/*
import net.minecraft.creativetab.CreativeTabs;
public interface IPackDataResolver
{
String getPackModID ();
String getBlockName (BlockConfiguration blockConfig);
CreativeTabs getCreativeTabs (BlockType type);
boolean isValidMetaValue (int meta);
String getUnlocalizedName (int meta);
String getTexturePath (TextureType type, int meta);
}
*/

View File

@@ -0,0 +1,108 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
/*
import net.minecraft.creativetab.CreativeTabs;
public class StandardDataResolver implements IPackDataResolver
{
private String modID;
private String[] unlocalizedNames;
private CreativeTabs creativeTab;
public StandardDataResolver (String modID, String[] unlocalizedNames) {
this.modID = modID;
this.unlocalizedNames = unlocalizedNames;
}
public StandardDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
this(modID, unlocalizedNames);
this.creativeTab = creativeTab;
}
@Override
public String getPackModID () {
return modID;
}
protected String makeBlockName (String name) {
return getPackModID().toLowerCase() + "." + name;
}
@Override
public String getBlockName (BlockConfiguration blockConfig) {
switch (blockConfig.getBlockType()) {
case Drawers:
case DrawersSorting:
if (blockConfig.getDrawerCount() == 1)
return makeBlockName("fullDrawers1");
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return makeBlockName("fullDrawers2");
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
return makeBlockName("fullDrawers4");
if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth())
return makeBlockName("halfDrawers2");
if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth())
return makeBlockName("halfDrawers4");
break;
case Trim:
case TrimSorting:
return makeBlockName("trim");
}
return null;
}
@Override
public CreativeTabs getCreativeTabs (BlockType type) {
return creativeTab;
}
@Override
public boolean isValidMetaValue (int meta) {
if (meta < 0 || meta >= unlocalizedNames.length)
return false;
return unlocalizedNames != null && unlocalizedNames[meta] != null;
}
@Override
public String getUnlocalizedName (int meta) {
if (!isValidMetaValue(meta))
return null;
return unlocalizedNames[meta];
}
protected String getBaseTexturePath () {
return getPackModID() + ":";
}
protected String getTextureMetaName (int meta) {
return getUnlocalizedName(meta);
}
@Override
public String getTexturePath (TextureType type, int meta) {
switch (type) {
case Front1:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_1";
case Front2:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_2";
case Front4:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_4";
case Side:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side";
case SideSort:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_sort";
case SideVSplit:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_v";
case SideHSplit:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_h";
case TrimBorder:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_trim";
case TrimBlock:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side";
default:
return "";
}
}
}
*/

View File

@@ -0,0 +1,13 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum TextureType {
Front1,
Front2,
Front4,
Side,
SideSort,
SideVSplit,
SideHSplit,
TrimBorder,
TrimBlock
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|pack", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.pack;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,4 @@
@API(owner = "StorageDrawers", provides = "StorageDrawersAPI", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,18 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import net.minecraft.item.ItemStack;
/**
* Ingredient handlers are used to get ItemStacks from ingredients in custom IRecipe implementations. If you have
* registered an IRecipeHandler that returns lists of objects that aren't ItemStacks, then you will need to
* implement an ingredient handler for those objects.
*/
public interface IIngredientHandler {
/**
* Gets an ItemStack from an object that represents an ingredient in an IRecipe.
*
* @param object An ingredient object.
* @return An ItemStack for the given ingredient.
*/
ItemStack getItemStack(Object object);
}

View File

@@ -0,0 +1,35 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import net.minecraft.item.crafting.IRecipe;
import java.util.List;
/**
* Recipe handlers are used by compacting drawers to find more-compressed forms of blocks and items. If your recipe
* to craft compressed items is a custom IRecipe implementation, you will need to register a handler for it.
*/
public interface IRecipeHandler {
/**
* Get the recipe ingredient list as an array of objects (usually used for shaped recipes).
* If your array does not contain ItemStack objects, you will need to register an {@link IIngredientHandler} to
* get an ItemStack from them.
* <p>
* If you would prefer to return a List, return null in this method and implement {@link #getInputAsList}.
*
* @param recipe An instance of a custom {@link IRecipe}.
* @return An array of ItemStacks or objects with a registered {@link IIngredientHandler}.
*/
Object[] getInputAsArray(IRecipe recipe);
/**
* Get the recipe ingredient list as a list of objects (usually used for shapeless recipes).
* If your list does not contain ItemStack objects, you will need to register an {@link IIngredientHandler} to
* get an ItemStack from them.
* <p>
* If you would prefer to return an array, return null in this method and implement {@link #getInputAsArray}.
*
* @param recipe An instance of a custom {@link IRecipe}.
* @return A list of ItemStacks or objects with a registered {@link IIngredientHandler}.
*/
List getInputAsList(IRecipe recipe);
}

View File

@@ -0,0 +1,11 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
public interface IRecipeHandlerRegistry {
void registerRecipeHandler(Class clazz, IRecipeHandler handler);
void registerIngredientHandler(Class clazz, IIngredientHandler handler);
IRecipeHandler getRecipeHandler(Class clazz);
IIngredientHandler getIngredientHandler(Class clazz);
}

View File

@@ -0,0 +1,7 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
public interface IRenderRegistry {
void registerPreLabelRenderHandler(IRenderLabel renderHandler);
}

View File

@@ -0,0 +1,5 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
public interface IWailaRegistry {
void registerTooltipHandler(IWailaTooltipHandler handler);
}

View File

@@ -0,0 +1,7 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
public interface IWailaTooltipHandler {
String transformItemName(IDrawer drawer, String defaultName);
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|registry", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,8 @@
package com.jaquadro.minecraft.storagedrawers.api.render;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import net.minecraft.tileentity.TileEntity;
public interface IRenderLabel {
void render(TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime);
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|render", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.render;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,12 @@
package com.jaquadro.minecraft.storagedrawers.api.security;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable;
import com.mojang.authlib.GameProfile;
public interface ISecurityProvider {
String getProviderID();
boolean hasOwnership(GameProfile profile, IProtectable target);
boolean hasAccess(GameProfile profile, IProtectable target);
}

View File

@@ -0,0 +1,68 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.util.IStringSerializable;
public enum EnumBasicDrawer implements IDrawerGeometry, IStringSerializable {
FULL1(0, 1, false, "full1", "fulldrawers1"),
FULL2(1, 2, false, "full2", "fulldrawers2"),
FULL4(2, 4, false, "full4", "fulldrawers4"),
HALF2(3, 2, true, "half2", "halfdrawers2"),
HALF4(4, 4, true, "half4", "halfdrawers4");
private static final EnumBasicDrawer[] META_LOOKUP;
private final int meta;
private final int drawerCount;
private final boolean halfDepth;
private final String name;
private final String unlocalizedName;
EnumBasicDrawer(int meta, int drawerCount, boolean halfDepth, String name, String unlocalizedName) {
this.meta = meta;
this.name = name;
this.drawerCount = drawerCount;
this.halfDepth = halfDepth;
this.unlocalizedName = unlocalizedName;
}
public int getMetadata() {
return meta;
}
@Override
public int getDrawerCount() {
return drawerCount;
}
@Override
public boolean isHalfDepth() {
return halfDepth;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public static EnumBasicDrawer byMetadata(int meta) {
if (meta < 0 || meta >= META_LOOKUP.length)
meta = 0;
return META_LOOKUP[meta];
}
@Override
public String toString() {
return getName();
}
@Override
public String getName() {
return name;
}
static {
META_LOOKUP = new EnumBasicDrawer[values().length];
for (EnumBasicDrawer upgrade : values()) {
META_LOOKUP[upgrade.getMetadata()] = upgrade;
}
}
}

View File

@@ -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.
* <p>
* 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.
* <p>
* 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);
}

View File

@@ -0,0 +1,7 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
public interface IDrawerGeometry {
boolean isHalfDepth();
int getDrawerCount();
}

View File

@@ -0,0 +1,24 @@
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();
}

View File

@@ -0,0 +1,14 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IDrawerGroupInteractive extends IDrawerGroup {
ItemStack takeItemsFromSlot(int slot, int count);
int putItemsIntoSlot(int slot, ItemStack stack, int count);
int interactPutCurrentItemIntoSlot(int slot, EntityPlayer player);
int interactPutCurrentInventoryIntoSlot(int slot, EntityPlayer player);
}

View File

@@ -0,0 +1,27 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
/**
* Represents a drawer with items that are a fractional component of another item within the drawer group. Compacting
* Drawers are a primary example of this drawer type.
*/
public interface IFractionalDrawer extends IDrawer {
/**
* Gets the storage ratio between the held item and the most compressed item within the drawer group.
* <p>
* For example, most ingots have a conversion rate of 9 compared to metal blocks, and nuggets a rate of 81.
* Actual conversion rates are implementation-defined.
*/
int getConversionRate();
/**
* Gets the number of items left in the drawer if the maximum number of equivalent compressed items had been removed.
* The equivalency is determined by the next compression tier, and not necessarily the conversion rate.
*/
int getStoredItemRemainder();
/**
* Gets whether or not the stored item represents the smallest granularity of material that can be stored within
* the drawer group.
*/
boolean isSmallestUnit();
}

View File

@@ -0,0 +1,4 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
public interface INetworked {
}

View File

@@ -0,0 +1,9 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
public interface IPriorityGroup {
/**
* Gets the list of available drawer slots in priority order.
*/
int[] getAccessibleDrawerSlots();
}

View File

@@ -0,0 +1,17 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.item.ItemStack;
public interface ISmartGroup {
/**
* Gets a lazy enumeration of all slots that will accept at least one item of the given stack, ordered by
* insertion preference.
*/
Iterable<Integer> enumerateDrawersForInsertion(ItemStack stack, boolean strict);
/**
* Gets a lazy enumeration of all slots that will provide at least one item of the given stack, ordered by
* extraction preference.
*/
Iterable<Integer> enumerateDrawersForExtraction(ItemStack stack, boolean strict);
}

View File

@@ -0,0 +1,20 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface ILockable {
/**
* Gets whether or not a drawer or group is locked for the given lock attribute.
*/
boolean isLocked(LockAttribute attr);
/**
* Gets whether or not the lock state can be changed for the given lock attribute.
* If this method returns false, isLocked may still return true.
*/
boolean canLock(LockAttribute attr);
/**
* Sets the lock state of a drawer or group for the given lock attribute.
* If canLock returns false, this is a no-op.
*/
void setLocked(LockAttribute attr, boolean isLocked);
}

View File

@@ -0,0 +1,33 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
import java.util.UUID;
public interface IProtectable {
/**
* Gets the owner of the drawer, or null if there is no owner.
*/
UUID getOwner();
/**
* Sets the owner of the drawer. Set to null to set no owner.
*
* @return false if the operation is not supported, true otherwise.
*/
boolean setOwner(UUID owner);
/**
* Gets the provider managing security for the target.
*
* @return null to use the default provider, which enforces strict owner access.
*/
ISecurityProvider getSecurityProvider();
/**
* Sets the provider managing security for the target. Set to null for default provider.
*
* @return false if the operation is not supported, true otherwise.
*/
boolean setSecurityProvider(ISecurityProvider provder);
}

View File

@@ -0,0 +1,16 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface ISealable {
/**
* Gets whether or not the drawer has the sealed attribute.
* A sealed drawer cannot be interacted with, and when broken will retain all of its items and upgrades.
*/
boolean isSealed();
/**
* Sets whether or not the drawer is currently sealed.
*
* @return false if the operation is not supported, true otherwise.
*/
boolean setIsSealed(boolean state);
}

View File

@@ -0,0 +1,16 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface IShroudable {
/**
* Gets whether or not the drawer has the shrouded attribute.
* The shrouded attribute instructs the drawer to not render its item label.
*/
boolean isShrouded();
/**
* Sets whether or not the drawer is currently shrouded.
*
* @return false if the operation is not supported, true otherwise.
*/
boolean setIsShrouded(boolean state);
}

View File

@@ -0,0 +1,8 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface IVoidable {
/**
* Gets whether or not the drawer has a voiding attribute.
*/
boolean isVoid();
}

View File

@@ -0,0 +1,36 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import java.util.EnumSet;
public enum LockAttribute {
LOCK_POPULATED,
LOCK_EMPTY;
public int getFlagValue() {
return 1 << ordinal();
}
public static int getBitfield(EnumSet<LockAttribute> attributes) {
int value = 0;
if (attributes == null)
return value;
for (LockAttribute attr : attributes)
value |= attr.getFlagValue();
return value;
}
public static EnumSet<LockAttribute> getEnumSet(int bitfield) {
if (bitfield == 0)
return null;
EnumSet<LockAttribute> set = EnumSet.noneOf(LockAttribute.class);
for (LockAttribute attr : values()) {
if ((bitfield & attr.getFlagValue()) != 0)
set.add(attr);
}
return set;
}
}

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|storage-attribute", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -0,0 +1,5 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|storage", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.storage;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import net.minecraftforge.fml.common.API;

View File

@@ -1,25 +0,0 @@
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().
*/
ItemStack getStoredItemType();
/**
* Sets the total amount of the item currently being stored, or zero if it wants to remove all items.
*/
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.
*/
int getMaxStoredCount();
}

View File

@@ -8,7 +8,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageUtils;
import refinedstorage.api.RefinedStorageCapabilities;
@@ -45,13 +44,6 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
@Override
public void addItems(List<ItemStack> items) {
IDeepStorageUnit storageUnit = getStorageUnit();
if (storageUnit != null) {
if (storageUnit.getStoredItemType() != null && storageUnit.getStoredItemType().getItem() != null) {
items.add(storageUnit.getStoredItemType().copy());
}
} else {
IItemHandler handler = getItemHandler();
if (handler != null) {
@@ -62,47 +54,22 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
}
}
}
}
@Override
public ItemStack push(ItemStack stack, boolean simulate) {
if (ModeFilter.respectsMode(filters, this, compare, stack)) {
IDeepStorageUnit storageUnit = getStorageUnit();
// @todo: fix push for deep storage units
if (storageUnit != null) {
if (storageUnit.getStoredItemType() == null) {
storageUnit.setStoredItemType(stack.copy(), stack.stackSize);
} else {
storageUnit.setStoredItemCount(storageUnit.getStoredItemType().stackSize + stack.stackSize);
}
} else {
IItemHandler handler = getItemHandler();
if (handler != null) {
return ItemHandlerHelper.insertItem(handler, stack, simulate);
}
}
}
return stack;
}
@Override
public ItemStack take(ItemStack stack, int size, int flags) {
IDeepStorageUnit storageUnit = getStorageUnit();
if (storageUnit != null) {
if (storageUnit.getStoredItemType() != null && RefinedStorageUtils.compareStackNoQuantity(storageUnit.getStoredItemType(), stack)) {
size = Math.min(size, storageUnit.getStoredItemType().stackSize);
ItemStack took = ItemHandlerHelper.copyStackWithSize(storageUnit.getStoredItemType(), size);
storageUnit.setStoredItemCount(storageUnit.getStoredItemType().stackSize - size);
return took;
}
} else {
IItemHandler handler = getItemHandler();
if (handler != null) {
@@ -120,15 +87,10 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
}
}
}
}
return null;
}
public IDeepStorageUnit getStorageUnit() {
return getFacingTile() instanceof IDeepStorageUnit ? (IDeepStorageUnit) getFacingTile() : null;
}
public IItemHandler getItemHandler() {
return RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
}
@@ -258,11 +220,6 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
return stored;
}
IDeepStorageUnit storageUnit = getStorageUnit();
if (storageUnit != null) {
return storageUnit.getStoredItemType() == null ? 0 : storageUnit.getStoredItemType().stackSize;
} else {
IItemHandler handler = getItemHandler();
if (handler != null) {
@@ -279,21 +236,14 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
return 0;
}
}
}
@Override
public int getCapacity() {
IDeepStorageUnit storageUnit = getStorageUnit();
if (storageUnit != null) {
return storageUnit.getMaxStoredCount();
} else {
IItemHandler handler = getItemHandler();
if (handler != null) {
return handler.getSlots() * 64;
}
}
return 0;
}