Rename some more terms
This commit is contained in:
@@ -298,19 +298,19 @@ public final class RefinedStorageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack takeFromNetwork(INetworkMaster network, ItemStack stack, int size) {
|
||||
return network.take(stack, size, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
||||
public static ItemStack extractItem(INetworkMaster network, ItemStack stack, int size) {
|
||||
return network.extractItem(stack, size, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
||||
}
|
||||
|
||||
public static ItemStack getFromNetwork(INetworkMaster network, ItemStack stack) {
|
||||
public static ItemStack getItem(INetworkMaster network, ItemStack stack) {
|
||||
return network.getStorage().get(stack, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
||||
}
|
||||
|
||||
public static ICraftingPattern getPatternFromNetwork(INetworkMaster network, ItemStack stack) {
|
||||
public static ICraftingPattern getPattern(INetworkMaster network, ItemStack stack) {
|
||||
return network.getPattern(stack, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
|
||||
}
|
||||
|
||||
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
||||
return RefinedStorageUtils.getPatternFromNetwork(network, stack) != null;
|
||||
return RefinedStorageUtils.getPattern(network, stack) != null;
|
||||
}
|
||||
}
|
||||
|
||||
10
src/main/java/refinedstorage/api/network/GridExtractFlags.java
Executable file
10
src/main/java/refinedstorage/api/network/GridExtractFlags.java
Executable file
@@ -0,0 +1,10 @@
|
||||
package refinedstorage.api.network;
|
||||
|
||||
/**
|
||||
* Flags for knowing what extract action the player is performing, these can be combined.
|
||||
*/
|
||||
public class GridExtractFlags {
|
||||
public static final int EXTRACT_HALF = 1;
|
||||
public static final int EXTRACT_SINGLE = 2;
|
||||
public static final int EXTRACT_SHIFT = 4;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package refinedstorage.api.network;
|
||||
|
||||
/**
|
||||
* Flags for knowing what pull action the player is performing, these can be combined.
|
||||
*/
|
||||
public class GridPullFlags {
|
||||
public static final int PULL_HALF = 1;
|
||||
public static final int PULL_SINGLE = 2;
|
||||
public static final int PULL_SHIFT = 4;
|
||||
}
|
||||
@@ -10,30 +10,30 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public interface IGridHandler {
|
||||
/**
|
||||
* Called when a player tries to pull an item from the grid.
|
||||
* Called when a player tries to extract an item from the grid.
|
||||
*
|
||||
* @param stack The item we're trying to pull
|
||||
* @param flags How we are pulling, see {@link GridPullFlags}
|
||||
* @param player The player that is attempting the pull
|
||||
* @param stack The item we're trying to extract
|
||||
* @param flags How we are extracting, see {@link GridExtractFlags}
|
||||
* @param player The player that is attempting the extraction
|
||||
*/
|
||||
void onPull(ItemStack stack, int flags, EntityPlayerMP player);
|
||||
void onExtract(ItemStack stack, int flags, EntityPlayerMP player);
|
||||
|
||||
/**
|
||||
* Called when a player tries to push to the grid.
|
||||
* Called when a player tries to insert an item to the grid.
|
||||
*
|
||||
* @param stack The item we're trying to push
|
||||
* @param stack The item we're trying to insert
|
||||
* @return The remainder, or null if there is no remainder
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack onPush(ItemStack stack);
|
||||
ItemStack onInsert(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Called when a player is trying to push 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 single If we are only pushing 1 item
|
||||
* @param player The player that is attempting the push
|
||||
* @param single If we are only inserting 1 item
|
||||
* @param player The player that is attempting the insert
|
||||
*/
|
||||
void onHeldItemPush(boolean single, EntityPlayerMP player);
|
||||
void onInsertHeldItem(boolean single, EntityPlayerMP player);
|
||||
|
||||
/**
|
||||
* Called when a player requested crafting for an item.
|
||||
|
||||
@@ -147,24 +147,24 @@ public interface INetworkMaster {
|
||||
void sendStorageDeltaToClient(ItemStack stack, int delta);
|
||||
|
||||
/**
|
||||
* Pushes an item to this network.
|
||||
* Inserts an item to this network.
|
||||
*
|
||||
* @param stack The stack prototype to push, do NOT modify
|
||||
* @param size The amount of that prototype that has to be pushed
|
||||
* @param stack The stack prototype to insert, do NOT modify
|
||||
* @param size The amount of that prototype that has to be inserted
|
||||
* @param simulate If we are simulating
|
||||
* @return null if the push was successful, or a {@link ItemStack} with the remainder
|
||||
* @return null if the insert was successful, or an {@link ItemStack} with the remainder
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack push(@Nonnull ItemStack stack, int size, boolean simulate);
|
||||
ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate);
|
||||
|
||||
/**
|
||||
* Takes an item from this network.
|
||||
* Extracts an item from this network.
|
||||
*
|
||||
* @param stack The prototype of the stack to take, do NOT modify
|
||||
* @param size The amount of that prototype that has to be taken
|
||||
* @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 flags The flags to compare on, see {@link CompareFlags}
|
||||
* @return null if we didn't take anything, or a {@link ItemStack} with the result
|
||||
* @return null if we didn't extract anything, or a {@link ItemStack} with the result
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack take(@Nonnull ItemStack stack, int size, int flags);
|
||||
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);
|
||||
}
|
||||
|
||||
@@ -17,28 +17,29 @@ public interface IStorage {
|
||||
List<ItemStack> getItems();
|
||||
|
||||
/**
|
||||
* Pushes an item to this storage.
|
||||
* Inserts an item to this storage.
|
||||
*
|
||||
* @param stack The stack prototype to push, do NOT modify
|
||||
* @param size The amount of that prototype that has to be pushed
|
||||
* @param stack The stack prototype to insert, do NOT modify
|
||||
* @param size The amount of that prototype that has to be inserted
|
||||
* @param simulate If we are simulating
|
||||
* @return null if the push was successful, or a {@link ItemStack} with the remainder
|
||||
* @return null if the insert was successful, or a {@link ItemStack} with the remainder
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack push(@Nonnull ItemStack stack, int size, boolean simulate);
|
||||
ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate);
|
||||
|
||||
/**
|
||||
* Takes an item from storage.
|
||||
* Extracts an item from storage.
|
||||
*
|
||||
* If the stack we found in the system is smaller than the requested size, return the stack anyway.
|
||||
* For example: if 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}
|
||||
* @return null if we didn't take anything, or a {@link ItemStack} with the result
|
||||
* @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 flags On what we are comparing to extract this item, see {@link CompareFlags}
|
||||
* @return null if we didn't extract anything, or an {@link ItemStack} with the result
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack take(@Nonnull ItemStack stack, int size, int flags);
|
||||
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);
|
||||
|
||||
/**
|
||||
* @return The amount of items stored in this storage
|
||||
|
||||
@@ -67,14 +67,14 @@ public class BasicCraftingTask implements ICraftingTask {
|
||||
if (!satisfied[i]) {
|
||||
done = false;
|
||||
|
||||
ItemStack took = RefinedStorageUtils.takeFromNetwork(network, input, 1);
|
||||
ItemStack took = RefinedStorageUtils.extractItem(network, input, 1);
|
||||
|
||||
if (took != null) {
|
||||
itemsTook.add(took);
|
||||
|
||||
satisfied[i] = true;
|
||||
} else if (!childTasks[i]) {
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPatternFromNetwork(network, input);
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPattern(network, input);
|
||||
|
||||
if (pattern != null) {
|
||||
network.addCraftingTask(network.createCraftingTask(pattern));
|
||||
@@ -96,12 +96,12 @@ public class BasicCraftingTask implements ICraftingTask {
|
||||
@Override
|
||||
public void onDone(INetworkMaster network) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
network.push(output, output.stackSize, false);
|
||||
network.insertItem(output, output.stackSize, false);
|
||||
}
|
||||
|
||||
if (pattern.getByproducts() != null) {
|
||||
for (ItemStack byproduct : pattern.getByproducts()) {
|
||||
network.push(byproduct, byproduct.stackSize, false);
|
||||
network.insertItem(byproduct, byproduct.stackSize, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class BasicCraftingTask implements ICraftingTask {
|
||||
@Override
|
||||
public void onCancelled(INetworkMaster network) {
|
||||
for (ItemStack took : itemsTook) {
|
||||
network.push(took, took.stackSize, false);
|
||||
network.insertItem(took, took.stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
||||
for (int i = 0; i < inserted.length; ++i) {
|
||||
if (!inserted[i]) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
ItemStack took = RefinedStorageUtils.takeFromNetwork(network, input, 1);
|
||||
ItemStack took = RefinedStorageUtils.extractItem(network, input, 1);
|
||||
|
||||
if (took != null) {
|
||||
if (ItemHandlerHelper.insertItem(container.getConnectedItems(), took, true) == null) {
|
||||
@@ -60,10 +60,10 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
||||
|
||||
inserted[i] = true;
|
||||
} else {
|
||||
network.push(took, took.stackSize, false);
|
||||
network.insertItem(took, took.stackSize, false);
|
||||
}
|
||||
} else if (!childTasks[i]) {
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPatternFromNetwork(network, input);
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPattern(network, input);
|
||||
|
||||
if (pattern != null) {
|
||||
childTasks[i] = true;
|
||||
@@ -90,7 +90,7 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onPushed(ItemStack inserted) {
|
||||
public void onInserted(ItemStack inserted) {
|
||||
for (int i = 0; i < pattern.getOutputs().length; ++i) {
|
||||
if (!satisfied[i] && RefinedStorageUtils.compareStackNoQuantity(inserted, pattern.getOutputs()[i])) {
|
||||
satisfied[i] = true;
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.GridExtractFlags;
|
||||
import refinedstorage.api.network.IGridHandler;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
|
||||
@@ -20,8 +20,8 @@ public class GridHandler implements IGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPull(ItemStack stack, int flags, EntityPlayerMP player) {
|
||||
ItemStack item = RefinedStorageUtils.getFromNetwork(network, stack);
|
||||
public void onExtract(ItemStack stack, int flags, EntityPlayerMP player) {
|
||||
ItemStack item = RefinedStorageUtils.getItem(network, stack);
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
@@ -29,7 +29,7 @@ public class GridHandler implements IGridHandler {
|
||||
|
||||
int itemSize = item.stackSize;
|
||||
|
||||
boolean single = (flags & GridPullFlags.PULL_SINGLE) == GridPullFlags.PULL_SINGLE;
|
||||
boolean single = (flags & GridExtractFlags.EXTRACT_SINGLE) == GridExtractFlags.EXTRACT_SINGLE;
|
||||
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class GridHandler implements IGridHandler {
|
||||
|
||||
int size = 64;
|
||||
|
||||
if ((flags & GridPullFlags.PULL_HALF) == GridPullFlags.PULL_HALF && itemSize > 1) {
|
||||
if ((flags & GridExtractFlags.EXTRACT_HALF) == GridExtractFlags.EXTRACT_HALF && itemSize > 1) {
|
||||
size = itemSize / 2;
|
||||
|
||||
if (size > 32) {
|
||||
@@ -51,16 +51,16 @@ public class GridHandler implements IGridHandler {
|
||||
}
|
||||
} else if (single) {
|
||||
size = 1;
|
||||
} else if ((flags & GridPullFlags.PULL_SHIFT) == GridPullFlags.PULL_SHIFT) {
|
||||
} else if ((flags & GridExtractFlags.EXTRACT_SHIFT) == GridExtractFlags.EXTRACT_SHIFT) {
|
||||
// NO OP, the quantity already set (64) is needed for shift
|
||||
}
|
||||
|
||||
size = Math.min(size, stack.getItem().getItemStackLimit(stack));
|
||||
|
||||
ItemStack took = RefinedStorageUtils.takeFromNetwork(network, stack, size);
|
||||
ItemStack took = RefinedStorageUtils.extractItem(network, stack, size);
|
||||
|
||||
if (took != null) {
|
||||
if ((flags & GridPullFlags.PULL_SHIFT) == GridPullFlags.PULL_SHIFT) {
|
||||
if ((flags & GridExtractFlags.EXTRACT_SHIFT) == GridExtractFlags.EXTRACT_SHIFT) {
|
||||
if (!player.inventory.addItemStackToInventory(took.copy())) {
|
||||
InventoryHelper.spawnItemStack(player.worldObj, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), took);
|
||||
}
|
||||
@@ -74,17 +74,17 @@ public class GridHandler implements IGridHandler {
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
network.getWirelessGridHandler().drainEnergy(player, WirelessGridHandler.USAGE_PULL);
|
||||
network.getWirelessGridHandler().drainEnergy(player, WirelessGridHandler.USAGE_EXTRACT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onPush(ItemStack stack) {
|
||||
return network.push(stack, stack.stackSize, false);
|
||||
public ItemStack onInsert(ItemStack stack) {
|
||||
return network.insertItem(stack, stack.stackSize, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeldItemPush(boolean single, EntityPlayerMP player) {
|
||||
public void onInsertHeldItem(boolean single, EntityPlayerMP player) {
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -93,8 +93,8 @@ public class GridHandler implements IGridHandler {
|
||||
int size = single ? 1 : stack.stackSize;
|
||||
|
||||
if (single) {
|
||||
if (network.push(stack, size, true) == null) {
|
||||
network.push(stack, size, false);
|
||||
if (network.insertItem(stack, size, true) == null) {
|
||||
network.insertItem(stack, size, false);
|
||||
|
||||
stack.stackSize -= size;
|
||||
|
||||
@@ -103,12 +103,12 @@ public class GridHandler implements IGridHandler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(network.push(stack, size, false));
|
||||
player.inventory.setItemStack(network.insertItem(stack, size, false));
|
||||
}
|
||||
|
||||
player.updateHeldItem();
|
||||
|
||||
network.getWirelessGridHandler().drainEnergy(player, WirelessGridHandler.USAGE_PUSH);
|
||||
network.getWirelessGridHandler().drainEnergy(player, WirelessGridHandler.USAGE_INSERT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ public class GridHandler implements IGridHandler {
|
||||
|
||||
int quantityPerRequest = 0;
|
||||
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPatternFromNetwork(network, stack);
|
||||
ICraftingPattern pattern = RefinedStorageUtils.getPattern(network, stack);
|
||||
|
||||
if (pattern != null) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
|
||||
public class WirelessGridHandler implements IWirelessGridHandler {
|
||||
public static final int USAGE_OPEN = 30;
|
||||
public static final int USAGE_PULL = 3;
|
||||
public static final int USAGE_PUSH = 3;
|
||||
public static final int USAGE_EXTRACT = 3;
|
||||
public static final int USAGE_INSERT = 3;
|
||||
|
||||
private INetworkMaster network;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class NBTStorage implements IStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
for (ItemStack otherStack : stacks) {
|
||||
if (RefinedStorageUtils.compareStackNoQuantity(otherStack, stack)) {
|
||||
if (getCapacity() != -1 && getStored() + size > getCapacity()) {
|
||||
@@ -178,7 +178,7 @@ public abstract class NBTStorage implements IStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack take(ItemStack stack, int size, int flags) {
|
||||
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
||||
for (ItemStack otherStack : stacks) {
|
||||
if (RefinedStorageUtils.compareStack(otherStack, stack, flags)) {
|
||||
if (size > otherStack.stackSize) {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ContainerGrid extends ContainerBase {
|
||||
if (slot == craftingResultSlot) {
|
||||
((TileGrid) grid).onCraftedShift(this, player);
|
||||
} else if (grid.getGridHandler() != null && slot != patternResultSlot && !(slot instanceof SlotSpecimenLegacy) && slot.getHasStack()) {
|
||||
slot.putStack(grid.getGridHandler().onPush(slot.getStack()));
|
||||
slot.putStack(grid.getGridHandler().onInsert(slot.getStack()));
|
||||
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
@@ -12,7 +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.api.network.GridExtractFlags;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode;
|
||||
@@ -21,7 +21,7 @@ import refinedstorage.gui.sidebutton.SideButtonGridSortingType;
|
||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import refinedstorage.jei.RefinedStorageJEIPlugin;
|
||||
import refinedstorage.network.MessageGridCraftingClear;
|
||||
import refinedstorage.network.MessageGridHeldPush;
|
||||
import refinedstorage.network.MessageGridInsertHeld;
|
||||
import refinedstorage.network.MessageGridPatternCreate;
|
||||
import refinedstorage.network.MessageGridPull;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
@@ -353,7 +353,7 @@ public class GuiGrid extends GuiBase {
|
||||
ItemStack held = container.getPlayer().inventory.getItemStack();
|
||||
|
||||
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && held != null && (clickedButton == 0 || clickedButton == 1)) {
|
||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridHeldPush(clickedButton == 1));
|
||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridInsertHeld(clickedButton == 1));
|
||||
}
|
||||
|
||||
if (isOverSlotWithItem() && (held == null || (held != null && clickedButton == 2))) {
|
||||
@@ -363,15 +363,15 @@ public class GuiGrid extends GuiBase {
|
||||
int flags = 0;
|
||||
|
||||
if (clickedButton == 1) {
|
||||
flags |= GridPullFlags.PULL_HALF;
|
||||
flags |= GridExtractFlags.EXTRACT_HALF;
|
||||
}
|
||||
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
flags |= GridPullFlags.PULL_SHIFT;
|
||||
flags |= GridExtractFlags.EXTRACT_SHIFT;
|
||||
}
|
||||
|
||||
if (clickedButton == 2) {
|
||||
flags |= GridPullFlags.PULL_SINGLE;
|
||||
flags |= GridExtractFlags.EXTRACT_SINGLE;
|
||||
}
|
||||
|
||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPull(items.get(slotNumber), flags));
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ItemStorageDisk extends ItemBase {
|
||||
item.getSubItems(item, CreativeTabs.INVENTORY, stacks);
|
||||
|
||||
for (ItemStack itemStack : stacks) {
|
||||
storage.push(itemStack, 1000, false);
|
||||
storage.insertItem(itemStack, 1000, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
|
||||
ItemStack slot = grid.getMatrix().getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
grid.getMatrix().setInventorySlotContents(i, grid.getNetwork().push(slot, slot.stackSize, false));
|
||||
grid.getMatrix().setInventorySlotContents(i, grid.getNetwork().insertItem(slot, slot.stackSize, false));
|
||||
}
|
||||
}
|
||||
} else if (grid.getType() == EnumGridType.PATTERN) {
|
||||
|
||||
@@ -7,13 +7,13 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.api.network.IGridHandler;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
|
||||
public class MessageGridHeldPush extends MessageHandlerPlayerToServer<MessageGridHeldPush> implements IMessage {
|
||||
public class MessageGridInsertHeld extends MessageHandlerPlayerToServer<MessageGridInsertHeld> implements IMessage {
|
||||
private boolean single;
|
||||
|
||||
public MessageGridHeldPush() {
|
||||
public MessageGridInsertHeld() {
|
||||
}
|
||||
|
||||
public MessageGridHeldPush(boolean single) {
|
||||
public MessageGridInsertHeld(boolean single) {
|
||||
this.single = single;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ public class MessageGridHeldPush extends MessageHandlerPlayerToServer<MessageGri
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageGridHeldPush message, EntityPlayerMP player) {
|
||||
public void handle(MessageGridInsertHeld message, EntityPlayerMP player) {
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container instanceof ContainerGrid) {
|
||||
IGridHandler handler = ((ContainerGrid) container).getGrid().getGridHandler();
|
||||
|
||||
if (handler != null) {
|
||||
handler.onHeldItemPush(message.single, player);
|
||||
handler.onInsertHeldItem(message.single, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class MessageGridPull extends MessageHandlerPlayerToServer<MessageGridPul
|
||||
IGridHandler handler = ((ContainerGrid) container).getGrid().getGridHandler();
|
||||
|
||||
if (handler != null) {
|
||||
handler.onPull(message.stack, message.flags, player);
|
||||
handler.onExtract(message.stack, message.flags, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CommonProxy {
|
||||
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageTileContainerUpdate.class, MessageTileContainerUpdate.class, id++, Side.CLIENT);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageRedstoneModeUpdate.class, MessageRedstoneModeUpdate.class, id++, Side.SERVER);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridHeldPush.class, MessageGridHeldPush.class, id++, Side.SERVER);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridInsertHeld.class, MessageGridInsertHeld.class, id++, Side.SERVER);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridPull.class, MessageGridPull.class, id++, Side.SERVER);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageCompareUpdate.class, MessageCompareUpdate.class, id++, Side.SERVER);
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageModeToggle.class, MessageModeToggle.class, id++, Side.SERVER);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TileConstructor extends TileNode implements ICompareConfig {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
|
||||
if (worldObj.isAirBlock(front) && block.getBlock().canPlaceBlockAt(worldObj, front)) {
|
||||
ItemStack took = network.take(filter.getStackInSlot(0), 1, compare);
|
||||
ItemStack took = network.extractItem(filter.getStackInSlot(0), 1, compare);
|
||||
|
||||
if (took != null) {
|
||||
scheduler.resetSchedule();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TileDestructor extends TileNode implements ICompareConfig, IModeCon
|
||||
if (network == null) {
|
||||
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop);
|
||||
} else {
|
||||
ItemStack remainder = network.push(drop, drop.stackSize, false);
|
||||
ItemStack remainder = network.insertItem(drop, drop.stackSize, false);
|
||||
|
||||
if (remainder != null) {
|
||||
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), remainder);
|
||||
|
||||
@@ -38,12 +38,12 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
if (!ModeFilter.respectsMode(getFilters(), getModeConfig(), getCompare(), stack)) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.push(stack, size, simulate);
|
||||
return super.insertItem(stack, size, simulate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TileExporter extends TileNode implements ICompareConfig {
|
||||
ItemStack slot = filters.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
ItemStack took = network.take(slot, size, compare);
|
||||
ItemStack took = network.extractItem(slot, size, compare);
|
||||
|
||||
if (took != null) {
|
||||
scheduler.resetSchedule();
|
||||
@@ -59,7 +59,7 @@ public class TileExporter extends TileNode implements ICompareConfig {
|
||||
ItemStack remainder = ItemHandlerHelper.insertItem(handler, took, false);
|
||||
|
||||
if (remainder != null) {
|
||||
network.push(remainder, remainder.stackSize, false);
|
||||
network.insertItem(remainder, remainder.stackSize, false);
|
||||
}
|
||||
} else if (RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_CRAFTING)) {
|
||||
if (scheduler.canSchedule(compare, slot)) {
|
||||
|
||||
@@ -64,8 +64,8 @@ public class TileImporter extends TileNode implements ICompareConfig, IModeConfi
|
||||
|
||||
ItemStack result = handler.extractItem(currentSlot, quantity, true);
|
||||
|
||||
if (result != null && network.push(result, result.stackSize, true) == null) {
|
||||
network.push(result, result.stackSize, false);
|
||||
if (result != null && network.insertItem(result, result.stackSize, true) == null) {
|
||||
network.insertItem(result, result.stackSize, false);
|
||||
|
||||
handler.extractItem(currentSlot, quantity, false);
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TileInterface extends TileNode implements ICompareConfig {
|
||||
} else if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
||||
int size = Math.min(slot.stackSize, RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1);
|
||||
|
||||
ItemStack remainder = network.push(slot, size, false);
|
||||
ItemStack remainder = network.insertItem(slot, size, false);
|
||||
|
||||
if (remainder == null) {
|
||||
importItems.extractItem(currentSlot, size, false);
|
||||
@@ -68,13 +68,13 @@ public class TileInterface extends TileNode implements ICompareConfig {
|
||||
|
||||
if (wanted == null) {
|
||||
if (got != null) {
|
||||
exportItems.setStackInSlot(i, network.push(got, got.stackSize, false));
|
||||
exportItems.setStackInSlot(i, network.insertItem(got, got.stackSize, false));
|
||||
}
|
||||
} else {
|
||||
int delta = got == null ? wanted.stackSize : (wanted.stackSize - got.stackSize);
|
||||
|
||||
if (delta > 0) {
|
||||
ItemStack result = network.take(wanted, delta, compare);
|
||||
ItemStack result = network.extractItem(wanted, delta, compare);
|
||||
|
||||
if (result != null) {
|
||||
if (got == null) {
|
||||
@@ -84,7 +84,7 @@ public class TileInterface extends TileNode implements ICompareConfig {
|
||||
}
|
||||
}
|
||||
} else if (delta < 0) {
|
||||
ItemStack remainder = network.push(got, Math.abs(delta), false);
|
||||
ItemStack remainder = network.insertItem(got, Math.abs(delta), false);
|
||||
|
||||
if (remainder == null) {
|
||||
exportItems.extractItem(i, Math.abs(delta), false);
|
||||
|
||||
@@ -35,12 +35,12 @@ public class TileStorage extends TileNode implements IStorageProvider, IStorageG
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
if (!ModeFilter.respectsMode(filters, TileStorage.this, compare, stack)) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.push(stack, size, simulate);
|
||||
return super.insertItem(stack, size, simulate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
int score = 0;
|
||||
|
||||
for (ItemStack input : patterns.get(i).getInputs()) {
|
||||
ItemStack stored = RefinedStorageUtils.getFromNetwork(this, input);
|
||||
ItemStack stored = RefinedStorageUtils.getItem(this, input);
|
||||
|
||||
score += stored != null ? stored.stackSize : 0;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
if (stack == null || stack.getItem() == null || storage.getStorages().isEmpty()) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
ItemStack remainder = stack;
|
||||
|
||||
for (IStorage storage : this.storage.getStorages()) {
|
||||
remainder = storage.push(remainder, size, simulate);
|
||||
remainder = storage.insertItem(remainder, size, simulate);
|
||||
|
||||
if (remainder == null) {
|
||||
break;
|
||||
@@ -428,34 +428,34 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
int sizePushed = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize;
|
||||
int inserted = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize;
|
||||
|
||||
if (!simulate && sizePushed > 0) {
|
||||
for (int i = 0; i < sizePushed; ++i) {
|
||||
if (!simulate && inserted > 0) {
|
||||
for (int i = 0; i < inserted; ++i) {
|
||||
if (!craftingTasks.empty()) {
|
||||
ICraftingTask top = craftingTasks.peek();
|
||||
|
||||
if (top instanceof ProcessingCraftingTask) {
|
||||
((ProcessingCraftingTask) top).onPushed(stack);
|
||||
((ProcessingCraftingTask) top).onInserted(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
storage.add(ItemHandlerHelper.copyStackWithSize(stack, sizePushed));
|
||||
storage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted));
|
||||
}
|
||||
|
||||
return remainder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack take(ItemStack stack, int size, int flags) {
|
||||
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
||||
int requested = size;
|
||||
int received = 0;
|
||||
|
||||
ItemStack newStack = null;
|
||||
|
||||
for (IStorage storage : this.storage.getStorages()) {
|
||||
ItemStack took = storage.take(stack, requested - received, flags);
|
||||
ItemStack took = storage.extractItem(stack, requested - received, flags);
|
||||
|
||||
if (took != null) {
|
||||
if (newStack == null) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DeepStorageUnitStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (ModeFilter.respectsMode(externalStorage.getFilters(), externalStorage, externalStorage.getCompare(), stack)) {
|
||||
if (unit.getStoredItemType() != null) {
|
||||
if (RefinedStorageUtils.compareStackNoQuantity(unit.getStoredItemType(), stack)) {
|
||||
@@ -85,7 +85,7 @@ public class DeepStorageUnitStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack take(@Nonnull ItemStack stack, int size, int flags) {
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags) {
|
||||
if (RefinedStorageUtils.compareStack(stack, unit.getStoredItemType(), flags)) {
|
||||
if (size > unit.getStoredItemType().stackSize) {
|
||||
size = unit.getStoredItemType().stackSize;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class DrawerStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
if (ModeFilter.respectsMode(externalStorage.getFilters(), externalStorage, externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
|
||||
if (!drawer.isEmpty()) {
|
||||
if (getStored() + size > drawer.getMaxCapacity(stack)) {
|
||||
@@ -87,7 +87,7 @@ public class DrawerStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack take(ItemStack stack, int size, int flags) {
|
||||
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
||||
if (RefinedStorageUtils.compareStack(stack, drawer.getStoredItemPrototype(), flags) && drawer.canItemBeExtracted(stack)) {
|
||||
if (size > drawer.getStoredItemCount()) {
|
||||
size = drawer.getStoredItemCount();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemHandlerStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack push(ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||
if (ModeFilter.respectsMode(externalStorage.getFilters(), externalStorage, externalStorage.getCompare(), stack)) {
|
||||
return ItemHandlerHelper.insertItem(handler, ItemHandlerHelper.copyStackWithSize(stack, size), simulate);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class ItemHandlerStorage extends ExternalStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack take(ItemStack stack, int size, int flags) {
|
||||
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
ItemStack slot = handler.getStackInSlot(i);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
|
||||
if (slot != null) {
|
||||
if (slot.stackSize == 1 && isConnected()) {
|
||||
matrix.setInventorySlotContents(i, RefinedStorageUtils.takeFromNetwork(network, slot, 1));
|
||||
matrix.setInventorySlotContents(i, RefinedStorageUtils.extractItem(network, slot, 1));
|
||||
} else {
|
||||
matrix.decrStackSize(i, 1);
|
||||
}
|
||||
@@ -214,10 +214,10 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
|
||||
if (slot != null) {
|
||||
if (getType() == EnumGridType.CRAFTING) {
|
||||
if (network.push(slot, slot.stackSize, true) != null) {
|
||||
if (network.insertItem(slot, slot.stackSize, true) != null) {
|
||||
return;
|
||||
} else {
|
||||
network.push(slot, slot.stackSize, false);
|
||||
network.insertItem(slot, slot.stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
|
||||
if (getType() == EnumGridType.CRAFTING) {
|
||||
for (ItemStack possibility : possibilities) {
|
||||
ItemStack took = RefinedStorageUtils.takeFromNetwork(network, possibility, 1);
|
||||
ItemStack took = RefinedStorageUtils.extractItem(network, possibility, 1);
|
||||
|
||||
if (took != null) {
|
||||
matrix.setInventorySlotContents(i, possibility);
|
||||
|
||||
Reference in New Issue
Block a user