From 89f41485d3174c29131c094dd34418a79355b446 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sat, 3 Dec 2016 20:24:41 +0100 Subject: [PATCH] Update Storage Drawers API --- CHANGELOG.md | 2 +- .../api/event/DrawerPopulatedEvent.java | 2 +- .../api/inventory/IDrawerInventory.java | 34 ------------------ .../api/inventory/IInventoryAdapter.java | 15 -------- .../api/inventory/SlotType.java | 18 ---------- .../api/inventory/package-info.java | 5 --- .../api/pack/IPackBlockFactory.java | 6 ++-- .../api/registry/IIngredientHandler.java | 3 ++ .../api/registry/IRecipeHandler.java | 4 +-- .../api/storage/EnumBasicDrawer.java | 3 ++ .../storagedrawers/api/storage/IDrawer.java | 36 ++++++------------- .../api/storage/IDrawerGroup.java | 4 --- .../api/storage/IDrawerGroupInteractive.java | 5 ++- .../api/storage/IFractionalDrawer.java | 2 +- .../api/storage/ISmartGroup.java | 6 ++-- .../api/storage/attribute/IProtectable.java | 4 --- .../api/storage/attribute/IQuantifiable.java | 16 +++++++++ .../api/storage/attribute/ISealable.java | 1 - .../api/storage/attribute/IShroudable.java | 1 - .../externalstorage/StorageItemDrawer.java | 4 +-- 20 files changed, 52 insertions(+), 119 deletions(-) delete mode 100755 src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java delete mode 100755 src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java delete mode 100755 src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java delete mode 100755 src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/package-info.java create mode 100755 src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IQuantifiable.java diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe5d9fd4..0db7c3412 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 1.3 - Port to Minecraft 1.11 (raoulvdberge, way2muchnoise) -- Removed RF support (raoulvdberge) +- Removed RF support, use Forge Energy instead (raoulvdberge) - Removed IC2 support (raoulvdberge) - Removed MCMultiPart support (will be re-added as soon as MCMultiPart for MC 1.11 is available) (raoulvdberge) diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java index dad1cf4e1..f934cea45 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java @@ -6,7 +6,7 @@ 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. - *

+ * * This event is also called when the drawer is changed to empty. */ public class DrawerPopulatedEvent extends Event { diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java deleted file mode 100755 index d0e1f412a..000000000 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java +++ /dev/null @@ -1,34 +0,0 @@ -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(); -} diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java deleted file mode 100755 index 0c7a4510d..000000000 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java +++ /dev/null @@ -1,15 +0,0 @@ -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(); -} diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java deleted file mode 100755 index 3c3a23f20..000000000 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java +++ /dev/null @@ -1,18 +0,0 @@ -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(); -} diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/package-info.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/package-info.java deleted file mode 100755 index f0b6e9b10..000000000 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/inventory/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -@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; \ No newline at end of file diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java index 1d9e9c715..1d48cbeb1 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java @@ -23,11 +23,13 @@ public interface IPackBlockFactory /** * Hides block from NEI if NEI is active. + *

+ * Registers block metadata from an initialized DataResolver with Storage Drawers. */ //void hideBlock (String blockID); /** * Registers block metadata from an initialized DataResolver with Storage Drawers. - */ -//void registerResolver (IExtendedDataResolver resolver); + */ + //void registerResolver (IExtendedDataResolver resolver); //} diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java index 714bc6dfe..c2f5d1064 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java @@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.api.registry; import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; + /** * 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 @@ -14,5 +16,6 @@ public interface IIngredientHandler { * @param object An ingredient object. * @return An ItemStack for the given ingredient. */ + @Nonnull ItemStack getItemStack(Object object); } diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java index 9cb3e8b9e..00fe63a32 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java @@ -13,7 +13,7 @@ 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. - *

+ * * 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}. @@ -25,7 +25,7 @@ public interface IRecipeHandler { * 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. - *

+ * * 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}. diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/EnumBasicDrawer.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/EnumBasicDrawer.java index 544faa276..245872644 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/EnumBasicDrawer.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/EnumBasicDrawer.java @@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.api.storage; import net.minecraft.util.IStringSerializable; +import javax.annotation.Nonnull; + public enum EnumBasicDrawer implements IDrawerGeometry, IStringSerializable { FULL1(0, 1, false, "full1", "fulldrawers1"), FULL2(1, 2, false, "full2", "fulldrawers2"), @@ -55,6 +57,7 @@ public enum EnumBasicDrawer implements IDrawerGeometry, IStringSerializable { } @Override + @Nonnull public String getName() { return name; } diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java index 6a729b118..89b0f737e 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java @@ -3,37 +3,24 @@ package com.jaquadro.minecraft.storagedrawers.api.storage; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import javax.annotation.Nonnull; + 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. */ + @Nonnull 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. - * @deprecated setStoredItem may redirect its set to another IDrawer, so use setStoredItemRedir instead. - */ - @Deprecated - void setStoredItem(ItemStack itemPrototype, int amount); - - /** - * 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. + * @param amount The amount to initialize the stored item count to. * @return The IDrawer actually set with the prototype. Some drawer groups can redirect a set operation to another member. */ - IDrawer setStoredItemRedir(ItemStack itemPrototype, int amount); + IDrawer setStoredItem(@Nonnull ItemStack itemPrototype, int amount); /** * Gets the number of items stored in this drawer. @@ -59,7 +46,7 @@ public interface IDrawer { * * @param itemPrototype The item type to query. */ - int getMaxCapacity(ItemStack itemPrototype); + int getMaxCapacity(@Nonnull ItemStack itemPrototype); /** * Gets the number of items that could still be added to this drawer before it is full. @@ -73,7 +60,7 @@ public interface IDrawer { /** * 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. @@ -81,17 +68,17 @@ public interface IDrawer { * * @param itemPrototype An ItemStack representing the type, metadata, and tags of an item. */ - boolean canItemBeStored(ItemStack itemPrototype); + boolean canItemBeStored(@Nonnull 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); + boolean canItemBeExtracted(@Nonnull ItemStack itemPrototype); /** * Gets whether or not the drawer has items. @@ -109,8 +96,7 @@ public interface IDrawer { /** * Stores auxiliary data with this drawer, mainly for use in integration. - * - * @param key The key to identify the data with. + * @param key The key to identify the data with. * @param data The data to store. */ void setExtendedData(String key, Object data); diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java index 0136f745f..90f54707e 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java @@ -1,7 +1,5 @@ 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. @@ -23,7 +21,5 @@ public interface IDrawerGroup { */ boolean isDrawerEnabled(int slot); - IDrawerInventory getDrawerInventory(); - boolean markDirtyIfNeeded(); } diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java index fe23227a0..14535e8e9 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java @@ -3,10 +3,13 @@ package com.jaquadro.minecraft.storagedrawers.api.storage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; + public interface IDrawerGroupInteractive extends IDrawerGroup { + @Nonnull ItemStack takeItemsFromSlot(int slot, int count); - int putItemsIntoSlot(int slot, ItemStack stack, int count); + int putItemsIntoSlot(int slot, @Nonnull ItemStack stack, int count); int interactPutCurrentItemIntoSlot(int slot, EntityPlayer player); diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java index e9aae63fc..ba47d9652 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java @@ -7,7 +7,7 @@ package com.jaquadro.minecraft.storagedrawers.api.storage; public interface IFractionalDrawer extends IDrawer { /** * Gets the storage ratio between the held item and the most compressed item within the drawer group. - *

+ * * 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. */ diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java index ad6a13a83..7d2f50f1f 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java @@ -2,16 +2,18 @@ package com.jaquadro.minecraft.storagedrawers.api.storage; import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; + 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 enumerateDrawersForInsertion(ItemStack stack, boolean strict); + Iterable enumerateDrawersForInsertion(@Nonnull 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 enumerateDrawersForExtraction(ItemStack stack, boolean strict); + Iterable enumerateDrawersForExtraction(@Nonnull ItemStack stack, boolean strict); } diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java index bc21a2efe..0bea99d6c 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java @@ -13,28 +13,24 @@ public interface IProtectable { /** * 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(); /** * Gets the lockable interface if it exists on the protected drawer. - * * @return A lockable interface, or null if lockable is not supported. */ ILockableContainer getLockableContainer(); /** * 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); diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IQuantifiable.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IQuantifiable.java new file mode 100755 index 000000000..c212264d7 --- /dev/null +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IQuantifiable.java @@ -0,0 +1,16 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +public interface IQuantifiable { + /** + * Gets whether or not the drawer has the quantified attribute. + * The quantified attribute instructs the drawer to render its numerical quantity. + */ + boolean isShowingQuantity(); + + /** + * Sets whether or not the drawer is currently quantified. + * + * @return false if the operation is not supported, true otherwise. + */ + boolean setIsShowingQuantity(boolean state); +} diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ISealable.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ISealable.java index 5248f0d52..eb9a951d8 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ISealable.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ISealable.java @@ -9,7 +9,6 @@ public interface ISealable { /** * Sets whether or not the drawer is currently sealed. - * * @return false if the operation is not supported, true otherwise. */ boolean setIsSealed(boolean state); diff --git a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java index cacf752e4..025420cfd 100755 --- a/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java +++ b/src/main/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java @@ -9,7 +9,6 @@ public interface IShroudable { /** * Sets whether or not the drawer is currently shrouded. - * * @return false if the operation is not supported, true otherwise. */ boolean setIsShrouded(boolean state); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/tile/externalstorage/StorageItemDrawer.java b/src/main/java/com/raoulvdberge/refinedstorage/tile/externalstorage/StorageItemDrawer.java index be8d2a435..e0573983a 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/tile/externalstorage/StorageItemDrawer.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/tile/externalstorage/StorageItemDrawer.java @@ -58,7 +58,7 @@ public class StorageItemDrawer extends StorageItemExternal { public static NonNullList getStacks(IDrawer drawer) { if (!drawer.isEmpty() && drawer.getStoredItemCount() > 0) { - return NonNullList.withSize(1, drawer.getStoredItemCopy()); + return NonNullList.withSize(1, ItemHandlerHelper.copyStackWithSize(drawer.getStoredItemPrototype(), drawer.getStoredItemCount())); } return RSUtils.emptyNonNullList(); @@ -73,7 +73,7 @@ public class StorageItemDrawer extends StorageItemExternal { if (!simulate && remainingSpace > 0) { if (drawer.isEmpty()) { - drawer.setStoredItemRedir(stack, inserted); + drawer.setStoredItem(stack, inserted); } else { drawer.setStoredItemCount(stored + inserted); }