add extraction from network to manipulator
also some small consistency change
This commit is contained in:
@@ -93,7 +93,7 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
Slot slot = inventorySlots.inventorySlots.get(i);
|
Slot slot = inventorySlots.inventorySlots.get(i);
|
||||||
|
|
||||||
if (slot instanceof SlotItemHandler && ((SlotItemHandler) slot).getItemHandler() instanceof ItemHandlerFluid) {
|
if (slot instanceof SlotItemHandler && ((SlotItemHandler) slot).getItemHandler() instanceof ItemHandlerFluid) {
|
||||||
FluidStack stack = ((ItemHandlerFluid) ((SlotItemHandler) slot).getItemHandler()).getFluids()[slot.getSlotIndex()];
|
FluidStack stack = ((ItemHandlerFluid) ((SlotItemHandler) slot).getItemHandler()).getFluidStackInSlot(slot.getSlotIndex());
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
FLUID_RENDERER.draw(mc, guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, stack);
|
FLUID_RENDERER.draw(mc, guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, stack);
|
||||||
|
|||||||
@@ -36,5 +36,7 @@ public class GuiDiskManipulator extends GuiBase {
|
|||||||
public void drawForeground(int mouseX, int mouseY) {
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
drawString(7, 7, t("block.refinedstorage:disk_manipulator.name"));
|
drawString(7, 7, t("block.refinedstorage:disk_manipulator.name"));
|
||||||
drawString(7, 117, t("container.inventory"));
|
drawString(7, 117, t("container.inventory"));
|
||||||
|
drawString(25, 45, t("gui.refinedstorage:fluid_interface.in"));
|
||||||
|
drawString(115, 45, t("gui.refinedstorage:fluid_interface.out"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ public class ItemHandlerFluid extends ItemHandlerBasic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FluidStack getFluidStackInSlot(int slot) {
|
||||||
|
return fluids[slot];
|
||||||
|
}
|
||||||
|
|
||||||
public FluidStack[] getFluids() {
|
public FluidStack[] getFluids() {
|
||||||
return fluids;
|
return fluids;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
public static final boolean ENABLE_DISK_MANIPULATOR = false;
|
public static final boolean ENABLE_DISK_MANIPULATOR = true;
|
||||||
|
|
||||||
protected List<BlockCable> cableTypes = new ArrayList<>();
|
protected List<BlockCable> cableTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class TileConstructor extends TileMultipartNode implements IComparable, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == IType.FLUIDS) {
|
} else if (type == IType.FLUIDS) {
|
||||||
FluidStack stack = fluidFilters.getFluids()[0];
|
FluidStack stack = fluidFilters.getFluidStackInSlot(0);
|
||||||
|
|
||||||
if (stack != null && stack.getFluid().canBePlacedInWorld()) {
|
if (stack != null && stack.getFluid().canBePlacedInWorld()) {
|
||||||
BlockPos front = pos.offset(getDirection());
|
BlockPos front = pos.offset(getDirection());
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class TileDetector extends TileNode implements IComparable, IType {
|
|||||||
powered = mode == MODE_AUTOCRAFTING && !network.getCraftingTasks().isEmpty();
|
powered = mode == MODE_AUTOCRAFTING && !network.getCraftingTasks().isEmpty();
|
||||||
}
|
}
|
||||||
} else if (type == IType.FLUIDS) {
|
} else if (type == IType.FLUIDS) {
|
||||||
FluidStack slot = fluidFilters.getFluids()[0];
|
FluidStack slot = fluidFilters.getFluidStackInSlot(0);
|
||||||
|
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
FluidStack stack = network.getFluidStorage().get(slot, compare);
|
FluidStack stack = network.getFluidStorage().get(slot, compare);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import refinedstorage.tile.data.ITileDataConsumer;
|
|||||||
import refinedstorage.tile.data.ITileDataProducer;
|
import refinedstorage.tile.data.ITileDataProducer;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileDiskManipulator extends TileNode implements IComparable, IFilterable, IType {
|
public class TileDiskManipulator extends TileNode implements IComparable, IFilterable, IType {
|
||||||
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();
|
||||||
@@ -49,6 +51,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
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_IO_MOD = "IOMode";
|
||||||
|
|
||||||
private int compare = 0;
|
private int compare = 0;
|
||||||
private int mode = IFilterable.WHITELIST;
|
private int mode = IFilterable.WHITELIST;
|
||||||
@@ -211,7 +214,42 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void extractFromNetwork(ItemStorage storage, int slot) {
|
private void extractFromNetwork(ItemStorage storage, int slot) {
|
||||||
|
if (storage.getStored() == storage.getCapacity()) {
|
||||||
|
moveDriveToOutput(slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ItemStack extracted = null;
|
||||||
|
int ii = 0;
|
||||||
|
if (IFilterable.isEmpty(itemFilters)) {
|
||||||
|
ItemStack toExtract = null;
|
||||||
|
ArrayList<ItemStack> networkItems = new ArrayList<>(network.getItemStorage().getStacks());
|
||||||
|
int iii = 0;
|
||||||
|
while ((toExtract == null || toExtract.stackSize == 0) && iii < networkItems.size()) {
|
||||||
|
toExtract = networkItems.get(iii++);
|
||||||
|
}
|
||||||
|
if (toExtract != null) {
|
||||||
|
extracted = network.extractItem(toExtract, 1, compare);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (itemFilters.getSlots() > ii && extracted == null) {
|
||||||
|
ItemStack stack = null;
|
||||||
|
while (itemFilters.getSlots() > ii && stack == null) {
|
||||||
|
stack = itemFilters.getStackInSlot(ii++);
|
||||||
|
}
|
||||||
|
if (stack != null) {
|
||||||
|
extracted = network.extractItem(stack, 1, compare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extracted == null) {
|
||||||
|
moveDriveToOutput(slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ItemStack leftOver = storage.insertItem(extracted, extracted.stackSize, false);
|
||||||
|
if (leftOver != null) {
|
||||||
|
network.insertItem(leftOver, leftOver.stackSize, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertIntoNetwork(FluidStorage storage, int slot) {
|
private void insertIntoNetwork(FluidStorage storage, int slot) {
|
||||||
@@ -241,6 +279,42 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void extractFromNetwork(FluidStorage storage, int slot) {
|
private void extractFromNetwork(FluidStorage storage, int slot) {
|
||||||
|
if (storage.getStored() == storage.getCapacity()) {
|
||||||
|
moveDriveToOutput(slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FluidStack extracted = null;
|
||||||
|
int ii = 0;
|
||||||
|
if (IFilterable.isEmpty(itemFilters)) {
|
||||||
|
FluidStack toExtract = null;
|
||||||
|
ArrayList<FluidStack> networkFluids = new ArrayList<>(network.getFluidStorage().getStacks());
|
||||||
|
int iii = 0;
|
||||||
|
while ((toExtract == null || toExtract.amount == 0) && iii < networkFluids.size()) {
|
||||||
|
toExtract = networkFluids.get(iii++);
|
||||||
|
}
|
||||||
|
if (toExtract != null) {
|
||||||
|
extracted = network.extractFluid(toExtract, 1, compare);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (fluidFilters.getSlots() > ii && extracted == null) {
|
||||||
|
FluidStack stack = null;
|
||||||
|
while (fluidFilters.getSlots() > ii && stack == null) {
|
||||||
|
stack = fluidFilters.getFluidStackInSlot(ii++);
|
||||||
|
}
|
||||||
|
if (stack != null) {
|
||||||
|
extracted = network.extractFluid(stack, 1, compare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extracted == null) {
|
||||||
|
moveDriveToOutput(slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FluidStack leftOver = storage.insertFluid(extracted, extracted.amount, false);
|
||||||
|
if (leftOver != null) {
|
||||||
|
network.insertFluid(leftOver, leftOver.amount, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveDriveToOutput(int slot) {
|
private void moveDriveToOutput(int slot) {
|
||||||
@@ -326,6 +400,10 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
if (tag.hasKey(NBT_TYPE)) {
|
if (tag.hasKey(NBT_TYPE)) {
|
||||||
type = tag.getInteger(NBT_TYPE);
|
type = tag.getInteger(NBT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_IO_MOD)) {
|
||||||
|
ioMode = tag.getInteger(NBT_IO_MOD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -339,6 +417,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
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.setInteger(NBT_IO_MOD, ioMode);
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class TileFluidInterface extends TileNode implements IComparable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack stack = out.getFluids()[0];
|
FluidStack stack = out.getFluidStackInSlot(0);
|
||||||
|
|
||||||
if (tankOut.getFluid() != null && (stack == null || (tankOut.getFluid().getFluid() != stack.getFluid()))) {
|
if (tankOut.getFluid() != null && (stack == null || (tankOut.getFluid().getFluid() != stack.getFluid()))) {
|
||||||
FluidStack remainder = tankOut.drainInternal(Fluid.BUCKET_VOLUME, true);
|
FluidStack remainder = tankOut.drainInternal(Fluid.BUCKET_VOLUME, true);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public interface IFilterable {
|
|||||||
int slots = 0;
|
int slots = 0;
|
||||||
|
|
||||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||||
FluidStack slot = filters.getFluids()[i];
|
FluidStack slot = filters.getFluidStackInSlot(i);
|
||||||
|
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
slots++;
|
slots++;
|
||||||
@@ -82,7 +82,7 @@ public interface IFilterable {
|
|||||||
return slots == 0;
|
return slots == 0;
|
||||||
} else if (mode == BLACKLIST) {
|
} else if (mode == BLACKLIST) {
|
||||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||||
FluidStack slot = filters.getFluids()[i];
|
FluidStack slot = filters.getFluidStackInSlot(i);
|
||||||
|
|
||||||
if (slot != null && CompareUtils.compareStack(slot, stack, compare)) {
|
if (slot != null && CompareUtils.compareStack(slot, stack, compare)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -95,6 +95,13 @@ public interface IFilterable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean isEmpty(IItemHandler filter) {
|
||||||
|
for (int i = 0; i < filter.getSlots(); i++)
|
||||||
|
if (filter.getStackInSlot(i) != null)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void setMode(int mode);
|
void setMode(int mode);
|
||||||
|
|
||||||
int getMode();
|
int getMode();
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ sidebutton.refinedstorage:mode=Mode
|
|||||||
sidebutton.refinedstorage:mode.whitelist=Whitelist
|
sidebutton.refinedstorage:mode.whitelist=Whitelist
|
||||||
sidebutton.refinedstorage:mode.blacklist=Blacklist
|
sidebutton.refinedstorage:mode.blacklist=Blacklist
|
||||||
|
|
||||||
sidebutton.refinedstorage:iomode=IOMode
|
sidebutton.refinedstorage:iomode=IO Mode
|
||||||
sidebutton.refinedstorage:iomode.insert=Insert into network
|
sidebutton.refinedstorage:iomode.insert=Insert into network
|
||||||
sidebutton.refinedstorage:iomode.extract=Extract from network
|
sidebutton.refinedstorage:iomode.extract=Extract from network
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user