Give drive better interface.
This commit is contained in:
@@ -1,73 +1,25 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.container.slot.BasicItemValidator;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import refinedstorage.tile.TileDrive;
|
||||
|
||||
public class ContainerDrive extends ContainerBase
|
||||
public class ContainerDrive extends ContainerStorage
|
||||
{
|
||||
public ContainerDrive(EntityPlayer player, TileDrive drive)
|
||||
{
|
||||
super(player);
|
||||
super(player, drive.getInventory());
|
||||
|
||||
int x = 8;
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
addSlotToContainer(new SlotFiltered(drive, i, x, y, new BasicItemValidator(RefinedStorageItems.STORAGE_CELL)));
|
||||
|
||||
if ((i + 1) % 2 == 0)
|
||||
{
|
||||
x = 8;
|
||||
y += 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
x += 18;
|
||||
}
|
||||
addSlotToContainer(new SlotFiltered(drive, i, 98 + (i * 18), 78, new BasicItemValidator(RefinedStorageItems.STORAGE_CELL)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 108);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
|
||||
Slot slot = getSlot(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
stack = slot.getStack().copy();
|
||||
|
||||
if (index < 8)
|
||||
{
|
||||
if (!mergeItemStack(stack, 8, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
addSlotToContainer(new SlotFiltered(drive, 4 + i, 98 + (i * 18), 96, new BasicItemValidator(RefinedStorageItems.STORAGE_CELL)));
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(stack, 0, 8, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stack.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package refinedstorage.gui;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.container.ContainerDrive;
|
||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.tile.TileDrive;
|
||||
|
||||
public class GuiDrive extends GuiBase
|
||||
{
|
||||
private TileDrive drive;
|
||||
|
||||
private GuiTextField priorityField;
|
||||
|
||||
public GuiDrive(ContainerDrive container, TileDrive drive)
|
||||
{
|
||||
super(container, 176, 190);
|
||||
|
||||
this.drive = drive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y)
|
||||
{
|
||||
addSideButton(new SideButtonRedstoneMode(drive));
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 52 + 1, y + 32 + 1, 25, fontRendererObj.FONT_HEIGHT);
|
||||
priorityField.setText(String.valueOf(drive.getPriority()));
|
||||
priorityField.setEnableBackgroundDrawing(false);
|
||||
priorityField.setVisible(true);
|
||||
priorityField.setTextColor(16777215);
|
||||
priorityField.setCanLoseFocus(false);
|
||||
priorityField.setFocused(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture("gui/drive.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
|
||||
priorityField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY)
|
||||
{
|
||||
drawString(7, 7, t("gui.refinedstorage:drive"));
|
||||
drawString(51, 20, t("misc.refinedstorage:priority"));
|
||||
drawString(7, 96, t("container.inventory"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int keyCode) throws IOException
|
||||
{
|
||||
if (!checkHotbarKeys(keyCode) && priorityField.textboxKeyTyped(character, keyCode))
|
||||
{
|
||||
Integer result = Ints.tryParse(priorityField.getText());
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
RefinedStorage.NETWORK.sendToServer(new MessagePriorityUpdate(drive.getPos(), result));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped(character, keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class GuiHandler implements IGuiHandler
|
||||
case RefinedStorageGui.GRID:
|
||||
return new GuiGrid((ContainerGrid) getContainer(ID, player, tile), (TileGrid) tile);
|
||||
case RefinedStorageGui.DRIVE:
|
||||
return new GuiDrive((ContainerDrive) getContainer(ID, player, tile), (TileDrive) tile);
|
||||
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile, "gui/drive.png");
|
||||
case RefinedStorageGui.IMPORTER:
|
||||
return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), (TileImporter) tile);
|
||||
case RefinedStorageGui.EXPORTER:
|
||||
|
||||
@@ -13,6 +13,7 @@ import refinedstorage.util.InventoryUtils;
|
||||
public class GuiStorage extends GuiBase
|
||||
{
|
||||
private IStorageGui gui;
|
||||
private String texture;
|
||||
|
||||
private GuiTextField priorityField;
|
||||
|
||||
@@ -21,11 +22,17 @@ public class GuiStorage extends GuiBase
|
||||
private int barWidth = 16;
|
||||
private int barHeight = 58;
|
||||
|
||||
public GuiStorage(ContainerStorage container, IStorageGui gui)
|
||||
public GuiStorage(ContainerStorage container, IStorageGui gui, String texture)
|
||||
{
|
||||
super(container, 176, 211);
|
||||
|
||||
this.gui = gui;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public GuiStorage(ContainerStorage container, IStorageGui gui)
|
||||
{
|
||||
this(container, gui, "gui/storage.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,8 +54,8 @@ public class GuiStorage extends GuiBase
|
||||
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_NBT));
|
||||
}
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 116 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT);
|
||||
priorityField.setText(String.valueOf(gui.getStorage().getPriority()));
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT);
|
||||
priorityField.setText(String.valueOf(gui.getPriority()));
|
||||
priorityField.setEnableBackgroundDrawing(false);
|
||||
priorityField.setVisible(true);
|
||||
priorityField.setTextColor(16777215);
|
||||
@@ -64,7 +71,7 @@ public class GuiStorage extends GuiBase
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture("gui/storage.png");
|
||||
bindTexture(texture);
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
|
||||
@@ -80,7 +87,7 @@ public class GuiStorage extends GuiBase
|
||||
{
|
||||
drawString(7, 7, t(gui.getName()));
|
||||
drawString(7, 42, t("misc.refinedstorage:storage"));
|
||||
drawString(115, 42, t("misc.refinedstorage:priority"));
|
||||
drawString(97, 42, t("misc.refinedstorage:priority"));
|
||||
drawString(7, 117, t("container.inventory"));
|
||||
|
||||
drawString(30, 54, t("misc.refinedstorage:storage.stored", gui.getStored()));
|
||||
|
||||
@@ -2,12 +2,29 @@ package refinedstorage.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.item.ItemStorageCell;
|
||||
import refinedstorage.tile.TileDrive;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
|
||||
public class CellStorage extends NBTStorage
|
||||
{
|
||||
public CellStorage(ItemStack cell, int priority)
|
||||
private TileDrive drive;
|
||||
|
||||
public CellStorage(ItemStack cell, TileDrive drive)
|
||||
{
|
||||
super(cell.getTagCompound(), getCapacity(cell), priority);
|
||||
super(cell.getTagCompound(), getCapacity(cell), drive.getPriority());
|
||||
|
||||
this.drive = drive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPush(ItemStack stack)
|
||||
{
|
||||
if (ModeSettingUtils.doesNotViolateMode(drive.getInventory(), drive.getWhitelistBlacklistSetting(), drive.getCompare(), stack))
|
||||
{
|
||||
return super.canPush(stack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getCapacity(ItemStack cell)
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface IStorageGui
|
||||
|
||||
public String getName();
|
||||
|
||||
public IStorage getStorage();
|
||||
public int getPriority();
|
||||
|
||||
public IInventory getInventory();
|
||||
|
||||
|
||||
@@ -7,19 +7,30 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.CellStorage;
|
||||
import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageGui;
|
||||
import refinedstorage.storage.IStorageProvider;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileDrive extends TileMachine implements IInventory, IStorageProvider
|
||||
public class TileDrive extends TileMachine implements IStorageProvider, IStorageGui, ICompareSetting, IModeSetting, IInventory
|
||||
{
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("drive", 8);
|
||||
private InventorySimple filterInventory = new InventorySimple("filters", 9, this);
|
||||
private InventorySimple inventory = new InventorySimple("drive", 8, this);
|
||||
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
private int mode = 0;
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage()
|
||||
@@ -42,6 +53,161 @@ public class TileDrive extends TileMachine implements IInventory, IStorageProvid
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorages(List<IStorage> storages)
|
||||
{
|
||||
for (int i = 0; i < getSizeInventory(); ++i)
|
||||
{
|
||||
if (getStackInSlot(i) != null)
|
||||
{
|
||||
storages.add(new CellStorage(getStackInSlot(i), this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
InventoryUtils.restoreInventory(filterInventory, 0, nbt);
|
||||
InventoryUtils.restoreInventory(inventory, 1, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_PRIORITY))
|
||||
{
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
}
|
||||
|
||||
if (nbt.hasKey(NBT_COMPARE))
|
||||
{
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
}
|
||||
|
||||
if (nbt.hasKey(NBT_MODE))
|
||||
{
|
||||
mode = nbt.getInteger(NBT_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
InventoryUtils.saveInventory(filterInventory, 0, nbt);
|
||||
InventoryUtils.saveInventory(inventory, 1, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
nbt.setInteger(NBT_MODE, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
super.toBytes(buf);
|
||||
|
||||
buf.writeInt(priority);
|
||||
buf.writeInt(compare);
|
||||
buf.writeInt(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
super.fromBytes(buf);
|
||||
|
||||
priority = buf.readInt();
|
||||
compare = buf.readInt();
|
||||
mode = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompare()
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompare(int compare)
|
||||
{
|
||||
markDirty();
|
||||
|
||||
this.compare = compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelist()
|
||||
{
|
||||
return mode == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklist()
|
||||
{
|
||||
return mode == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToWhitelist()
|
||||
{
|
||||
markDirty();
|
||||
|
||||
this.mode = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToBlacklist()
|
||||
{
|
||||
markDirty();
|
||||
|
||||
this.mode = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "block.refinedstorage:drive.name";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return filterInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModeSetting getWhitelistBlacklistSetting()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPriorityHandler getPriorityHandler()
|
||||
{
|
||||
return new IPriorityHandler()
|
||||
{
|
||||
@Override
|
||||
public void onPriorityChanged(int priority)
|
||||
{
|
||||
RefinedStorage.NETWORK.sendToServer(new MessagePriorityUpdate(pos, priority));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return priority;
|
||||
@@ -55,54 +221,15 @@ public class TileDrive extends TileMachine implements IInventory, IStorageProvid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
public int getStored()
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
InventoryUtils.restoreInventory(this, 0, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_PRIORITY))
|
||||
{
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
public int getCapacity()
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
InventoryUtils.saveInventory(this, 0, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
super.toBytes(buf);
|
||||
|
||||
buf.writeInt(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
super.fromBytes(buf);
|
||||
|
||||
priority = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorages(List<IStorage> storages)
|
||||
{
|
||||
for (int i = 0; i < getSizeInventory(); ++i)
|
||||
{
|
||||
if (getStackInSlot(i) != null)
|
||||
{
|
||||
storages.add(new CellStorage(getStackInSlot(i), priority));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,12 +316,6 @@ public class TileDrive extends TileMachine implements IInventory, IStorageProvid
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileExternalStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting, IModeSetting
|
||||
@@ -127,7 +128,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
return TileStorage.checkWhitelistBlacklist(inventory, this, compare, stack) && InventoryUtils.canPushToInventory(connectedInventory, stack);
|
||||
return ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack) && InventoryUtils.canPushToInventory(connectedInventory, stack);
|
||||
}
|
||||
|
||||
public IInventory getConnectedInventory()
|
||||
@@ -266,12 +267,6 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
return "gui.refinedstorage:external_storage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorage getStorage()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.block.BlockStorage;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
@@ -20,6 +21,7 @@ import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting, IModeSetting
|
||||
@@ -99,10 +101,15 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
}
|
||||
|
||||
public EnumStorageType getType()
|
||||
{
|
||||
if (worldObj.getBlockState(pos).getBlock() == RefinedStorageBlocks.STORAGE)
|
||||
{
|
||||
return ((EnumStorageType) worldObj.getBlockState(pos).getValue(BlockStorage.TYPE));
|
||||
}
|
||||
|
||||
return EnumStorageType.TYPE_1K;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
@@ -154,48 +161,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
@Override
|
||||
public boolean canPush(ItemStack stack)
|
||||
{
|
||||
return checkWhitelistBlacklist(inventory, this, compare, stack) && getStorage().canPush(stack);
|
||||
}
|
||||
|
||||
public static boolean checkWhitelistBlacklist(IInventory inventory, IModeSetting mode, int compare, ItemStack stack)
|
||||
{
|
||||
if (mode.isWhitelist())
|
||||
{
|
||||
int slots = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
slots++;
|
||||
|
||||
if (InventoryUtils.compareStack(slot, stack, compare))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return slots == 0;
|
||||
}
|
||||
else if (mode.isBlacklist())
|
||||
{
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null && InventoryUtils.compareStack(slot, stack, compare))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack) && getStorage().canPush(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -283,7 +249,6 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTStorage getStorage()
|
||||
{
|
||||
return new NBTStorage(tag, getCapacity(), priority);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package refinedstorage.tile.settings;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class ModeSettingUtils
|
||||
{
|
||||
public static boolean doesNotViolateMode(IInventory inventory, IModeSetting mode, int compare, ItemStack stack)
|
||||
{
|
||||
if (mode.isWhitelist())
|
||||
{
|
||||
int slots = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
slots++;
|
||||
|
||||
if (InventoryUtils.compareStack(slot, stack, compare))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return slots == 0;
|
||||
}
|
||||
else if (mode.isBlacklist())
|
||||
{
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null && InventoryUtils.compareStack(slot, stack, compare))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user