Added documentation for the new API
This commit is contained in:
@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftin
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.wireless.IWirelessGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.wireless.IWirelessGridRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
@@ -109,9 +110,20 @@ public interface IRSAPI {
|
||||
@Nonnull
|
||||
ICraftingMonitorElementList createCraftingMonitorElementList();
|
||||
|
||||
/**
|
||||
* @return the wireless grid registry
|
||||
*/
|
||||
@Nonnull
|
||||
IWirelessGridRegistry getWirelessGridRegistry();
|
||||
|
||||
/**
|
||||
* Opens a wireless grid for the given player.
|
||||
*
|
||||
* @param player the player
|
||||
* @param hand the hand where the wireless grid is in
|
||||
* @param networkDimension the dimension of the bound network
|
||||
* @param id the id of the wireless grid, as returned in {@link IWirelessGridRegistry#add(IWirelessGridFactory)}
|
||||
*/
|
||||
void openWirelessGrid(EntityPlayer player, EnumHand hand, int networkDimension, int id);
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,26 @@ package com.raoulvdberge.refinedstorage.api.network.grid;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
/**
|
||||
* Represents a grid type.
|
||||
* Used in {@link IGrid} to determine grid GUI rendering.
|
||||
*/
|
||||
public enum GridType implements IStringSerializable {
|
||||
/**
|
||||
* A regular grid.
|
||||
*/
|
||||
NORMAL(0, "normal"),
|
||||
/**
|
||||
* A crafting grid.
|
||||
*/
|
||||
CRAFTING(1, "crafting"),
|
||||
/**
|
||||
* A pattern grid.
|
||||
*/
|
||||
PATTERN(2, "pattern"),
|
||||
/**
|
||||
* A fluid grid.
|
||||
*/
|
||||
FLUID(3, "fluid");
|
||||
|
||||
private int id;
|
||||
|
||||
@@ -13,67 +13,165 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a grid.
|
||||
*/
|
||||
public interface IGrid {
|
||||
/**
|
||||
* @return the grid type
|
||||
*/
|
||||
GridType getType();
|
||||
|
||||
/**
|
||||
* @return the network of this grid, or null if the network is unavailable
|
||||
*/
|
||||
@Nullable
|
||||
INetwork getNetwork();
|
||||
|
||||
/**
|
||||
* @return the item grid handler of the network of the grid, or null if the network is unavailable
|
||||
*/
|
||||
@Nullable
|
||||
default IItemGridHandler getItemHandler() {
|
||||
return getNetwork() != null ? getNetwork().getItemGridHandler() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fluid grid handler of the network of the grid, or null if the network is unavailable
|
||||
*/
|
||||
@Nullable
|
||||
default IFluidGridHandler getFluidHandler() {
|
||||
return getNetwork() != null ? getNetwork().getFluidGridHandler() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unlocalized gui title
|
||||
*/
|
||||
String getGuiTitle();
|
||||
|
||||
/**
|
||||
* @return the view type
|
||||
*/
|
||||
int getViewType();
|
||||
|
||||
/**
|
||||
* @return the sorting type
|
||||
*/
|
||||
int getSortingType();
|
||||
|
||||
/**
|
||||
* @return the sorting direction
|
||||
*/
|
||||
int getSortingDirection();
|
||||
|
||||
/**
|
||||
* @return the search box mode
|
||||
*/
|
||||
int getSearchBoxMode();
|
||||
|
||||
/**
|
||||
* @return the current tab that is selected
|
||||
*/
|
||||
int getTabSelected();
|
||||
|
||||
/**
|
||||
* @return the size mode
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* @param type the new view type
|
||||
*/
|
||||
void onViewTypeChanged(int type);
|
||||
|
||||
/**
|
||||
* @param type the new sorting type
|
||||
*/
|
||||
void onSortingTypeChanged(int type);
|
||||
|
||||
/**
|
||||
* @param direction the new direction
|
||||
*/
|
||||
void onSortingDirectionChanged(int direction);
|
||||
|
||||
/**
|
||||
* @param searchBoxMode the new search box mode
|
||||
*/
|
||||
void onSearchBoxModeChanged(int searchBoxMode);
|
||||
|
||||
/**
|
||||
* @param size the new size mode
|
||||
*/
|
||||
void onSizeChanged(int size);
|
||||
|
||||
/**
|
||||
* @param tab the new selected tab
|
||||
*/
|
||||
void onTabSelectionChanged(int tab);
|
||||
|
||||
/**
|
||||
* @return the filters
|
||||
*/
|
||||
List<IFilter> getFilters();
|
||||
|
||||
/**
|
||||
* @return the tabs
|
||||
*/
|
||||
List<IGridTab> getTabs();
|
||||
|
||||
/**
|
||||
* @return the inventory of the filters
|
||||
*/
|
||||
IItemHandlerModifiable getFilter();
|
||||
|
||||
/**
|
||||
* @return the crafting matrix, or null if not a crafting grid
|
||||
*/
|
||||
@Nullable
|
||||
InventoryCrafting getCraftingMatrix();
|
||||
|
||||
/**
|
||||
* @return the crafting result inventory, or null if not a crafting grid
|
||||
*/
|
||||
@Nullable
|
||||
InventoryCraftResult getCraftingResult();
|
||||
|
||||
/**
|
||||
* Called when the crafting matrix changes.
|
||||
*/
|
||||
void onCraftingMatrixChanged();
|
||||
|
||||
/**
|
||||
* Called when an item is crafted in a crafting grid.
|
||||
*
|
||||
* @param player the player that crafted the item
|
||||
*/
|
||||
void onCrafted(EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Called when an item is crafted with shift click (up to 64 items) in a crafting grid.
|
||||
*
|
||||
* @param player the player that crafted the item
|
||||
*/
|
||||
void onCraftedShift(EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Called when a JEI recipe transfer occurs.
|
||||
*
|
||||
* @param player the player
|
||||
* @param recipe a 9*x array stack array, where x is the possible combinations for the given slot
|
||||
*/
|
||||
void onRecipeTransfer(EntityPlayer player, ItemStack[][] recipe);
|
||||
|
||||
/**
|
||||
* Called when the grid is closed.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
void onClosed(EntityPlayer player);
|
||||
|
||||
/**
|
||||
* @return true if the grid is active, false otherwise
|
||||
*/
|
||||
boolean isActive();
|
||||
}
|
||||
|
||||
@@ -5,10 +5,22 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a grid tab.
|
||||
*/
|
||||
public interface IGridTab {
|
||||
/**
|
||||
* @return the filters
|
||||
*/
|
||||
List<IFilter> getFilters();
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return the icon
|
||||
*/
|
||||
ItemStack getIcon();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,18 @@ import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A factory interface for a wireless grid.
|
||||
*/
|
||||
public interface IWirelessGridFactory {
|
||||
/**
|
||||
* Creates a new wireless grid.
|
||||
*
|
||||
* @param player the player
|
||||
* @param hand the hand
|
||||
* @param networkDimension the network dimension of the grid
|
||||
* @return the grid
|
||||
*/
|
||||
@Nonnull
|
||||
IGrid create(EntityPlayer player, EnumHand hand, int networkDimension);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
package com.raoulvdberge.refinedstorage.api.network.grid.wireless;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A registry for wireless grid factories.
|
||||
*/
|
||||
public interface IWirelessGridRegistry {
|
||||
/**
|
||||
* Registers a new wireless grid factory.
|
||||
*
|
||||
* @param factory the factory
|
||||
* @return the id of this new wireless grid, use this id in {@link com.raoulvdberge.refinedstorage.api.IRSAPI#openWirelessGrid(EntityPlayer, EnumHand, int, int)}.
|
||||
*/
|
||||
int add(IWirelessGridFactory factory);
|
||||
|
||||
/**
|
||||
* Gets a wireless grid factory by id.
|
||||
*
|
||||
* @param id the id, as returned by {@link #add(IWirelessGridFactory)}
|
||||
* @return the wireless grid factory, or null if none is found
|
||||
*/
|
||||
@Nullable
|
||||
IWirelessGridFactory get(int id);
|
||||
}
|
||||
|
||||
@@ -25,5 +25,10 @@ public interface INetworkItem {
|
||||
*/
|
||||
boolean onOpen(INetwork network, EntityPlayer player, EnumHand hand);
|
||||
|
||||
/**
|
||||
* Called when an action occurs that is defined in {@link NetworkItemAction} and the network item is in use.
|
||||
*
|
||||
* @param action the action
|
||||
*/
|
||||
void onAction(NetworkItemAction action);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,36 @@
|
||||
package com.raoulvdberge.refinedstorage.api.network.item;
|
||||
|
||||
/**
|
||||
* Represents an network item action.
|
||||
* Called with {@link INetworkItem#onAction(NetworkItemAction)}.
|
||||
*/
|
||||
public enum NetworkItemAction {
|
||||
/**
|
||||
* Used when an item is inserted in a grid.
|
||||
*/
|
||||
ITEM_INSERTED,
|
||||
/**
|
||||
* Used when an item is extracted in a grid.
|
||||
*/
|
||||
ITEM_EXTRACTED,
|
||||
/**
|
||||
* Used when an item is crafted in a crafting grid (regular crafting, not autocrafting).
|
||||
*/
|
||||
ITEM_CRAFTED,
|
||||
/**
|
||||
* Used when a fluid is inserted in a grid.
|
||||
*/
|
||||
FLUID_INSERTED,
|
||||
/**
|
||||
* Used when a fluid is extracted in a grid.
|
||||
*/
|
||||
FLUID_EXTRACTED,
|
||||
/**
|
||||
* Used when a crafting task is cancelled in a crafting monitor.
|
||||
*/
|
||||
CRAFTING_TASK_CANCELLED,
|
||||
/**
|
||||
* Used when all crafting tasks are cancelled in a crafting monitor.
|
||||
*/
|
||||
CRAFTING_TASK_ALL_CANCELLED
|
||||
}
|
||||
|
||||
@@ -2,12 +2,30 @@ package com.raoulvdberge.refinedstorage.api.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* A filter.
|
||||
*/
|
||||
public interface IFilter {
|
||||
int MODE_WHITELIST = 0;
|
||||
int MODE_BLACKLIST = 1;
|
||||
|
||||
/**
|
||||
* @return the stack being filtered
|
||||
*/
|
||||
ItemStack getStack();
|
||||
|
||||
/**
|
||||
* @return the compare flags, see {@link IComparer}
|
||||
*/
|
||||
int getCompare();
|
||||
|
||||
/**
|
||||
* @return the mode, whitelist or blacklist
|
||||
*/
|
||||
int getMode();
|
||||
|
||||
/**
|
||||
* @return true if this is a mod filter, false otherwise
|
||||
*/
|
||||
boolean isModFilter();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageFilterUpdate;
|
||||
@@ -51,7 +52,7 @@ public class GuiFilter extends GuiBase {
|
||||
}
|
||||
|
||||
private void updateModeButton(int mode) {
|
||||
String text = mode == ItemFilter.MODE_WHITELIST ? t("sidebutton.refinedstorage:mode.whitelist") : t("sidebutton.refinedstorage:mode.blacklist");
|
||||
String text = mode == IFilter.MODE_WHITELIST ? t("sidebutton.refinedstorage:mode.whitelist") : t("sidebutton.refinedstorage:mode.blacklist");
|
||||
|
||||
toggleMode.setWidth(fontRenderer.getStringWidth(text) + 12);
|
||||
toggleMode.displayString = text;
|
||||
@@ -104,7 +105,7 @@ public class GuiFilter extends GuiBase {
|
||||
} else if (button == compareOredict) {
|
||||
compare ^= IComparer.COMPARE_OREDICT;
|
||||
} else if (button == toggleMode) {
|
||||
mode = mode == ItemFilter.MODE_WHITELIST ? ItemFilter.MODE_BLACKLIST : ItemFilter.MODE_WHITELIST;
|
||||
mode = mode == IFilter.MODE_WHITELIST ? IFilter.MODE_BLACKLIST : IFilter.MODE_WHITELIST;
|
||||
|
||||
updateModeButton(mode);
|
||||
} else if (button == toggleModFilter) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,20 +26,20 @@ public class GridFilterFilter implements Predicate<IGridStack> {
|
||||
return true;
|
||||
}
|
||||
|
||||
int lastMode = ItemFilter.MODE_WHITELIST;
|
||||
int lastMode = IFilter.MODE_WHITELIST;
|
||||
|
||||
for (IFilter filter : filters) {
|
||||
lastMode = filter.getMode();
|
||||
|
||||
if (filter.isModFilter()) {
|
||||
if (filter.getStack().getItem().getRegistryName().getResourceDomain().equalsIgnoreCase(stackModId)) {
|
||||
return filter.getMode() == ItemFilter.MODE_WHITELIST;
|
||||
return filter.getMode() == IFilter.MODE_WHITELIST;
|
||||
}
|
||||
} else if (API.instance().getComparer().isEqual(stack, filter.getStack(), filter.getCompare())) {
|
||||
return filter.getMode() == ItemFilter.MODE_WHITELIST;
|
||||
return filter.getMode() == IFilter.MODE_WHITELIST;
|
||||
}
|
||||
}
|
||||
|
||||
return lastMode != ItemFilter.MODE_WHITELIST;
|
||||
return lastMode != IFilter.MODE_WHITELIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSGui;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilterItems;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -23,9 +24,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemFilter extends ItemBase {
|
||||
public static final int MODE_WHITELIST = 0;
|
||||
public static final int MODE_BLACKLIST = 1;
|
||||
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_MOD_FILTER = "ModFilter";
|
||||
@@ -82,7 +80,7 @@ public class ItemFilter extends ItemBase {
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
||||
tooltip.add(TextFormatting.YELLOW + I18n.format("sidebutton.refinedstorage:mode." + (getMode(stack) == MODE_WHITELIST ? "whitelist" : "blacklist")) + TextFormatting.RESET);
|
||||
tooltip.add(TextFormatting.YELLOW + I18n.format("sidebutton.refinedstorage:mode." + (getMode(stack) == IFilter.MODE_WHITELIST ? "whitelist" : "blacklist")) + TextFormatting.RESET);
|
||||
|
||||
if (isModFilter(stack)) {
|
||||
tooltip.add(TextFormatting.BLUE + I18n.format("gui.refinedstorage:filter.mod_filter") + TextFormatting.RESET);
|
||||
@@ -106,7 +104,7 @@ public class ItemFilter extends ItemBase {
|
||||
}
|
||||
|
||||
public static int getMode(ItemStack stack) {
|
||||
return (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_MODE)) ? stack.getTagCompound().getInteger(NBT_MODE) : MODE_WHITELIST;
|
||||
return (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_MODE)) ? stack.getTagCompound().getInteger(NBT_MODE) : IFilter.MODE_WHITELIST;
|
||||
}
|
||||
|
||||
public static void setMode(ItemStack stack, int mode) {
|
||||
|
||||
Reference in New Issue
Block a user