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 net.minecraft.client.gui.GuiTextField;
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.container.ContainerBase;
|
import refinedstorage.container.ContainerBase;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonCompare;
|
import refinedstorage.gui.sidebutton.*;
|
||||||
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.IStorageGui;
|
||||||
import refinedstorage.tile.data.TileDataManager;
|
import refinedstorage.tile.data.TileDataManager;
|
||||||
|
|
||||||
@@ -56,7 +52,7 @@ public class GuiStorage extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gui.getVoidExcessParameter() != null) {
|
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);
|
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 {
|
public class SideButtonVoidExcess extends SideButton {
|
||||||
private TileDataParameter<Boolean> parameter;
|
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);
|
super(gui);
|
||||||
|
|
||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTooltip() {
|
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
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public interface IStorageGui {
|
|||||||
|
|
||||||
TileDataParameter<Boolean> getVoidExcessParameter();
|
TileDataParameter<Boolean> getVoidExcessParameter();
|
||||||
|
|
||||||
|
String getVoidExcessType();
|
||||||
|
|
||||||
int getStored();
|
int getStored();
|
||||||
|
|
||||||
int getCapacity();
|
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;
|
int inserted;
|
||||||
|
|
||||||
if (remainder == null) {
|
if (remainder == null) {
|
||||||
inserted = orginalSize;
|
inserted = orginalSize;
|
||||||
} else if (remainder.stackSize < 0) {
|
} 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) {
|
if (!simulate && inserted > 0) {
|
||||||
fluidStorage.add(FluidUtils.copyStackWithSize(stack, inserted), false);
|
fluidStorage.add(FluidUtils.copyStackWithSize(stack, inserted), false);
|
||||||
|
|||||||
@@ -27,19 +27,17 @@ import refinedstorage.block.EnumItemStorageType;
|
|||||||
import refinedstorage.inventory.IItemValidator;
|
import refinedstorage.inventory.IItemValidator;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.inventory.ItemHandlerFluid;
|
import refinedstorage.inventory.ItemHandlerFluid;
|
||||||
import refinedstorage.tile.config.IComparable;
|
import refinedstorage.tile.config.*;
|
||||||
import refinedstorage.tile.config.IFilterable;
|
|
||||||
import refinedstorage.tile.config.IPrioritizable;
|
|
||||||
import refinedstorage.tile.config.IType;
|
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
|
|
||||||
import java.util.List;
|
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> PRIORITY = IPrioritizable.createParameter();
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||||
public static final TileDataParameter<Integer> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer> TYPE = IType.createParameter();
|
||||||
|
public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
|
||||||
|
|
||||||
public class ItemStorage extends ItemStorageNBT {
|
public class ItemStorage extends ItemStorageNBT {
|
||||||
public ItemStorage(ItemStack disk) {
|
public ItemStorage(ItemStack disk) {
|
||||||
@@ -57,7 +55,14 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
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 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_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
private static final String NBT_TYPE = "Type";
|
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) {
|
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
||||||
@Override
|
@Override
|
||||||
@@ -129,12 +142,14 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||||
private int mode = IFilterable.WHITELIST;
|
private int mode = IFilterable.WHITELIST;
|
||||||
private int type = IType.ITEMS;
|
private int type = IType.ITEMS;
|
||||||
|
private boolean voidExcess = false;
|
||||||
|
|
||||||
public TileDiskDrive() {
|
public TileDiskDrive() {
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
|
dataManager.addWatchedParameter(VOID_EXCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,6 +232,10 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
if (tag.hasKey(NBT_TYPE)) {
|
if (tag.hasKey(NBT_TYPE)) {
|
||||||
type = tag.getInteger(NBT_TYPE);
|
type = tag.getInteger(NBT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_VOID_EXCESS)) {
|
||||||
|
voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -241,6 +260,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
tag.setInteger(NBT_COMPARE, compare);
|
tag.setInteger(NBT_COMPARE, compare);
|
||||||
tag.setInteger(NBT_MODE, mode);
|
tag.setInteger(NBT_MODE, mode);
|
||||||
tag.setInteger(NBT_TYPE, type);
|
tag.setInteger(NBT_TYPE, type);
|
||||||
|
tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -301,7 +321,12 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileDataParameter<Boolean> getVoidExcessParameter() {
|
public TileDataParameter<Boolean> getVoidExcessParameter() {
|
||||||
return null;
|
return VOID_EXCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVoidExcessType() {
|
||||||
|
return "items_fluids";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -356,6 +381,18 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
return disks;
|
return disks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getVoidExcess() {
|
||||||
|
return voidExcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVoidExcess(boolean voidExcess) {
|
||||||
|
this.voidExcess = voidExcess;
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return worldObj.isRemote ? TYPE.getValue() : type;
|
return worldObj.isRemote ? TYPE.getValue() : type;
|
||||||
|
|||||||
@@ -230,6 +230,11 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVoidExcessType() {
|
||||||
|
return "fluids";
|
||||||
|
}
|
||||||
|
|
||||||
public NBTTagCompound getStorageTag() {
|
public NBTTagCompound getStorageTag() {
|
||||||
return storageTag;
|
return storageTag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
|||||||
ItemStack result = super.insertItem(stack, size, simulate);
|
ItemStack result = super.insertItem(stack, size, simulate);
|
||||||
|
|
||||||
if (voidExcess && result != null) {
|
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;
|
result.stackSize = -result.stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +259,11 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
|||||||
return VOID_EXCESS;
|
return VOID_EXCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVoidExcessType() {
|
||||||
|
return "items";
|
||||||
|
}
|
||||||
|
|
||||||
public NBTTagCompound getStorageTag() {
|
public NBTTagCompound getStorageTag() {
|
||||||
return storageTag;
|
return storageTag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,6 +311,11 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVoidExcessType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStored() {
|
public int getStored() {
|
||||||
return STORED.getValue();
|
return STORED.getValue();
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ sidebutton.refinedstorage:detector.mode.3=Emit signal when item is being autocra
|
|||||||
|
|
||||||
sidebutton.refinedstorage:crafter.triggered_autocrafting=Trigger autocrafting with redstone signal
|
sidebutton.refinedstorage:crafter.triggered_autocrafting=Trigger autocrafting with redstone signal
|
||||||
|
|
||||||
sidebutton.refinedstorage:void_excess.mode=Void excess items
|
sidebutton.refinedstorage:void_excess.items=Void excess items
|
||||||
|
sidebutton.refinedstorage:void_excess.fluids=Void excess fluids
|
||||||
|
sidebutton.refinedstorage:void_excess.items_fluids=Void excess items and fluids
|
||||||
|
|
||||||
block.refinedstorage:controller.0.name=Controller
|
block.refinedstorage:controller.0.name=Controller
|
||||||
block.refinedstorage:controller.1.name=Creative Controller
|
block.refinedstorage:controller.1.name=Creative Controller
|
||||||
|
|||||||
Reference in New Issue
Block a user