Update docs

This commit is contained in:
Raoul Van den Berge
2016-06-24 18:57:12 +02:00
parent f10b2b9be7
commit 03fcc1b0d9
9 changed files with 54 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
package refinedstorage.network; package refinedstorage.api.network;
public class GridPullFlags { public class GridPullFlags {
public static final int PULL_HALF = 1; public static final int PULL_HALF = 1;

View File

@@ -3,14 +3,50 @@ package refinedstorage.api.network;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
/**
* Defines the behaviour of grids.
*/
public interface IGridHandler { 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); 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); 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); 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); 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); void onCraftingCancelRequested(int id);
} }

View File

@@ -28,17 +28,12 @@ public interface INetworkMaster {
BlockPos getPosition(); 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(); boolean canRun();
/** /**
* Updates this network. * @return A list with all network slaves
*/
void update();
/**
* @return A list with all network slaves, do NOT modify
*/ */
List<INetworkSlave> getSlaves(); List<INetworkSlave> getSlaves();
@@ -82,7 +77,7 @@ public interface INetworkMaster {
/** /**
* Adds a crafting task to the bottom of the crafting task stack. * 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); 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 * 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. * 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 * @return The pattern
*/ */
ICraftingPattern getPatternWithBestScore(ItemStack pattern); ICraftingPattern getPatternWithBestScore(ItemStack pattern);
/** /**
* Returns a crafting pattern from an item stack. * @param pattern The {@link ItemStack} to get a pattern for
* If there are multiple crafting patterns with the same output, it'll return the one * @param flags The flags we compare on, see {@link CompareFlags}
* 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
* @return The pattern * @return The pattern
*/ */
ICraftingPattern getPatternWithBestScore(ItemStack pattern, int flags); 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(); void updateItemsWithClient();
@@ -168,10 +159,6 @@ public interface INetworkMaster {
ItemStack take(ItemStack stack, int size); 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 stack A prototype of the stack to take, do NOT modify
* @param size The amount of that prototype that has to be taken * @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} * @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 stack The stack to search
* @param flags The flags to compare on * @param flags The flags to compare on
* @return The stack we found * @return The {@link ItemStack} we found
*/ */
@Nullable @Nullable
ItemStack getItem(ItemStack stack, int flags); ItemStack getItem(ItemStack stack, int flags);

View File

@@ -8,7 +8,7 @@ import net.minecraft.world.World;
*/ */
public interface INetworkSlave { public interface INetworkSlave {
/** /**
* Called every server tick. * Called every tile entity tick
*/ */
void updateSlave(); void updateSlave();
@@ -41,13 +41,6 @@ public interface INetworkSlave {
*/ */
void connect(World world, INetworkMaster network); 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 * Called when a connection is lost to the network
* *

View File

@@ -23,7 +23,7 @@ public interface ISoldererRegistry {
List<ISoldererRecipe> getRecipes(); List<ISoldererRecipe> 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 * @return The recipe, or null if no recipe was found
*/ */
@Nullable @Nullable

View File

@@ -6,10 +6,10 @@ import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
import refinedstorage.api.autocrafting.ICraftingPattern; import refinedstorage.api.autocrafting.ICraftingPattern;
import refinedstorage.api.autocrafting.ICraftingTask; import refinedstorage.api.autocrafting.ICraftingTask;
import refinedstorage.api.network.GridPullFlags;
import refinedstorage.api.network.IGridHandler; import refinedstorage.api.network.IGridHandler;
import refinedstorage.api.network.INetworkMaster; import refinedstorage.api.network.INetworkMaster;
import refinedstorage.item.ItemWirelessGrid; import refinedstorage.item.ItemWirelessGrid;
import refinedstorage.network.GridPullFlags;
public class GridHandler implements IGridHandler { public class GridHandler implements IGridHandler {
public static final int MAX_CRAFTING_PER_REQUEST = 500; public static final int MAX_CRAFTING_PER_REQUEST = 500;

View File

@@ -105,7 +105,7 @@ public class BlockController extends BlockBase {
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state) { public void breakBlock(World world, BlockPos pos, IBlockState state) {
if (!world.isRemote) { if (!world.isRemote) {
((TileController) world.getTileEntity(pos)).disconnectAll(); ((TileController) world.getTileEntity(pos)).disconnectSlaves();
} }
super.breakBlock(world, pos, state); super.breakBlock(world, pos, state);

View File

@@ -12,6 +12,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.api.network.GridPullFlags;
import refinedstorage.block.EnumGridType; import refinedstorage.block.EnumGridType;
import refinedstorage.container.ContainerGrid; import refinedstorage.container.ContainerGrid;
import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode; import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode;
@@ -19,7 +20,10 @@ import refinedstorage.gui.sidebutton.SideButtonGridSortingDirection;
import refinedstorage.gui.sidebutton.SideButtonGridSortingType; import refinedstorage.gui.sidebutton.SideButtonGridSortingType;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.jei.RefinedStorageJEIPlugin; 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.IGrid;
import refinedstorage.tile.grid.TileGrid; import refinedstorage.tile.grid.TileGrid;
import refinedstorage.tile.grid.WirelessGrid; import refinedstorage.tile.grid.WirelessGrid;

View File

@@ -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 @Override
public void disconnect(World world) { public void disconnect(World world) {
this.connected = false; this.connected = false;