Added void excess items functionality to storage blocks (counts not working correctly).
This commit is contained in:
		@@ -8,6 +8,7 @@ import refinedstorage.gui.sidebutton.SideButtonCompare;
 | 
			
		||||
import refinedstorage.gui.sidebutton.SideButtonMode;
 | 
			
		||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
			
		||||
import refinedstorage.gui.sidebutton.SideButtonType;
 | 
			
		||||
import refinedstorage.gui.sidebutton.SideButtonVoidExcess;
 | 
			
		||||
import refinedstorage.tile.IStorageGui;
 | 
			
		||||
import refinedstorage.tile.data.TileDataManager;
 | 
			
		||||
 | 
			
		||||
@@ -54,6 +55,10 @@ public class GuiStorage extends GuiBase {
 | 
			
		||||
            addSideButton(new SideButtonCompare(this, gui.getCompareParameter(), CompareUtils.COMPARE_NBT));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(gui.getVoidExcessParameter() != null) {
 | 
			
		||||
            addSideButton(new SideButtonVoidExcess(this, gui.getVoidExcessParameter()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 29, fontRendererObj.FONT_HEIGHT);
 | 
			
		||||
        priorityField.setEnableBackgroundDrawing(false);
 | 
			
		||||
        priorityField.setVisible(true);
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,31 @@
 | 
			
		||||
package refinedstorage.gui.sidebutton;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.util.text.TextFormatting;
 | 
			
		||||
import refinedstorage.gui.GuiBase;
 | 
			
		||||
import refinedstorage.tile.data.TileDataManager;
 | 
			
		||||
import refinedstorage.tile.data.TileDataParameter;
 | 
			
		||||
 | 
			
		||||
public class SideButtonVoidExcess extends SideButton {
 | 
			
		||||
    private TileDataParameter<Boolean> parameter;
 | 
			
		||||
 | 
			
		||||
    public SideButtonVoidExcess(GuiBase gui, TileDataParameter<Boolean> parameter) {
 | 
			
		||||
        super(gui);
 | 
			
		||||
 | 
			
		||||
        this.parameter = parameter;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTooltip() {
 | 
			
		||||
        return TextFormatting.LIGHT_PURPLE + "Void Excess Item Mode" + "\n" + (parameter.getValue() ? "On" : "Off");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void drawButtonIcon(int x, int y) {
 | 
			
		||||
        gui.drawTexture(x, y, parameter.getValue() ? 16 : 0, 192, 16, 16);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void actionPerformed() {
 | 
			
		||||
        TileDataManager.setParameter(parameter, !parameter.getValue());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -15,6 +15,8 @@ public interface IStorageGui {
 | 
			
		||||
 | 
			
		||||
    TileDataParameter<Integer> getPriorityParameter();
 | 
			
		||||
 | 
			
		||||
    TileDataParameter<Boolean> getVoidExcessParameter();
 | 
			
		||||
 | 
			
		||||
    int getStored();
 | 
			
		||||
 | 
			
		||||
    int getCapacity();
 | 
			
		||||
 
 | 
			
		||||
@@ -375,6 +375,9 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
 | 
			
		||||
        return PRIORITY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TileDataParameter<Boolean> getVoidExcessParameter() { return null; }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getPriority() {
 | 
			
		||||
        return priority;
 | 
			
		||||
 
 | 
			
		||||
@@ -224,6 +224,9 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
 | 
			
		||||
        return PRIORITY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TileDataParameter<Boolean> getVoidExcessParameter() { return null; }
 | 
			
		||||
 | 
			
		||||
    public NBTTagCompound getStorageTag() {
 | 
			
		||||
        return storageTag;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ import refinedstorage.block.BlockStorage;
 | 
			
		||||
import refinedstorage.block.EnumItemStorageType;
 | 
			
		||||
import refinedstorage.inventory.ItemHandlerBasic;
 | 
			
		||||
import refinedstorage.tile.config.IComparable;
 | 
			
		||||
import refinedstorage.tile.config.IExcessVoidable;
 | 
			
		||||
import refinedstorage.tile.config.IFilterable;
 | 
			
		||||
import refinedstorage.tile.config.IPrioritizable;
 | 
			
		||||
import refinedstorage.tile.data.ITileDataProducer;
 | 
			
		||||
@@ -22,7 +23,7 @@ import refinedstorage.tile.data.TileDataParameter;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class TileStorage extends TileNode implements IItemStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable {
 | 
			
		||||
public class TileStorage extends TileNode implements IItemStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IExcessVoidable {
 | 
			
		||||
    public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
 | 
			
		||||
    public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
 | 
			
		||||
    public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
 | 
			
		||||
@@ -32,6 +33,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
            return ItemStorageNBT.getStoredFromNBT(tile.storageTag);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
 | 
			
		||||
 | 
			
		||||
    class ItemStorage extends ItemStorageNBT {
 | 
			
		||||
        public ItemStorage() {
 | 
			
		||||
@@ -49,7 +51,14 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
                return ItemHandlerHelper.copyStackWithSize(stack, size);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return super.insertItem(stack, size, simulate);
 | 
			
		||||
            ItemStack result = super.insertItem(stack, size, simulate);
 | 
			
		||||
 | 
			
		||||
            if(voidExcess) {
 | 
			
		||||
                //Simulate should not matter as the items are voided anyway
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -58,6 +67,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
    private static final String NBT_PRIORITY = "Priority";
 | 
			
		||||
    private static final String NBT_COMPARE = "Compare";
 | 
			
		||||
    private static final String NBT_MODE = "Mode";
 | 
			
		||||
    private static final String NBT_VOID_EXCESS = "VoidExcess";
 | 
			
		||||
 | 
			
		||||
    private ItemHandlerBasic filters = new ItemHandlerBasic(9, this);
 | 
			
		||||
 | 
			
		||||
@@ -70,12 +80,14 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
    private int priority = 0;
 | 
			
		||||
    private int compare = CompareUtils.COMPARE_NBT | CompareUtils.COMPARE_DAMAGE;
 | 
			
		||||
    private int mode = IFilterable.WHITELIST;
 | 
			
		||||
    private boolean voidExcess = false;
 | 
			
		||||
 | 
			
		||||
    public TileStorage() {
 | 
			
		||||
        dataManager.addWatchedParameter(PRIORITY);
 | 
			
		||||
        dataManager.addWatchedParameter(COMPARE);
 | 
			
		||||
        dataManager.addWatchedParameter(MODE);
 | 
			
		||||
        dataManager.addWatchedParameter(STORED);
 | 
			
		||||
        dataManager.addWatchedParameter(VOID_EXCESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -141,6 +153,10 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
        if (tag.hasKey(NBT_MODE)) {
 | 
			
		||||
            mode = tag.getInteger(NBT_MODE);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(tag.hasKey(NBT_VOID_EXCESS)) {
 | 
			
		||||
            voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -158,6 +174,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
        tag.setTag(NBT_STORAGE, storageTag);
 | 
			
		||||
        tag.setInteger(NBT_COMPARE, compare);
 | 
			
		||||
        tag.setInteger(NBT_MODE, mode);
 | 
			
		||||
        tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
 | 
			
		||||
 | 
			
		||||
        return tag;
 | 
			
		||||
    }
 | 
			
		||||
@@ -194,6 +211,18 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
        markDirty();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean getVoidExcess() {
 | 
			
		||||
        return voidExcess;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setVoidExcess(boolean voidExcess) {
 | 
			
		||||
        this.voidExcess = voidExcess;
 | 
			
		||||
 | 
			
		||||
        markDirty();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getGuiTitle() {
 | 
			
		||||
        return "block.refinedstorage:storage." + getType().getId() + ".name";
 | 
			
		||||
@@ -224,6 +253,9 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
 | 
			
		||||
        return PRIORITY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TileDataParameter<Boolean> getVoidExcessParameter() { return VOID_EXCESS; }
 | 
			
		||||
 | 
			
		||||
    public NBTTagCompound getStorageTag() {
 | 
			
		||||
        return storageTag;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,30 @@
 | 
			
		||||
package refinedstorage.tile.config;
 | 
			
		||||
 | 
			
		||||
import net.minecraft.network.datasync.DataSerializers;
 | 
			
		||||
import net.minecraft.tileentity.TileEntity;
 | 
			
		||||
import refinedstorage.tile.data.ITileDataConsumer;
 | 
			
		||||
import refinedstorage.tile.data.ITileDataProducer;
 | 
			
		||||
import refinedstorage.tile.data.TileDataParameter;
 | 
			
		||||
 | 
			
		||||
public interface IExcessVoidable {
 | 
			
		||||
    public static final boolean VOID_EXCESS_OFF = false;
 | 
			
		||||
    public static final boolean VOID_EXCESS_ON = true;
 | 
			
		||||
 | 
			
		||||
    static <T extends TileEntity> TileDataParameter<Boolean> createParameter() {
 | 
			
		||||
        return new TileDataParameter<>(DataSerializers.BOOLEAN, VOID_EXCESS_OFF, new ITileDataProducer<Boolean, T>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public Boolean getValue(T tile) {
 | 
			
		||||
                return ((IExcessVoidable) tile).getVoidExcess();
 | 
			
		||||
            }
 | 
			
		||||
        }, new ITileDataConsumer<Boolean, T>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void setValue(T tile, Boolean value) {
 | 
			
		||||
                ((IExcessVoidable) tile).setVoidExcess(value);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    boolean getVoidExcess();
 | 
			
		||||
 | 
			
		||||
    void setVoidExcess(boolean voidExcess);
 | 
			
		||||
}
 | 
			
		||||
@@ -305,6 +305,9 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
 | 
			
		||||
        return PRIORITY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TileDataParameter<Boolean> getVoidExcessParameter() { return null; }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getStored() {
 | 
			
		||||
        return STORED.getValue();
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.2 KiB  | 
		Reference in New Issue
	
	Block a user