Implemented void excess in disk drive
This commit is contained in:
@@ -4,11 +4,7 @@ import com.google.common.primitives.Ints;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import refinedstorage.api.util.IComparer;
|
||||
import refinedstorage.container.ContainerBase;
|
||||
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.gui.sidebutton.*;
|
||||
import refinedstorage.tile.IStorageGui;
|
||||
import refinedstorage.tile.data.TileDataManager;
|
||||
|
||||
@@ -56,7 +52,7 @@ public class GuiStorage extends GuiBase {
|
||||
}
|
||||
|
||||
if (gui.getVoidExcessParameter() != null) {
|
||||
addSideButton(new SideButtonVoidExcess(this, gui.getVoidExcessParameter()));
|
||||
addSideButton(new SideButtonVoidExcess(this, gui.getVoidExcessParameter(), gui.getVoidExcessType()));
|
||||
}
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 29, fontRendererObj.FONT_HEIGHT);
|
||||
|
||||
6
src/main/java/refinedstorage/gui/sidebutton/SideButtonVoidExcess.java
Normal file → Executable file
6
src/main/java/refinedstorage/gui/sidebutton/SideButtonVoidExcess.java
Normal file → Executable file
@@ -7,16 +7,18 @@ import refinedstorage.tile.data.TileDataParameter;
|
||||
|
||||
public class SideButtonVoidExcess extends SideButton {
|
||||
private TileDataParameter<Boolean> parameter;
|
||||
private String type;
|
||||
|
||||
public SideButtonVoidExcess(GuiBase gui, TileDataParameter<Boolean> parameter) {
|
||||
public SideButtonVoidExcess(GuiBase gui, TileDataParameter<Boolean> parameter, String type) {
|
||||
super(gui);
|
||||
|
||||
this.parameter = parameter;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return TextFormatting.LIGHT_PURPLE + gui.t("sidebutton.refinedstorage:void_excess.mode") + TextFormatting.RESET + "\n" + gui.t(parameter.getValue() ? "gui.yes" : "gui.no");
|
||||
return TextFormatting.LIGHT_PURPLE + gui.t("sidebutton.refinedstorage:void_excess." + type) + TextFormatting.RESET + "\n" + gui.t(parameter.getValue() ? "gui.yes" : "gui.no");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,8 @@ public interface IStorageGui {
|
||||
|
||||
TileDataParameter<Boolean> getVoidExcessParameter();
|
||||
|
||||
String getVoidExcessType();
|
||||
|
||||
int getStored();
|
||||
|
||||
int getCapacity();
|
||||
|
||||
@@ -535,8 +535,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
//If the stack size of the remainder is negative, it means of the original size abs(remainder.stackSize) items have been voided
|
||||
// If the stack size of the remainder is negative, it means of the original size abs(remainder.stackSize) items have been voided
|
||||
int inserted;
|
||||
|
||||
if (remainder == null) {
|
||||
inserted = orginalSize;
|
||||
} else if (remainder.stackSize < 0) {
|
||||
@@ -632,7 +633,17 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
int inserted = remainder != null ? (orginalSize - remainder.amount) : orginalSize;
|
||||
// If the stack size of the remainder is negative, it means of the original size abs(remainder.amount) fluids have been voided
|
||||
int inserted;
|
||||
|
||||
if (remainder == null) {
|
||||
inserted = orginalSize;
|
||||
} else if (remainder.amount < 0) {
|
||||
inserted = orginalSize + remainder.amount;
|
||||
remainder = null;
|
||||
} else {
|
||||
inserted = orginalSize - remainder.amount;
|
||||
}
|
||||
|
||||
if (!simulate && inserted > 0) {
|
||||
fluidStorage.add(FluidUtils.copyStackWithSize(stack, inserted), false);
|
||||
|
||||
@@ -27,19 +27,17 @@ import refinedstorage.block.EnumItemStorageType;
|
||||
import refinedstorage.inventory.IItemValidator;
|
||||
import refinedstorage.inventory.ItemHandlerBasic;
|
||||
import refinedstorage.inventory.ItemHandlerFluid;
|
||||
import refinedstorage.tile.config.IComparable;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
import refinedstorage.tile.config.IPrioritizable;
|
||||
import refinedstorage.tile.config.IType;
|
||||
import refinedstorage.tile.config.*;
|
||||
import refinedstorage.tile.data.TileDataParameter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFluidStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType {
|
||||
public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFluidStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, 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();
|
||||
public static final TileDataParameter<Integer> TYPE = IType.createParameter();
|
||||
public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
|
||||
|
||||
public class ItemStorage extends ItemStorageNBT {
|
||||
public ItemStorage(ItemStack disk) {
|
||||
@@ -57,7 +55,14 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertItem(stack, size, simulate);
|
||||
ItemStack result = super.insertItem(stack, size, simulate);
|
||||
|
||||
if (voidExcess && result != null) {
|
||||
// Simulate should not matter as the items are voided anyway
|
||||
result.stackSize = -result.stackSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +82,14 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
return FluidUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertFluid(stack, size, simulate);
|
||||
FluidStack result = super.insertFluid(stack, size, simulate);
|
||||
|
||||
if (voidExcess && result != null) {
|
||||
// Simulate should not matter as the items are voided anyway
|
||||
result.amount = -result.amount;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +97,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_TYPE = "Type";
|
||||
private static final String NBT_VOID_EXCESS = "VoidExcess";
|
||||
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
||||
@Override
|
||||
@@ -129,12 +142,14 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
private int type = IType.ITEMS;
|
||||
private boolean voidExcess = false;
|
||||
|
||||
public TileDiskDrive() {
|
||||
dataManager.addWatchedParameter(PRIORITY);
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(MODE);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(VOID_EXCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +232,10 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
if (tag.hasKey(NBT_TYPE)) {
|
||||
type = tag.getInteger(NBT_TYPE);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_VOID_EXCESS)) {
|
||||
voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,6 +260,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -301,7 +321,12 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
|
||||
@Override
|
||||
public TileDataParameter<Boolean> getVoidExcessParameter() {
|
||||
return null;
|
||||
return VOID_EXCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoidExcessType() {
|
||||
return "items_fluids";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -356,6 +381,18 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
return disks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getVoidExcess() {
|
||||
return voidExcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoidExcess(boolean voidExcess) {
|
||||
this.voidExcess = voidExcess;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return worldObj.isRemote ? TYPE.getValue() : type;
|
||||
|
||||
@@ -230,6 +230,11 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoidExcessType() {
|
||||
return "fluids";
|
||||
}
|
||||
|
||||
public NBTTagCompound getStorageTag() {
|
||||
return storageTag;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
ItemStack result = super.insertItem(stack, size, simulate);
|
||||
|
||||
if (voidExcess && result != null) {
|
||||
//Simulate should not matter as the items are voided anyway
|
||||
// Simulate should not matter as the items are voided anyway
|
||||
result.stackSize = -result.stackSize;
|
||||
}
|
||||
|
||||
@@ -259,6 +259,11 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
return VOID_EXCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoidExcessType() {
|
||||
return "items";
|
||||
}
|
||||
|
||||
public NBTTagCompound getStorageTag() {
|
||||
return storageTag;
|
||||
}
|
||||
|
||||
@@ -311,6 +311,11 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoidExcessType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
return STORED.getValue();
|
||||
|
||||
Reference in New Issue
Block a user