diff --git a/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java index 8df01dc..588d337 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java @@ -31,6 +31,8 @@ public class StorageDrawers public static final String MOD_VERSION = "1.2.0"; public static final String SOURCE_PATH = "com.jaquadro.minecraft.storagedrawers."; + public static final Api api = new Api(); + public static final ModBlocks blocks = new ModBlocks(); public static final ModItems items = new ModItems(); public static final ModRecipes recipes = new ModRecipes(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java b/src/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java new file mode 100644 index 0000000..6343ada --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java @@ -0,0 +1,11 @@ +package com.jaquadro.minecraft.storagedrawers.api; + +import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry; + +public interface IStorageDrawersApi +{ + /** + * Recipe handlers are used to make custom recipes compatible with compacting drawers. + */ + IRecipeHandlerRegistry recipeHandlerRegistry (); +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java b/src/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java new file mode 100644 index 0000000..70a1517 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java @@ -0,0 +1,28 @@ +package com.jaquadro.minecraft.storagedrawers.api; + +/** + * Entry point for the public API. + */ +public class StorageDrawersApi +{ + private static IStorageDrawersApi instance; + + /** + * 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; + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java b/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java index cb8299c..998d185 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java @@ -9,7 +9,7 @@ public interface IDrawerInventory extends ISidedInventory * * @param inventorySlot An IInventory slot index returned from getInventorySlot. */ - public int getDrawerSlot (int inventorySlot); + int getDrawerSlot (int inventorySlot); /** * Gets an IInventory slot index suitable for operations for the given type. @@ -17,12 +17,12 @@ public interface IDrawerInventory extends ISidedInventory * @param drawerSlot The index of the drawer within its group. * @param type The type of IInventory slot to return an index for. */ - public int getInventorySlot (int drawerSlot, SlotType type); + 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. */ - public SlotType getInventorySlotType (int inventorySlot); + SlotType getInventorySlotType (int inventorySlot); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java b/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java index 5ed5a6c..e069d50 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java +++ b/src/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java @@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack; public interface IInventoryAdapter { - public ItemStack getInventoryStack (SlotType slotType); + ItemStack getInventoryStack (SlotType slotType); - public void syncInventory (); + void syncInventory (); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java b/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java index e28502a..259c33e 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java +++ b/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java @@ -9,13 +9,13 @@ 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. */ - public ItemStack getStoredItemPrototype (); + 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. */ - public ItemStack getStoredItemCopy (); + ItemStack getStoredItemCopy (); /** * Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced. @@ -23,12 +23,12 @@ public interface IDrawer * @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. */ - public void setStoredItem (ItemStack itemPrototype, int amount); + void setStoredItem (ItemStack itemPrototype, int amount); /** * Gets the number of items stored in this drawer. */ - public int getStoredItemCount (); + int getStoredItemCount (); /** * Sets the number of items stored in this drawer. Triggers syncing of inventories and client data. @@ -36,23 +36,23 @@ public interface IDrawer * * @param amount The new amount of items stored in this drawer. */ - public void setStoredItemCount (int amount); + 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. */ - public int getMaxCapacity (); + int getMaxCapacity (); /** * Gets the number of items that could still be added to this drawer before it is full. */ - public int getRemainingCapacity (); + int getRemainingCapacity (); /** * Gets the max stack size of the item type stored in this drawer. Convenience method. */ - public int getStoredItemStackSize (); + int getStoredItemStackSize (); /** * Gets whether or not an item of the given type and data can be stored in this drawer. @@ -81,7 +81,7 @@ public interface IDrawer */ boolean isEmpty (); - public void writeToNBT (NBTTagCompound tag); + void writeToNBT (NBTTagCompound tag); - public void readFromNBT (NBTTagCompound tag); + void readFromNBT (NBTTagCompound tag); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java b/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java index bd69ccd..6faf8c9 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java +++ b/src/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java @@ -5,15 +5,15 @@ public interface IDrawerGroup /** * Gets the number of drawers contained within this group. */ - public int getDrawerCount (); + int getDrawerCount (); /** * Gets the drawer at the given slot within this group. */ - public IDrawer getDrawer (int slot); + IDrawer getDrawer (int slot); /** * Gets whether the drawer in the given slot is usable. */ - public boolean isDrawerEnabled (int slot); + boolean isDrawerEnabled (int slot); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/Api.java b/src/com/jaquadro/minecraft/storagedrawers/core/Api.java new file mode 100644 index 0000000..040de19 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/core/Api.java @@ -0,0 +1,19 @@ +package com.jaquadro.minecraft.storagedrawers.core; + +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.IStorageDrawersApi; +import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry; + +public class Api implements IStorageDrawersApi +{ + public static IStorageDrawersApi instance; + + public Api () { + instance = this; + } + + @Override + public IRecipeHandlerRegistry recipeHandlerRegistry () { + return StorageDrawers.recipeHandlerRegistry; + } +}