Improve docs

This commit is contained in:
Raoul Van den Berge
2016-09-11 22:48:19 +02:00
parent 10b52f3022
commit 8cf180e9f8
27 changed files with 252 additions and 245 deletions

View File

@@ -10,13 +10,13 @@ import javax.annotation.Nonnull;
*/ */
public interface IAPI { public interface IAPI {
/** /**
* @return The solderer registry * @return the solderer registry
*/ */
@Nonnull @Nonnull
ISoldererRegistry getSoldererRegistry(); ISoldererRegistry getSoldererRegistry();
/** /**
* @return The crafting task registry * @return the crafting task registry
*/ */
@Nonnull @Nonnull
ICraftingTaskRegistry getCraftingTaskRegistry(); ICraftingTaskRegistry getCraftingTaskRegistry();

View File

@@ -20,7 +20,7 @@ public final class RefinedStorageAPI {
} }
/** /**
* @return The Refined Storage API * @return the Refined Storage API
*/ */
public static IAPI instance() { public static IAPI instance() {
return API; return API;

View File

@@ -9,38 +9,40 @@ import java.util.List;
*/ */
public interface ICraftingPattern { public interface ICraftingPattern {
/** /**
* @return The container where the pattern is in * @return the {@link ICraftingPatternContainer} where the pattern is in
*/ */
ICraftingPatternContainer getContainer(); ICraftingPatternContainer getContainer();
/** /**
* @return The crafting pattern stack * @return the crafting pattern stack
*/ */
ItemStack getStack(); ItemStack getStack();
/** /**
* @return Whether the crafting pattern is valid * @return true if the crafting pattern is valid, false otherwise
*/ */
boolean isValid(); boolean isValid();
/** /**
* @return The inputs * @return the inputs
*/ */
List<ItemStack> getInputs(); List<ItemStack> getInputs();
/** /**
* @return The outputs * @return the outputs
*/ */
List<ItemStack> getOutputs(); List<ItemStack> getOutputs();
/** /**
* @return The id of the crafting task, as defined in the registry * @return the id of the factory that creates a crafting task for this pattern, as defined in the registry
*/ */
String getId(); String getId();
/** /**
* @param requested The item requested * Returns the quantity of items that this crafting task yields per request.
* @return The quantity returned per request *
* @param requested the item requested
* @return the quantity
*/ */
int getQuantityPerRequest(ItemStack requested); int getQuantityPerRequest(ItemStack requested);
} }

View File

@@ -4,28 +4,28 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
/** /**
* Represents the container where the pattern is in. * Represents the container where a crafting pattern is in.
*/ */
public interface ICraftingPatternContainer { public interface ICraftingPatternContainer {
/** /**
* This usually corresponds to the amount of speed upgrades in a crafter. * The speed that crafting tasks that have a pattern in this container can run.
* *
* @return The speed of this container * @return the speed of this container
*/ */
int getSpeed(); int getSpeed();
/** /**
* @return The {@link IItemHandler} that this container is facing * @return the {@link IItemHandler} that this container is facing
*/ */
IItemHandler getConnectedItems(); IItemHandler getConnectedItems();
/** /**
* @return The patterns stored in this container * @return the patterns stored in this container
*/ */
IItemHandler getPatterns(); IItemHandler getPatterns();
/** /**
* @return The position of this container * @return the position of this container
*/ */
BlockPos getPosition(); BlockPos getPosition();
} }

View File

@@ -6,17 +6,17 @@ import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
/** /**
* Implement this interface on pattern items. * Implement this interface on crafting pattern items.
* When you implement this interface on your patterns, they will be insertable in crafters. * When this interface is implemented on the item in question, they will be insertable in crafters.
*/ */
public interface ICraftingPatternProvider { public interface ICraftingPatternProvider {
/** /**
* Creates a crafting pattern. * Creates a crafting pattern.
* *
* @param world The world * @param world the world
* @param stack The pattern stack * @param stack the pattern stack
* @param container The container where the pattern is in * @param container the {@link ICraftingPatternContainer} where the pattern is in
* @return The crafting pattern * @return the crafting pattern
*/ */
@Nonnull @Nonnull
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container); ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container);

View File

@@ -9,17 +9,17 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
* A factory that creates a crafting task from a NBT tag and crafting pattern. * A factory that creates a crafting task.
* Register this factory to create your own custom crafting tasks. * Register this factory in the {@link ICraftingTaskRegistry}.
*/ */
public interface ICraftingTaskFactory { public interface ICraftingTaskFactory {
/** /**
* Returns a crafting task for a given NBT tag and pattern. * Returns a crafting task for a given NBT tag and pattern.
* *
* @param world The world * @param world the world
* @param tag The NBT tag. If this is null it isn't reading from disk but is used for making a task on demand * @param tag the NBT tag, if this is null it isn't reading from disk but is used for making a task on demand
* @param pattern The pattern * @param pattern the pattern
* @return The crafting task * @return the crafting task
*/ */
@Nonnull @Nonnull
ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern); ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern);

View File

@@ -3,23 +3,23 @@ package refinedstorage.api.autocrafting.registry;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
* A registry that stores the various crafting task types. * A registry that stores crafting task factories.
*/ */
public interface ICraftingTaskRegistry { public interface ICraftingTaskRegistry {
/** /**
* Adds a crafting task factory to the registry. * Adds a crafting task factory to the registry.
* The id is used for reading and writing the crafting tasks to disk. * The id is used for identifying tasks when they are read from disk.
* *
* @param id The id of the crafting task type * @param id the id of the factory
* @param factory The factory * @param factory the factory
*/ */
void addFactory(String id, ICraftingTaskFactory factory); void addFactory(String id, ICraftingTaskFactory factory);
/** /**
* Returns the factory of a crafting task type id. * Returns the crafting task factory by factory id.
* *
* @param id The id * @param id the factory id
* @return The factory * @return the factory
*/ */
@Nullable @Nullable
ICraftingTaskFactory getFactory(String id); ICraftingTaskFactory getFactory(String id);

View File

@@ -12,51 +12,52 @@ import javax.annotation.Nullable;
*/ */
public interface ICraftingTask { public interface ICraftingTask {
/** /**
* @return The pattern * @return the pattern
*/ */
ICraftingPattern getPattern(); ICraftingPattern getPattern();
/** /**
* @return The child task * @return the child task
*/ */
@Nullable @Nullable
ICraftingTask getChild(); ICraftingTask getChild();
/** /**
* @param child The child task * @param child the child task
*/ */
void setChild(@Nullable ICraftingTask child); void setChild(@Nullable ICraftingTask child);
/** /**
* @param world The world * @param world the world
* @param network The network * @param network the network
* @return If the crafting task is done * @return true if the crafting task is done, false otherwise
*/ */
boolean update(World world, INetworkMaster network); boolean update(World world, INetworkMaster network);
/** /**
* Gets called when this crafting task is cancelled. * Gets called when the crafting task is cancelled.
* *
* @param network The network * @param network the network
*/ */
void onCancelled(INetworkMaster network); void onCancelled(INetworkMaster network);
/** /**
* Writes this crafting task to NBT. * Writes this crafting task to NBT.
* *
* @param tag The NBT tag to write to * @param tag the NBT tag to write to
* @return the written NBT tag
*/ */
NBTTagCompound writeToNBT(NBTTagCompound tag); NBTTagCompound writeToNBT(NBTTagCompound tag);
/** /**
* Returns status info used in the tooltip of the crafting monitor. * Returns the status of this crafting task that is used for the tooltip in the crafting monitor.
* *
* @return The status * @return the status
*/ */
String getStatus(); String getStatus();
/** /**
* @return The progress for display in the crafting monitor, -1 for no progress * @return the progress for display in the crafting monitor, or -1 to not display any progress
*/ */
int getProgress(); int getProgress();
} }

View File

@@ -23,81 +23,81 @@ import java.util.List;
*/ */
public interface INetworkMaster { public interface INetworkMaster {
/** /**
* @return The energy storage of this network * @return the energy storage of this network
*/ */
EnergyStorage getEnergy(); EnergyStorage getEnergy();
/** /**
* @return The energy usage per tick of this network * @return the energy usage per tick of this network
*/ */
int getEnergyUsage(); int getEnergyUsage();
/** /**
* @return The position of this network in the world * @return the position of this network in the world
*/ */
BlockPos getPosition(); BlockPos getPosition();
/** /**
* @return If this network is able to run (usually corresponds to the redstone setting) * @return if this network is able to run (usually corresponds to the redstone configuration)
*/ */
boolean canRun(); boolean canRun();
/** /**
* @return A graph of connected nodes to this network * @return a graph of connected nodes to this network
*/ */
INetworkNodeGraph getNodeGraph(); INetworkNodeGraph getNodeGraph();
/** /**
* @return The {@link IItemGridHandler} for this network * @return the {@link IItemGridHandler} of this network
*/ */
IItemGridHandler getItemGridHandler(); IItemGridHandler getItemGridHandler();
/** /**
* @return The {@link IFluidGridHandler} for this network * @return the {@link IFluidGridHandler} of this network
*/ */
IFluidGridHandler getFluidGridHandler(); IFluidGridHandler getFluidGridHandler();
/** /**
* @return The {@link IWirelessGridHandler} for this network * @return the {@link IWirelessGridHandler} of this network
*/ */
IWirelessGridHandler getWirelessGridHandler(); IWirelessGridHandler getWirelessGridHandler();
/** /**
* @return The {@link IGroupedItemStorage} of this network * @return the {@link IGroupedItemStorage} of this network
*/ */
IGroupedItemStorage getItemStorage(); IGroupedItemStorage getItemStorage();
/** /**
* @return The {@link IGroupedFluidStorage} of this network * @return the {@link IGroupedFluidStorage} of this network
*/ */
IGroupedFluidStorage getFluidStorage(); IGroupedFluidStorage getFluidStorage();
/** /**
* @return The crafting tasks in this network, do NOT modify this list * @return the crafting tasks in this network, do NOT modify this list
*/ */
List<ICraftingTask> getCraftingTasks(); List<ICraftingTask> getCraftingTasks();
/** /**
* Adds a crafting task to the top of the crafting task stack. * Adds a crafting task.
* *
* @param task The crafting task to add * @param task the task to add
*/ */
void addCraftingTask(@Nonnull ICraftingTask task); void addCraftingTask(@Nonnull ICraftingTask task);
/** /**
* Cancels a crafting task. * Cancels a crafting task.
* *
* @param task The task to cancel * @param task the task to cancel
*/ */
void cancelCraftingTask(@Nonnull ICraftingTask task); void cancelCraftingTask(@Nonnull ICraftingTask task);
/** /**
* Sends a sync packet to all crafting monitors with the crafting task status. * Sends a update packet to all crafting monitors with the crafting task status.
*/ */
void updateCraftingTasks(); void updateCraftingTasks();
/** /**
* @return A list of crafting patterns in this network, do NOT modify this list * @return a list of crafting patterns in this network, do NOT modify this list
*/ */
List<ICraftingPattern> getPatterns(); List<ICraftingPattern> getPatterns();
@@ -109,40 +109,45 @@ public interface INetworkMaster {
/** /**
* Returns crafting patterns from an item stack. * Returns crafting patterns from an item stack.
* *
* @param pattern The {@link ItemStack} to get a pattern for * @param pattern the stack to get a pattern for
* @param flags The flags to compare on, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return A list of crafting patterns where the given pattern is one of the outputs * @return a list of crafting patterns where the given pattern is one of the outputs
*/ */
List<ICraftingPattern> getPatterns(ItemStack pattern, int flags); List<ICraftingPattern> getPatterns(ItemStack pattern, int flags);
/** /**
* @param pattern The {@link ItemStack} to get a pattern for * Returns a crafting pattern for an item stack.
* @param flags The flags to compare on, see {@link CompareUtils} * This returns a single crafting pattern, as opposed to {@link INetworkMaster#getPatterns(ItemStack, int)}.
* @return The pattern, or null if the pattern is not found * Internally, this makes a selection out of the available patterns.
* It makes this selection based on the item count of the pattern outputs in the system.
*
* @param pattern the stack to get a pattern for
* @param flags the flags to compare on, see {@link CompareUtils}
* @return the pattern, or null if the pattern is not found
*/ */
@Nullable @Nullable
ICraftingPattern getPattern(ItemStack pattern, int flags); ICraftingPattern getPattern(ItemStack pattern, int flags);
/** /**
* Sends a grid packet with all the items to all clients that are watching a grid. * Sends a grid update packet with all the items to all clients that are watching a grid connected to this network.
*/ */
void sendItemStorageToClient(); void sendItemStorageToClient();
/** /**
* Sends a grid packet with all the items to a specific player. * Sends a grid update packet with all the items to a specific player.
*/ */
void sendItemStorageToClient(EntityPlayerMP player); void sendItemStorageToClient(EntityPlayerMP player);
/** /**
* Sends a item storage change to all clients that are watching a grid. * Sends a item storage change to all clients that are watching a grid connected to this network.
* *
* @param stack The stack * @param stack the stack
* @param delta The delta * @param delta the delta
*/ */
void sendItemStorageDeltaToClient(ItemStack stack, int delta); void sendItemStorageDeltaToClient(ItemStack stack, int delta);
/** /**
* Sends a grid packet with all the fluids to all clients that are watching a grid. * Sends a grid update packet with all the fluids to all clients that are watching a grid connected to this network.
*/ */
void sendFluidStorageToClient(); void sendFluidStorageToClient();
@@ -152,20 +157,20 @@ public interface INetworkMaster {
void sendFluidStorageToClient(EntityPlayerMP player); void sendFluidStorageToClient(EntityPlayerMP player);
/** /**
* Sends a fluids storage change to all clients that are watching a grid. * Sends a fluids storage change to all clients that are watching a grid connected to this network.
* *
* @param stack The stack * @param stack the stack
* @param delta The delta * @param delta the delta
*/ */
void sendFluidStorageDeltaToClient(FluidStack stack, int delta); void sendFluidStorageDeltaToClient(FluidStack stack, int delta);
/** /**
* Inserts an item to this network. * Inserts an item in this network.
* *
* @param stack The stack prototype to insert, do NOT modify * @param stack the stack prototype to insert, do NOT modify
* @param size The amount of that prototype that has to be inserted * @param size the amount of that prototype that has to be inserted
* @param simulate If we are simulating * @param simulate if we are simulating
* @return null if the insert was successful, or an {@link ItemStack} with the remainder * @return null if the insert was successful, or a stack with the remainder
*/ */
@Nullable @Nullable
ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate); ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate);
@@ -173,21 +178,21 @@ public interface INetworkMaster {
/** /**
* Extracts an item from this network. * Extracts an item from this network.
* *
* @param stack The prototype of the stack to extract, do NOT modify * @param stack the prototype of the stack to extract, do NOT modify
* @param size The amount of that prototype that has to be extracted * @param size the amount of that prototype that has to be extracted
* @param flags The flags to compare on, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return null if we didn't extract anything, or a {@link ItemStack} with the result * @return null if we didn't extract anything, or a stack with the result
*/ */
@Nullable @Nullable
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags); ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);
/** /**
* Inserts a fluid to this network. * Inserts a fluid in this network.
* *
* @param stack The stack prototype to insert, do NOT modify * @param stack the stack prototype to insert, do NOT modify
* @param size The amount of that prototype that has to be inserted * @param size the amount of that prototype that has to be inserted
* @param simulate If we are simulating * @param simulate if we are simulating
* @return null if the insert was successful, or an {@link FluidStack} with the remainder * @return null if the insert was successful, or a stack with the remainder
*/ */
@Nullable @Nullable
FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate); FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate);
@@ -195,16 +200,16 @@ public interface INetworkMaster {
/** /**
* Extracts a fluid from this network. * Extracts a fluid from this network.
* *
* @param stack The prototype of the stack to extract, do NOT modify * @param stack the prototype of the stack to extract, do NOT modify
* @param size The amount of that prototype that has to be extracted * @param size the amount of that prototype that has to be extracted
* @param flags The flags to compare on, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return null if we didn't extract anything, or a {@link FluidStack} with the result * @return null if we didn't extract anything, or a stack with the result
*/ */
@Nullable @Nullable
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags); FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags);
/** /**
* @return The world where this node is in * @return the world where this network is in
*/ */
World getNetworkWorld(); World getNetworkWorld();
} }

View File

@@ -5,61 +5,56 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
* Represents a node in the storage network. * Represents a node in the network.
*/ */
public interface INetworkNode { public interface INetworkNode {
/** /**
* Called every tile entity tick. * @return the energy usage of this node
*/
void updateNode();
/**
* @return The energy usage of this node
*/ */
int getEnergyUsage(); int getEnergyUsage();
/** /**
* @return The position of this node in the world * @return the position of this node in the world
*/ */
BlockPos getPosition(); BlockPos getPosition();
/** /**
* Called when this node is connected to a network. * Called when this node is connected to a network.
* *
* @param network The network * @param network the network
*/ */
void onConnected(INetworkMaster network); void onConnected(INetworkMaster network);
/** /**
* Called when this node is disconnected from a network. * Called when this node is disconnected from a network.
* *
* @param network The network * @param network the network
*/ */
void onDisconnected(INetworkMaster network); void onDisconnected(INetworkMaster network);
/** /**
* @return If we are connected * @return true if this is node is connected to a network, or false otherwise
*/ */
boolean isConnected(); boolean isConnected();
/** /**
* @return If {@link INetworkNode#updateNode()} can get called, typically checks for connection status and redstone mode * @return true if this node can be treated as active, typically checks the redstone configuration
*/ */
boolean canUpdate(); boolean canUpdate();
/** /**
* @param direction The direction to conduct to * @param direction the direction to do a conduction check
* @return Whether this node can conduct a network signal * @return true if this node can conduct a connection to the given direction, false otherwise
*/ */
boolean canConduct(EnumFacing direction); boolean canConduct(EnumFacing direction);
/** /**
* @return The network * @return the network
*/ */
INetworkMaster getNetwork(); INetworkMaster getNetwork();
/** /**
* @return The world where this node is in * @return the world where this node is in
*/ */
World getNodeWorld(); World getNodeWorld();
} }

View File

@@ -5,26 +5,26 @@ import net.minecraft.util.math.BlockPos;
import java.util.List; import java.util.List;
/** /**
* A graph of all the nodes connected to a network. * Represents a graph of all the nodes connected to a network.
*/ */
public interface INetworkNodeGraph { public interface INetworkNodeGraph {
/** /**
* Rebuilds the node graph. * Rebuilds the node graph.
* *
* @param start The starting position to start looking for nodes * @param start the starting position to start looking for nodes
* @param notify Whether to notify nodes of a connection change * @param notify true to notify the nodes of a connection change, false to not notify
*/ */
void rebuild(BlockPos start, boolean notify); void rebuild(BlockPos start, boolean notify);
/** /**
* @return A list of all connected nodes * @return a list of all connected nodes
*/ */
List<INetworkNode> all(); List<INetworkNode> all();
/** /**
* Replaces an old network node with a new one. * Replaces an old node with a new one.
* *
* @param node The node * @param node the node to replace
*/ */
void replace(INetworkNode node); void replace(INetworkNode node);

View File

@@ -8,12 +8,12 @@ import net.minecraft.item.ItemStack;
*/ */
public interface IWirelessGridConsumer { public interface IWirelessGridConsumer {
/** /**
* @return The player using the wireless grid * @return the player using the wireless grid
*/ */
EntityPlayer getPlayer(); EntityPlayer getPlayer();
/** /**
* @return The wireless grid stack * @return the wireless grid stack
*/ */
ItemStack getStack(); ItemStack getStack();
} }

View File

@@ -18,33 +18,33 @@ public interface IWirelessGridHandler {
/** /**
* Called when a player opens a wireless grid. * Called when a player opens a wireless grid.
* *
* @param player The player that opened the wireless grid * @param player the player that opened the wireless grid
* @param controllerWorld The world of the controller * @param controllerWorld the world of the controller
* @param hand The hand the player opened it with * @param hand the hand the player opened it with
* @return If the opening was successful * @return true if the opening was successful, false otherwise
*/ */
boolean onOpen(EntityPlayer player, World controllerWorld, EnumHand hand); boolean onOpen(EntityPlayer player, World controllerWorld, EnumHand hand);
/** /**
* Called when the player closes a wireless grid. * Called when the player closes a wireless grid.
* *
* @param player The player that closed the grid * @param player the player that closed the grid
*/ */
void onClose(EntityPlayer player); void onClose(EntityPlayer player);
/** /**
* Drains energy from the wireless grid of a player. * Drains energy from the wireless grid of a player.
* *
* @param player The player to drain energy from * @param player the player that is using the wireless grid to drain energy from
* @param energy The amount of energy that has to be drained * @param energy the amount of energy that has to be drained
*/ */
void drainEnergy(EntityPlayer player, int energy); void drainEnergy(EntityPlayer player, int energy);
/** /**
* Returns a {@link IWirelessGridConsumer} for a player. * Returns a {@link IWirelessGridConsumer} for a player.
* *
* @param player The player to get the wireless grid consumer for * @param player the player to get the wireless grid consumer for
* @return The {@link IWirelessGridConsumer} that corresponds to a player, or null if the player isn't using a wireless grid * @return the {@link IWirelessGridConsumer} that corresponds to a player, or null if the player isn't using a wireless grid
*/ */
@Nullable @Nullable
IWirelessGridConsumer getConsumer(EntityPlayer player); IWirelessGridConsumer getConsumer(EntityPlayer player);

View File

@@ -7,12 +7,12 @@ import net.minecraft.util.math.BlockPos;
*/ */
public interface IWirelessTransmitter { public interface IWirelessTransmitter {
/** /**
* @return The range in blocks of this transmitter, starting from {@link IWirelessTransmitter#getOrigin()} * @return the range in blocks of this transmitter, starting from {@link IWirelessTransmitter#getOrigin()}
*/ */
int getRange(); int getRange();
/** /**
* @return The position where the wireless signal starts * @return the position where the wireless signal starts
*/ */
BlockPos getOrigin(); BlockPos getOrigin();
} }

View File

@@ -6,23 +6,23 @@ import net.minecraft.item.ItemStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
* Defines the behavior of item grids. * Defines the behavior of fluid grids.
*/ */
public interface IFluidGridHandler { public interface IFluidGridHandler {
/** /**
* Called when a player tries to extract a fluid from the grid. * Called when a player tries to extract a fluid from the grid.
* *
* @param hash The hash of the fluid we're trying to extract, see {@link refinedstorage.api.network.NetworkUtils#getFluidStackHashCode(net.minecraftforge.fluids.FluidStack)} * @param hash the hash of the fluid we're trying to extract, see {@link refinedstorage.api.network.NetworkUtils#getFluidStackHashCode(net.minecraftforge.fluids.FluidStack)}
* @param shift If we're shift clicking * @param shift if shift click was used
* @param player The player that is attempting the extraction * @param player the player that is attempting the extraction
*/ */
void onExtract(int hash, boolean shift, EntityPlayerMP player); void onExtract(int hash, boolean shift, EntityPlayerMP player);
/** /**
* Called when a player tries to insert fluids to the grid. * Called when a player tries to insert fluids in the grid.
* *
* @param container A stack with a container we're trying to insert * @param container a stack with a fluid container we're trying to insert
* @return The remainder, or null if there is no remainder * @return the remainder, or null if there is no remainder
*/ */
@Nullable @Nullable
ItemStack onInsert(ItemStack container); ItemStack onInsert(ItemStack container);
@@ -30,7 +30,7 @@ public interface IFluidGridHandler {
/** /**
* Called when a player is trying to insert a fluid that it is holding in their hand in the GUI. * Called when a player is trying to insert a fluid that it is holding in their hand in the GUI.
* *
* @param player The player that is attempting the insert * @param player the player that is attempting the insert
*/ */
void onInsertHeldContainer(EntityPlayerMP player); void onInsertHeldContainer(EntityPlayerMP player);
} }

View File

@@ -16,18 +16,18 @@ public interface IItemGridHandler {
/** /**
* Called when a player tries to extract an item from the grid. * Called when a player tries to extract an item from the grid.
* *
* @param hash The hash of the item we're trying to extract, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)} * @param hash the hash of the item we're trying to extract, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)}
* @param flags How we are extracting * @param flags how we are extracting
* @param player The player that is attempting the extraction * @param player the player that is attempting the extraction
*/ */
void onExtract(int hash, int flags, EntityPlayerMP player); void onExtract(int hash, int flags, EntityPlayerMP player);
/** /**
* Called when a player tries to insert an item to the grid. * Called when a player tries to insert an item in the grid.
* *
* @param player The player that is attempting the insert * @param player the player that is attempting the insert
* @param stack The item we're trying to insert * @param stack the item we're trying to insert
* @return The remainder, or null if there is no remainder * @return the remainder, or null if there is no remainder
*/ */
@Nullable @Nullable
ItemStack onInsert(EntityPlayerMP player, ItemStack stack); ItemStack onInsert(EntityPlayerMP player, ItemStack stack);
@@ -35,24 +35,24 @@ public interface IItemGridHandler {
/** /**
* Called when a player is trying to insert an item that it is holding in their hand in the GUI. * Called when a player is trying to insert an item that it is holding in their hand in the GUI.
* *
* @param player The player that is attempting the insert * @param player the player that is attempting the insert
* @param single If we are only inserting 1 item * @param single if we are only inserting a single item
*/ */
void onInsertHeldItem(EntityPlayerMP player, boolean single); void onInsertHeldItem(EntityPlayerMP player, boolean single);
/** /**
* Called when a player requested crafting for an item. * Called when a player requested crafting for an item.
* *
* @param hash The hash of the item we're requesting crafting for, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)} * @param hash the hash of the item we're requesting crafting for, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)}
* @param quantity The amount of that item that has to be crafted * @param quantity the amount of that item that has to be crafted
*/ */
void onCraftingRequested(int hash, int quantity); void onCraftingRequested(int hash, int quantity);
/** /**
* Called when a player wants to cancel a crafting task. * Called when a player wants to cancel a crafting task.
* *
* @param id The task ID, or -1 for all tasks * @param id the task id, or -1 to cancel all tasks
* @param depth The child depth of this task to cancel * @param depth the child depth of this task to cancel
*/ */
void onCraftingCancelRequested(int id, int depth); void onCraftingCancelRequested(int id, int depth);
} }

View File

@@ -10,20 +10,20 @@ import javax.annotation.Nullable;
*/ */
public interface ISoldererRecipe { public interface ISoldererRecipe {
/** /**
* @param row The row in the solderer that we want the {@link ItemStack} for (between 0 - 2) * @param row the row in the solderer that we want the stack for (between 0 - 2)
* @return A {@link ItemStack} for the given row * @return a stack for the given row, or null for no stack
*/ */
@Nullable @Nullable
ItemStack getRow(int row); ItemStack getRow(int row);
/** /**
* @return The {@link ItemStack} that this recipe gives back * @return the stack that this recipe gives back
*/ */
@Nonnull @Nonnull
ItemStack getResult(); ItemStack getResult();
/** /**
* @return The duration in ticks that this recipe takes to give the result back from {@link ISoldererRecipe#getResult()} * @return the duration in ticks that this recipe takes to give the result back
*/ */
int getDuration(); int getDuration();
} }

View File

@@ -13,19 +13,21 @@ public interface ISoldererRegistry {
/** /**
* Adds a recipe to the registry. * Adds a recipe to the registry.
* *
* @param recipe The recipe to add * @param recipe the recipe to add
*/ */
void addRecipe(@Nonnull ISoldererRecipe recipe); void addRecipe(@Nonnull ISoldererRecipe recipe);
/** /**
* @return A list with all the solderer recipes, do NOT modify * Returns a solderer recipe from the rows.
*/ *
List<ISoldererRecipe> getRecipes(); * @param row an item handler, where slots 0 - 2 are the rows
* @return the {@link ISoldererRecipe}, or null if no recipe was found
/**
* @param items An item handler, where slots 0 - 2 are the rows
* @return The {@link ISoldererRecipe}, or null if no recipe was found
*/ */
@Nullable @Nullable
ISoldererRecipe getRecipe(@Nonnull IItemHandler items); ISoldererRecipe getRecipe(@Nonnull IItemHandler row);
/**
* @return a list with all the solderer recipes, do NOT modify
*/
List<ISoldererRecipe> getRecipes();
} }

View File

@@ -16,9 +16,9 @@ public final class CompareUtils {
/** /**
* Compares two stacks by NBT, damage and quantity. * Compares two stacks by NBT, damage and quantity.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @return Whether the left and right stack are equal * @return true if the left and right stack are the same, false otherwise
*/ */
public static boolean compareStack(ItemStack left, ItemStack right) { public static boolean compareStack(ItemStack left, ItemStack right) {
return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE | COMPARE_QUANTITY); return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE | COMPARE_QUANTITY);
@@ -27,9 +27,9 @@ public final class CompareUtils {
/** /**
* Compares two stacks by NBT and damage. * Compares two stacks by NBT and damage.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @return Whether the left and right stack are equal * @return true if the left and right stack are the same, false otherwise
*/ */
public static boolean compareStackNoQuantity(ItemStack left, ItemStack right) { public static boolean compareStackNoQuantity(ItemStack left, ItemStack right) {
return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE); return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE);
@@ -38,10 +38,10 @@ public final class CompareUtils {
/** /**
* Compares two stacks by the given flags. * Compares two stacks by the given flags.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @param flags The flags to compare with * @param flags the flags to compare with
* @return Whether the left and right stack are equal * @return true if the left and right stack are the same, false otherwise
*/ */
public static boolean compareStack(ItemStack left, ItemStack right, int flags) { public static boolean compareStack(ItemStack left, ItemStack right, int flags) {
if (left == null && right == null) { if (left == null && right == null) {
@@ -80,10 +80,10 @@ public final class CompareUtils {
/** /**
* Compares two stacks by the given flags. * Compares two stacks by the given flags.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @param flags The flags to compare with * @param flags the flags to compare with
* @return Whether the left and right stack are equal * @return true if the left and right stack are the same, false otherwise
*/ */
public static boolean compareStack(FluidStack left, FluidStack right, int flags) { public static boolean compareStack(FluidStack left, FluidStack right, int flags) {
if (left == null && right == null) { if (left == null && right == null) {
@@ -116,9 +116,9 @@ public final class CompareUtils {
/** /**
* Compares the NBT tags of two stacks. * Compares the NBT tags of two stacks.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @return Whether the NBT tags are equal * @return true if the NBT tags of the two stacks are the same, false otherwise
*/ */
public static boolean compareNbt(ItemStack left, ItemStack right) { public static boolean compareNbt(ItemStack left, ItemStack right) {
if (!ItemStack.areItemStackTagsEqual(left, right)) { if (!ItemStack.areItemStackTagsEqual(left, right)) {
@@ -137,9 +137,9 @@ public final class CompareUtils {
/** /**
* Compares two stacks and checks if they share the same ore dictionary entry. * Compares two stacks and checks if they share the same ore dictionary entry.
* *
* @param left The left stack * @param left the left stack
* @param right The right stack * @param right the right stack
* @return Whether the stacks share the same ore dictionary entry * @return true if the two stacks share the same ore dictionary entry
*/ */
public static boolean compareStackOreDict(ItemStack left, ItemStack right) { public static boolean compareStackOreDict(ItemStack left, ItemStack right) {
if (left == null && right == null) { if (left == null && right == null) {

View File

@@ -2,7 +2,6 @@ package refinedstorage.api.storage.fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import refinedstorage.api.storage.CompareUtils; import refinedstorage.api.storage.CompareUtils;
import refinedstorage.api.storage.item.IItemStorageProvider;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -10,21 +9,21 @@ import java.util.List;
/** /**
* Represents a fluid storage sink for the storage network. * Represents a fluid storage sink for the storage network.
* Provide this through an {@link IItemStorageProvider}. * Provide this through an {@link IFluidStorageProvider}.
*/ */
public interface IFluidStorage { public interface IFluidStorage {
/** /**
* @return Fluids stored in this storage * @return fluids stored in this storage
*/ */
List<FluidStack> getStacks(); List<FluidStack> getStacks();
/** /**
* Inserts a fluid to this storage. * Inserts a fluid in this storage.
* *
* @param stack The fluid prototype to insert, do NOT modify * @param stack the fluid prototype to insert, do NOT modify
* @param size The amount of that prototype that has to be inserted * @param size the amount of that prototype that has to be inserted
* @param simulate If we are simulating * @param simulate if we are simulating
* @return null if the insert was successful, or a {@link FluidStack} with the remainder * @return null if the insert was successful, or a stack with the remainder
*/ */
@Nullable @Nullable
FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate); FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate);
@@ -34,21 +33,21 @@ public interface IFluidStorage {
* <p> * <p>
* If the fluid we found in the system is smaller than the requested size, return that fluid anyway. * If the fluid we found in the system is smaller than the requested size, return that fluid anyway.
* *
* @param stack A prototype of the fluid to extract, do NOT modify * @param stack a prototype of the fluid to extract, do NOT modify
* @param size The amount of that fluid that has to be extracted * @param size the amount of that fluid that has to be extracted
* @param flags On what we are comparing to extract this fluid, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return null if we didn't extract anything, or an {@link FluidStack} with the result * @return null if we didn't extract anything, or a stack with the result
*/ */
@Nullable @Nullable
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags); FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags);
/** /**
* @return The amount of fluids stored in this storage * @return the amount of fluids stored in this storage
*/ */
int getStored(); int getStored();
/** /**
* @return The priority of this storage * @return the priority of this storage
*/ */
int getPriority(); int getPriority();
} }

View File

@@ -3,13 +3,13 @@ package refinedstorage.api.storage.fluid;
import java.util.List; import java.util.List;
/** /**
* Represents a tile that provides item storage to the network. Implement this on a tile that is a {@link refinedstorage.api.network.INetworkNode}. * Represents a node that provides fluid storage to the network.
*/ */
public interface IFluidStorageProvider { public interface IFluidStorageProvider {
/** /**
* Adds the fluid storages that this storage provider provides. * Adds the fluid storages that this storage provider provides.
* *
* @param storages The previously added fluid storages * @param storages the previously added fluid storages
*/ */
void addFluidStorages(List<IFluidStorage> storages); void addFluidStorages(List<IFluidStorage> storages);
} }

View File

@@ -3,14 +3,13 @@ package refinedstorage.api.storage.fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import refinedstorage.api.network.INetworkMaster; import refinedstorage.api.network.INetworkMaster;
import refinedstorage.api.storage.CompareUtils; import refinedstorage.api.storage.CompareUtils;
import refinedstorage.api.storage.item.IItemStorageProvider;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
/** /**e
* This holds all fluids from all the connected storages from a {@link INetworkMaster}. * This holds all fluids from all the connected storages from a {@link INetworkMaster}.
* <p> * <p>
* Refined Storage uses this class mainly for use in Grids and Detectors to avoid querying * Refined Storage uses this class mainly for use in Grids and Detectors to avoid querying
@@ -19,7 +18,8 @@ import java.util.List;
*/ */
public interface IGroupedFluidStorage { public interface IGroupedFluidStorage {
/** /**
* Rebuilds the global fluid list. Typically called when a {@link IItemStorageProvider} is added or removed from the network. * Rebuilds the global fluid list.
* Typically called when a {@link IFluidStorageProvider} is added or removed from the network.
*/ */
void rebuild(); void rebuild();
@@ -31,8 +31,8 @@ public interface IGroupedFluidStorage {
* <p> * <p>
* Will merge it with another fluid if it already exists. * Will merge it with another fluid if it already exists.
* *
* @param stack The fluid to add, do NOT modify * @param stack the stack to add, do NOT modify
* @param rebuilding Whether this method is called while the storage is rebuilding * @param rebuilding whether this method is called while the storage is rebuilding
*/ */
void add(@Nonnull FluidStack stack, boolean rebuilding); void add(@Nonnull FluidStack stack, boolean rebuilding);
@@ -42,16 +42,16 @@ public interface IGroupedFluidStorage {
* Note that this doesn't modify any of the connected storages, but just modifies the global fluid list. * Note that this doesn't modify any of the connected storages, but just modifies the global fluid list.
* Use {@link INetworkMaster#extractFluid(FluidStack, int, int)} to remove an fluid from an actual storage. * Use {@link INetworkMaster#extractFluid(FluidStack, int, int)} to remove an fluid from an actual storage.
* *
* @param stack The fluid to remove, do NOT modify * @param stack the fluid to remove, do NOT modify
*/ */
void remove(@Nonnull FluidStack stack); void remove(@Nonnull FluidStack stack);
/** /**
* Gets a fluid from the network. * Gets a fluid from the network.
* *
* @param stack The stack to find * @param stack the stack to find
* @param flags The flags to compare on, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return Null if no fluid is found, or the {@link FluidStack}, do NOT modify * @return null if no fluid is found, or the stack, do NOT modify
*/ */
@Nullable @Nullable
FluidStack get(@Nonnull FluidStack stack, int flags); FluidStack get(@Nonnull FluidStack stack, int flags);
@@ -59,18 +59,18 @@ public interface IGroupedFluidStorage {
/** /**
* Gets a fluid from the network by hash, see {@link refinedstorage.api.network.NetworkUtils#getFluidStackHashCode(FluidStack)}. * Gets a fluid from the network by hash, see {@link refinedstorage.api.network.NetworkUtils#getFluidStackHashCode(FluidStack)}.
* *
* @return Null if no fluid is found matching the hash, or the {@link FluidStack}, do NOT modify * @return null if no fluid is found matching the hash, or the stack, do NOT modify
*/ */
@Nullable @Nullable
FluidStack get(int hash); FluidStack get(int hash);
/** /**
* @return All fluids in this storage network * @return all fluids in this storage network
*/ */
Collection<FluidStack> getStacks(); Collection<FluidStack> getStacks();
/** /**
* @return The fluid storages connected to this network * @return the fluid storages connected to this network
*/ */
List<IFluidStorage> getStorages(); List<IFluidStorage> getStorages();
} }

View File

@@ -18,7 +18,8 @@ import java.util.List;
*/ */
public interface IGroupedItemStorage { public interface IGroupedItemStorage {
/** /**
* Rebuilds the global item list. Typically called when a {@link IItemStorageProvider} is added or removed from the network. * Rebuilds the global item list.
* Typically called when a {@link IItemStorageProvider} is added or removed from the network.
*/ */
void rebuild(); void rebuild();
@@ -30,8 +31,8 @@ public interface IGroupedItemStorage {
* <p> * <p>
* Will merge it with another item if it already exists. * Will merge it with another item if it already exists.
* *
* @param stack The stack to add, do NOT modify * @param stack the stack to add, do NOT modify
* @param rebuilding Whether this method is called while the storage is rebuilding * @param rebuilding whether this method is called while the storage is rebuilding
*/ */
void add(@Nonnull ItemStack stack, boolean rebuilding); void add(@Nonnull ItemStack stack, boolean rebuilding);
@@ -41,16 +42,16 @@ public interface IGroupedItemStorage {
* Note that this doesn't modify any of the connected storages, but just modifies the global item list. * Note that this doesn't modify any of the connected storages, but just modifies the global item list.
* Use {@link INetworkMaster#extractItem(ItemStack, int, int)} to remove an item from an actual storage. * Use {@link INetworkMaster#extractItem(ItemStack, int, int)} to remove an item from an actual storage.
* *
* @param stack The item to remove, do NOT modify * @param stack the item to remove, do NOT modify
*/ */
void remove(@Nonnull ItemStack stack); void remove(@Nonnull ItemStack stack);
/** /**
* Gets an item from the network. * Gets an item from the network.
* *
* @param stack The stack to find * @param stack the stack to find
* @param flags The flags to compare on, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return Null if no item is found, or the {@link ItemStack}, do NOT modify * @return null if no item is found, or the stack, do NOT modify
*/ */
@Nullable @Nullable
ItemStack get(@Nonnull ItemStack stack, int flags); ItemStack get(@Nonnull ItemStack stack, int flags);
@@ -58,18 +59,18 @@ public interface IGroupedItemStorage {
/** /**
* Gets an item from the network by hash, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)}. * Gets an item from the network by hash, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)}.
* *
* @return Null if no item is found matching the hash, or the {@link ItemStack}, do NOT modify * @return null if no item is found matching the hash, or the stack, do NOT modify
*/ */
@Nullable @Nullable
ItemStack get(int hash); ItemStack get(int hash);
/** /**
* @return All items in this storage network * @return all items in this storage network
*/ */
Collection<ItemStack> getStacks(); Collection<ItemStack> getStacks();
/** /**
* @return The item storages connected to this network * @return the item storages connected to this network
*/ */
List<IItemStorage> getStorages(); List<IItemStorage> getStorages();
} }

View File

@@ -13,17 +13,17 @@ import java.util.List;
*/ */
public interface IItemStorage { public interface IItemStorage {
/** /**
* @return Items stored in this storage * @return items stored in this storage
*/ */
List<ItemStack> getItems(); List<ItemStack> getItems();
/** /**
* Inserts an item to this storage. * Inserts an item to this storage.
* *
* @param stack The stack prototype to insert, do NOT modify * @param stack the stack prototype to insert, do NOT modify
* @param size The amount of that prototype that has to be inserted * @param size the amount of that prototype that has to be inserted
* @param simulate If we are simulating * @param simulate if we are simulating
* @return null if the insert was successful, or a {@link ItemStack} with the remainder * @return null if the insert was successful, or a stack with the remainder
*/ */
@Nullable @Nullable
ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate); ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate);
@@ -33,10 +33,10 @@ public interface IItemStorage {
* <p> * <p>
* If the stack we found in the system is smaller than the requested size, return that stack anyway. * If the stack we found in the system is smaller than the requested size, return that stack anyway.
* *
* @param stack A prototype of the stack to extract, do NOT modify * @param stack a prototype of the stack to extract, do NOT modify
* @param size The amount of that prototype that has to be extracted * @param size the amount of that prototype that has to be extracted
* @param flags On what we are comparing to extract this item, see {@link CompareUtils} * @param flags the flags to compare on, see {@link CompareUtils}
* @return null if we didn't extract anything, or an {@link ItemStack} with the result * @return null if we didn't extract anything, or a stack with the result
*/ */
@Nullable @Nullable
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags); ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);

View File

@@ -3,13 +3,13 @@ package refinedstorage.api.storage.item;
import java.util.List; import java.util.List;
/** /**
* Represents a tile that provides item storage to the network. Implement this on a tile that is a {@link refinedstorage.api.network.INetworkNode}. * Represents a node that provides item storage to the network.
*/ */
public interface IItemStorageProvider { public interface IItemStorageProvider {
/** /**
* Adds the item storages that this storage provider provides. * Adds the item storages that this storage provider provides.
* *
* @param storages The previously added item storages * @param storages the previously added item storages
*/ */
void addItemStorages(List<IItemStorage> storages); void addItemStorages(List<IItemStorage> storages);
} }

View File

@@ -18,24 +18,19 @@ public class SoldererRegistry implements ISoldererRegistry {
recipes.add(recipe); recipes.add(recipe);
} }
@Override
public List<ISoldererRecipe> getRecipes() {
return recipes;
}
@Override @Override
@Nullable @Nullable
public ISoldererRecipe getRecipe(@Nonnull IItemHandler items) { public ISoldererRecipe getRecipe(@Nonnull IItemHandler row) {
for (ISoldererRecipe recipe : recipes) { for (ISoldererRecipe recipe : recipes) {
boolean found = true; boolean found = true;
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
if (!CompareUtils.compareStackNoQuantity(recipe.getRow(i), items.getStackInSlot(i)) && !CompareUtils.compareStackOreDict(recipe.getRow(i), items.getStackInSlot(i))) { if (!CompareUtils.compareStackNoQuantity(recipe.getRow(i), row.getStackInSlot(i)) && !CompareUtils.compareStackOreDict(recipe.getRow(i), row.getStackInSlot(i))) {
found = false; found = false;
} }
if (items.getStackInSlot(i) != null && recipe.getRow(i) != null) { if (row.getStackInSlot(i) != null && recipe.getRow(i) != null) {
if (items.getStackInSlot(i).stackSize < recipe.getRow(i).stackSize) { if (row.getStackInSlot(i).stackSize < recipe.getRow(i).stackSize) {
found = false; found = false;
} }
} }
@@ -48,4 +43,9 @@ public class SoldererRegistry implements ISoldererRegistry {
return null; return null;
} }
@Override
public List<ISoldererRecipe> getRecipes() {
return recipes;
}
} }

View File

@@ -42,6 +42,8 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
return isConnected() && canUpdate(); return isConnected() && canUpdate();
} }
public abstract void updateNode();
@Override @Override
public void update() { public void update() {
if (!worldObj.isRemote) { if (!worldObj.isRemote) {