diff --git a/src/main/java/refinedstorage/network/GridPullFlags.java b/src/main/java/refinedstorage/api/network/GridPullFlags.java similarity index 93% rename from src/main/java/refinedstorage/network/GridPullFlags.java rename to src/main/java/refinedstorage/api/network/GridPullFlags.java index e90cc91bd..995808fc1 100755 --- a/src/main/java/refinedstorage/network/GridPullFlags.java +++ b/src/main/java/refinedstorage/api/network/GridPullFlags.java @@ -1,4 +1,4 @@ -package refinedstorage.network; +package refinedstorage.api.network; public class GridPullFlags { public static final int PULL_HALF = 1; diff --git a/src/main/java/refinedstorage/api/network/IGridHandler.java b/src/main/java/refinedstorage/api/network/IGridHandler.java index ebd6118c7..a6dbc1922 100755 --- a/src/main/java/refinedstorage/api/network/IGridHandler.java +++ b/src/main/java/refinedstorage/api/network/IGridHandler.java @@ -3,14 +3,50 @@ package refinedstorage.api.network; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import javax.annotation.Nullable; + +/** + * Defines the behaviour of grids. + */ public interface IGridHandler { + /** + * Called when a player tries to pull an item from the grid. + * + * @param stack The stack we're trying to pull + * @param flags How we are pulling, see {@link GridPullFlags} + * @param player The player that is attempting the pull + */ void onPull(ItemStack stack, int flags, EntityPlayerMP player); + /** + * Called when a player tries to push to the grid + * + * @param stack The stack we're trying to push + * @return The remainder, or null if no remainder + */ + @Nullable ItemStack onPush(ItemStack stack); + /** + * Called when a player is trying to push an item that it is holding in their hand in the GUI, so not with shift. + * + * @param single If we are only pushing 1 item + * @param player The player that is attempting the push + */ void onHeldItemPush(boolean single, EntityPlayerMP player); + /** + * Called when a player requested crafting for an item. + * + * @param stack The item we're requesting crafting for + * @param quantity The amount of that item that has to be crafted + */ void onCraftingRequested(ItemStack stack, int quantity); + /** + * Called when a player wants to cancel a crafting task. + * + * @param id The task ID, or -1 for all tasks + */ void onCraftingCancelRequested(int id); } diff --git a/src/main/java/refinedstorage/api/network/INetworkMaster.java b/src/main/java/refinedstorage/api/network/INetworkMaster.java index 4ba6a2b44..8317416ad 100755 --- a/src/main/java/refinedstorage/api/network/INetworkMaster.java +++ b/src/main/java/refinedstorage/api/network/INetworkMaster.java @@ -28,17 +28,12 @@ public interface INetworkMaster { BlockPos getPosition(); /** - * @return If this network is able to run (usually corresponds to redstone setting) + * @return If this network is able to run (usually corresponds to the redstone setting) */ boolean canRun(); /** - * Updates this network. - */ - void update(); - - /** - * @return A list with all network slaves, do NOT modify + * @return A list with all network slaves */ List getSlaves(); @@ -82,7 +77,7 @@ public interface INetworkMaster { /** * Adds a crafting task to the bottom of the crafting task stack. * - * @param task The crafting task to add + * @param task The crafting task to add as last */ void addCraftingTaskAsLast(ICraftingTask task); @@ -120,24 +115,20 @@ public interface INetworkMaster { * If there are multiple crafting patterns with the same output, it'll return the one * where there are the most ingredients of in the network. * - * @param pattern The item to get a pattern for + * @param pattern The {@link ItemStack} to get a pattern for * @return The pattern */ ICraftingPattern getPatternWithBestScore(ItemStack pattern); /** - * Returns a crafting pattern from an item stack. - * If there are multiple crafting patterns with the same output, it'll return the one - * where there are the most ingredients of in the network. - * - * @param pattern The item to get a pattern for - * @param flags The flags we compare on + * @param pattern The {@link ItemStack} to get a pattern for + * @param flags The flags we compare on, see {@link CompareFlags} * @return The pattern */ ICraftingPattern getPatternWithBestScore(ItemStack pattern, int flags); /** - * Sends to all clients watching a network (for example a grid) a packet with all the items in this network. + * Sends to all clients in a grid a packet with all the items in this network. */ void updateItemsWithClient(); @@ -168,10 +159,6 @@ public interface INetworkMaster { ItemStack take(ItemStack stack, int size); /** - * Takes an item from storage. - * If the stack we found in the system is smaller than the requested size, return the stack anyway. - * For example: this method is called for dirt (64x) while there is only dirt (32x), return the dirt (32x) anyway. - * * @param stack A prototype of the stack to take, do NOT modify * @param size The amount of that prototype that has to be taken * @param flags On what we are comparing to take the item, see {@link CompareFlags} @@ -184,7 +171,7 @@ public interface INetworkMaster { * * @param stack The stack to search * @param flags The flags to compare on - * @return The stack we found + * @return The {@link ItemStack} we found */ @Nullable ItemStack getItem(ItemStack stack, int flags); diff --git a/src/main/java/refinedstorage/api/network/INetworkSlave.java b/src/main/java/refinedstorage/api/network/INetworkSlave.java index f3fbfc74e..0baf1cc9f 100755 --- a/src/main/java/refinedstorage/api/network/INetworkSlave.java +++ b/src/main/java/refinedstorage/api/network/INetworkSlave.java @@ -8,7 +8,7 @@ import net.minecraft.world.World; */ public interface INetworkSlave { /** - * Called every server tick. + * Called every tile entity tick */ void updateSlave(); @@ -41,13 +41,6 @@ public interface INetworkSlave { */ void connect(World world, INetworkMaster network); - /** - * Called when the slave is loaded from a save file - * - * @param network The network we have to connected to - */ - void forceConnect(INetworkMaster network); - /** * Called when a connection is lost to the network * diff --git a/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java b/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java index 83a003311..a728f18a0 100755 --- a/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java +++ b/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java @@ -23,7 +23,7 @@ public interface ISoldererRegistry { List getRecipes(); /** - * @param items An item handler, where slots 0 - 2 are the row slots + * @param items An item handler, where slots 0 - 2 are the rows * @return The recipe, or null if no recipe was found */ @Nullable diff --git a/src/main/java/refinedstorage/apiimpl/network/GridHandler.java b/src/main/java/refinedstorage/apiimpl/network/GridHandler.java index d0107d5f4..290abe58f 100755 --- a/src/main/java/refinedstorage/apiimpl/network/GridHandler.java +++ b/src/main/java/refinedstorage/apiimpl/network/GridHandler.java @@ -6,10 +6,10 @@ import net.minecraft.item.ItemStack; import refinedstorage.RefinedStorageUtils; import refinedstorage.api.autocrafting.ICraftingPattern; import refinedstorage.api.autocrafting.ICraftingTask; +import refinedstorage.api.network.GridPullFlags; import refinedstorage.api.network.IGridHandler; import refinedstorage.api.network.INetworkMaster; import refinedstorage.item.ItemWirelessGrid; -import refinedstorage.network.GridPullFlags; public class GridHandler implements IGridHandler { public static final int MAX_CRAFTING_PER_REQUEST = 500; diff --git a/src/main/java/refinedstorage/block/BlockController.java b/src/main/java/refinedstorage/block/BlockController.java index 54eee9423..8ae09f876 100755 --- a/src/main/java/refinedstorage/block/BlockController.java +++ b/src/main/java/refinedstorage/block/BlockController.java @@ -105,7 +105,7 @@ public class BlockController extends BlockBase { @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) { - ((TileController) world.getTileEntity(pos)).disconnectAll(); + ((TileController) world.getTileEntity(pos)).disconnectSlaves(); } super.breakBlock(world, pos, state); diff --git a/src/main/java/refinedstorage/gui/GuiGrid.java b/src/main/java/refinedstorage/gui/GuiGrid.java index 1b4145da5..2b0a0b366 100755 --- a/src/main/java/refinedstorage/gui/GuiGrid.java +++ b/src/main/java/refinedstorage/gui/GuiGrid.java @@ -12,6 +12,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.FMLCommonHandler; import org.apache.commons.lang3.StringUtils; import refinedstorage.RefinedStorage; +import refinedstorage.api.network.GridPullFlags; import refinedstorage.block.EnumGridType; import refinedstorage.container.ContainerGrid; import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode; @@ -19,7 +20,10 @@ import refinedstorage.gui.sidebutton.SideButtonGridSortingDirection; import refinedstorage.gui.sidebutton.SideButtonGridSortingType; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.jei.RefinedStorageJEIPlugin; -import refinedstorage.network.*; +import refinedstorage.network.MessageGridCraftingClear; +import refinedstorage.network.MessageGridHeldPush; +import refinedstorage.network.MessageGridPatternCreate; +import refinedstorage.network.MessageGridPull; import refinedstorage.tile.grid.IGrid; import refinedstorage.tile.grid.TileGrid; import refinedstorage.tile.grid.WirelessGrid; diff --git a/src/main/java/refinedstorage/tile/TileSlave.java b/src/main/java/refinedstorage/tile/TileSlave.java index 38c524633..adf650dc2 100755 --- a/src/main/java/refinedstorage/tile/TileSlave.java +++ b/src/main/java/refinedstorage/tile/TileSlave.java @@ -80,12 +80,6 @@ public abstract class TileSlave extends TileBase implements INetworkSlave, ISync } } - @Override - public void forceConnect(INetworkMaster network) { - this.network = network; - this.connected = true; - } - @Override public void disconnect(World world) { this.connected = false;