You can now keep fluids in stock by attaching a External Storage in fluid mode to a Fluid Interface with a Crafting Upgrade. #461
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
### 1.6.1
|
### 1.6.1
|
||||||
- Added fluid autocrafting (raoulvdberge)
|
- Added fluid autocrafting (raoulvdberge)
|
||||||
|
- Added Crafting Upgrade support for fluids on the Exporter, Constructor and Fluid Interface (raoulvdberge)
|
||||||
|
- You can now keep fluids in stock by attaching a External Storage in fluid mode to a Fluid Interface with a Crafting Upgrade (raoulvdberge)
|
||||||
|
- You can now specify the amount to export in the Fluid Interface (raoulvdberge)
|
||||||
- Made the Crafting Preview window bigger (raoulvdberge)
|
- Made the Crafting Preview window bigger (raoulvdberge)
|
||||||
- Updated Russian translation (kellixon)
|
- Updated Russian translation (kellixon)
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ public interface INetwork {
|
|||||||
* @param action the action
|
* @param action the action
|
||||||
* @return null if we didn't extract anything, or a stack with the result
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
default ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, Action action) {
|
default ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, Action action) {
|
||||||
return extractItem(stack, size, flags, action, s -> true);
|
return extractItem(stack, size, flags, action, s -> true);
|
||||||
}
|
}
|
||||||
@@ -152,6 +153,7 @@ public interface INetwork {
|
|||||||
* @param action the action
|
* @param action the action
|
||||||
* @return null if we didn't extract anything, or a stack with the result
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
default ItemStack extractItem(@Nonnull ItemStack stack, int size, Action action) {
|
default ItemStack extractItem(@Nonnull ItemStack stack, int size, Action action) {
|
||||||
return extractItem(stack, size, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, action);
|
return extractItem(stack, size, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, action);
|
||||||
}
|
}
|
||||||
@@ -174,6 +176,7 @@ public interface INetwork {
|
|||||||
* @param size the amount of that prototype that has to be inserted
|
* @param size the amount of that prototype that has to be inserted
|
||||||
* @return null if the insert was successful, or a stack with the remainder
|
* @return null if the insert was successful, or a stack with the remainder
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
default FluidStack insertFluidTracked(@Nonnull FluidStack stack, int size) {
|
default FluidStack insertFluidTracked(@Nonnull FluidStack stack, int size) {
|
||||||
FluidStack remainder = insertFluid(stack, size, Action.PERFORM);
|
FluidStack remainder = insertFluid(stack, size, Action.PERFORM);
|
||||||
|
|
||||||
@@ -194,7 +197,21 @@ public interface INetwork {
|
|||||||
* @return null if we didn't extract anything, or a stack with the result
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, Action action);
|
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, Action action, Predicate<IStorage<FluidStack>> filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a fluid from this network.
|
||||||
|
*
|
||||||
|
* @param stack the prototype of the stack to extract, do NOT modify
|
||||||
|
* @param size the amount of that prototype that has to be extracted
|
||||||
|
* @param flags the flags to compare on, see {@link IComparer}
|
||||||
|
* @param action the action
|
||||||
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
default FluidStack extractFluid(FluidStack stack, int size, int flags, Action action) {
|
||||||
|
return extractFluid(stack, size, flags, action, s -> true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts a fluid from this network.
|
* Extracts a fluid from this network.
|
||||||
@@ -204,6 +221,7 @@ public interface INetwork {
|
|||||||
* @param action the action
|
* @param action the action
|
||||||
* @return null if we didn't extract anything, or a stack with the result
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
default FluidStack extractFluid(FluidStack stack, int size, Action action) {
|
default FluidStack extractFluid(FluidStack stack, int size, Action action) {
|
||||||
return extractFluid(stack, size, IComparer.COMPARE_NBT, action);
|
return extractFluid(stack, size, IComparer.COMPARE_NBT, action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,6 +373,11 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CoverManager getCoverManager() {
|
public CoverManager getCoverManager() {
|
||||||
return coverManager;
|
return coverManager;
|
||||||
|
|||||||
@@ -317,6 +317,11 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConduct(@Nullable EnumFacing direction) {
|
public boolean canConduct(@Nullable EnumFacing direction) {
|
||||||
return coverManager.canConduct(direction);
|
return coverManager.canConduct(direction);
|
||||||
|
|||||||
@@ -251,4 +251,9 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
|
|||||||
public IItemHandler getFilterInventory() {
|
public IItemHandler getFilterInventory() {
|
||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,11 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConduct(@Nullable EnumFacing direction) {
|
public boolean canConduct(@Nullable EnumFacing direction) {
|
||||||
return coverManager.canConduct(direction);
|
return coverManager.canConduct(direction);
|
||||||
|
|||||||
@@ -345,6 +345,11 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
public List<IStorageExternal<ItemStack>> getItemStorages() {
|
public List<IStorageExternal<ItemStack>> getItemStorages() {
|
||||||
return itemStorages;
|
return itemStorages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.StorageExternalFluid;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.*;
|
import com.raoulvdberge.refinedstorage.inventory.*;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
@@ -19,18 +23,14 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
// TODO: Crafting upgrade
|
public class NetworkNodeFluidInterface extends NetworkNode {
|
||||||
public class NetworkNodeFluidInterface extends NetworkNode implements IComparable {
|
|
||||||
public static final String ID = "fluid_interface";
|
public static final String ID = "fluid_interface";
|
||||||
|
|
||||||
public static final int TANK_CAPACITY = 16000;
|
public static final int TANK_CAPACITY = 16000;
|
||||||
|
|
||||||
private static final String NBT_COMPARE = "Compare";
|
|
||||||
private static final String NBT_TANK_IN = "TankIn";
|
private static final String NBT_TANK_IN = "TankIn";
|
||||||
private static final String NBT_TANK_OUT = "TankOut";
|
private static final String NBT_TANK_OUT = "TankOut";
|
||||||
|
|
||||||
private int compare = IComparer.COMPARE_NBT;
|
|
||||||
|
|
||||||
private FluidTank tankIn = new FluidTank(TANK_CAPACITY) {
|
private FluidTank tankIn = new FluidTank(TANK_CAPACITY) {
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged() {
|
protected void onContentsChanged() {
|
||||||
@@ -43,26 +43,14 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private FluidTank tankOut = new FluidTank(TANK_CAPACITY);
|
||||||
private FluidTank tankOut = new FluidTank(TANK_CAPACITY) {
|
|
||||||
@Override
|
|
||||||
protected void onContentsChanged() {
|
|
||||||
super.onContentsChanged();
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
((TileFluidInterface) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_OUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private FluidHandlerFluidInterface tank = new FluidHandlerFluidInterface(tankIn, tankOut);
|
private FluidHandlerFluidInterface tank = new FluidHandlerFluidInterface(tankIn, tankOut);
|
||||||
|
|
||||||
private ItemHandlerBase in = new ItemHandlerBase(1, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase in = new ItemHandlerBase(1, new ItemHandlerListenerNetworkNode(this));
|
||||||
private ItemHandlerFluid out = new ItemHandlerFluid(1, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerFluid out = new ItemHandlerFluid(1, new ItemHandlerListenerNetworkNode(this));
|
||||||
|
|
||||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
|
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
|
||||||
|
|
||||||
public NetworkNodeFluidInterface(World world, BlockPos pos) {
|
public NetworkNodeFluidInterface(World world, BlockPos pos) {
|
||||||
super(world, pos);
|
super(world, pos);
|
||||||
@@ -92,71 +80,103 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (network != null && canUpdate() && ticks % upgrades.getSpeed() == 0) {
|
if (network != null && canUpdate()) {
|
||||||
FluidStack drained = tankIn.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true);
|
if (ticks % upgrades.getSpeed() == 0) {
|
||||||
|
FluidStack drained = tankIn.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true);
|
||||||
|
|
||||||
// Drain in tank
|
// Drain in tank
|
||||||
if (drained != null) {
|
if (drained != null) {
|
||||||
FluidStack remainder = network.insertFluidTracked(drained, drained.amount);
|
FluidStack remainder = network.insertFluidTracked(drained, drained.amount);
|
||||||
|
|
||||||
if (remainder != null) {
|
if (remainder != null) {
|
||||||
tankIn.fillInternal(remainder, true);
|
tankIn.fillInternal(remainder, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack stack = out.getFluidStackInSlot(0);
|
FluidStack wanted = out.getFluidStackInSlot(0);
|
||||||
|
int wantedAmount = out.getStackInSlot(0).getCount();
|
||||||
|
FluidStack got = tankOut.getFluid();
|
||||||
|
|
||||||
// Fill out tank
|
if (wanted == null) {
|
||||||
|
if (got != null) {
|
||||||
|
tankOut.setFluid(network.insertFluidTracked(got, got.amount));
|
||||||
|
|
||||||
// If our out fluid doesn't match the new fluid, empty it first
|
onTankOutChanged();
|
||||||
if (tankOut.getFluid() != null && (stack == null || (tankOut.getFluid().getFluid() != stack.getFluid()))) {
|
|
||||||
FluidStack remainder = tankOut.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true);
|
|
||||||
|
|
||||||
if (remainder != null) {
|
|
||||||
network.insertFluidTracked(remainder, remainder.amount);
|
|
||||||
}
|
}
|
||||||
} else if (stack != null) {
|
} else if (got != null && !API.instance().getComparer().isEqual(wanted, got, IComparer.COMPARE_NBT)) {
|
||||||
// Fill the out fluid
|
tankOut.setFluid(network.insertFluidTracked(got, got.amount));
|
||||||
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
|
|
||||||
|
|
||||||
if (stackInStorage != null) {
|
onTankOutChanged();
|
||||||
int toExtract = Math.min(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), stackInStorage.amount);
|
} else {
|
||||||
|
int delta = got == null ? wantedAmount : (wantedAmount - got.amount);
|
||||||
|
|
||||||
int spaceRemaining = tankOut.getCapacity() - tankOut.getFluidAmount();
|
if (delta > 0) {
|
||||||
if (toExtract > spaceRemaining) {
|
final boolean actingAsStorage = isActingAsStorage();
|
||||||
toExtract = spaceRemaining;
|
|
||||||
}
|
FluidStack result = network.extractFluid(wanted, delta, IComparer.COMPARE_NBT, Action.PERFORM, s -> {
|
||||||
if (toExtract <= 0) {
|
// If we are not an interface acting as a storage, we can extract from anywhere.
|
||||||
return;
|
if (!actingAsStorage) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are an interface acting as a storage, we don't want to extract from other interfaces to
|
||||||
|
// avoid stealing from each other.
|
||||||
|
return !(s instanceof StorageExternalFluid) || !((StorageExternalFluid) s).isConnectedToInterface();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
if (tankOut.getFluid() == null) {
|
||||||
|
tankOut.setFluid(result);
|
||||||
|
} else {
|
||||||
|
tankOut.getFluid().amount += result.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
onTankOutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack took = network.extractFluid(stack, toExtract, compare, Action.SIMULATE);
|
// Example: our delta is 5, we extracted 3 fluids.
|
||||||
|
// That means we still have to autocraft 2 fluids.
|
||||||
|
delta -= result == null ? 0 : result.amount;
|
||||||
|
|
||||||
if (took != null && (toExtract - tankOut.fillInternal(took, false)) == 0) {
|
if (delta > 0 && upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
took = network.extractFluid(stack, toExtract, compare, Action.PERFORM);
|
network.getCraftingManager().request(wanted, delta);
|
||||||
|
|
||||||
tankOut.fillInternal(took, true);
|
|
||||||
}
|
}
|
||||||
|
} else if (delta < 0) {
|
||||||
|
FluidStack remainder = network.insertFluidTracked(got, Math.abs(delta));
|
||||||
|
|
||||||
|
if (remainder == null) {
|
||||||
|
tankOut.getFluid().amount -= Math.abs(delta);
|
||||||
|
} else {
|
||||||
|
tankOut.getFluid().amount -= Math.abs(delta) - remainder.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
onTankOutChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isActingAsStorage() {
|
||||||
|
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||||
|
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
|
||||||
|
|
||||||
|
if (facingNode instanceof NetworkNodeExternalStorage &&
|
||||||
|
facingNode.canUpdate() &&
|
||||||
|
((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite() &&
|
||||||
|
((NetworkNodeExternalStorage) facingNode).getType() == IType.FLUIDS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return RS.INSTANCE.config.fluidInterfaceUsage;
|
return RS.INSTANCE.config.fluidInterfaceUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCompare() {
|
|
||||||
return compare;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCompare(int compare) {
|
|
||||||
this.compare = compare;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound write(NBTTagCompound tag) {
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
super.write(tag);
|
super.write(tag);
|
||||||
@@ -195,9 +215,7 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
|
|||||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||||
super.writeConfiguration(tag);
|
super.writeConfiguration(tag);
|
||||||
|
|
||||||
StackUtils.writeItems(out, 2, tag);
|
StackUtils.writeItems(out, 2, tag, StackUtils::serializeStackToNbt);
|
||||||
|
|
||||||
tag.setInteger(NBT_COMPARE, compare);
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -206,11 +224,7 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
|
|||||||
public void readConfiguration(NBTTagCompound tag) {
|
public void readConfiguration(NBTTagCompound tag) {
|
||||||
super.readConfiguration(tag);
|
super.readConfiguration(tag);
|
||||||
|
|
||||||
StackUtils.readItems(out, 2, tag);
|
StackUtils.readItems(out, 2, tag, StackUtils::deserializeStackFromNbt);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_COMPARE)) {
|
|
||||||
compare = tag.getInteger(NBT_COMPARE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemHandlerUpgrade getUpgrades() {
|
public ItemHandlerUpgrade getUpgrades() {
|
||||||
@@ -237,6 +251,14 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
|
|||||||
return tankOut;
|
return tankOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onTankOutChanged() {
|
||||||
|
if (!world.isRemote) {
|
||||||
|
((TileFluidInterface) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemHandler getDrops() {
|
public IItemHandler getDrops() {
|
||||||
return new CombinedInvWrapper(in, upgrades);
|
return new CombinedInvWrapper(in, upgrades);
|
||||||
|
|||||||
@@ -693,6 +693,11 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
|||||||
return getType() == IType.FLUIDS ? matrixProcessingFluids : matrixProcessing;
|
return getType() == IType.FLUIDS ? matrixProcessingFluids : matrixProcessing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasConnectivityState() {
|
public boolean hasConnectivityState() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -245,6 +245,11 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CoverManager getCoverManager() {
|
public CoverManager getCoverManager() {
|
||||||
return coverManager;
|
return coverManager;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
|
|||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -137,7 +138,10 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||||
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
|
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
|
||||||
|
|
||||||
if (facingNode instanceof NetworkNodeExternalStorage && facingNode.canUpdate() && ((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite()) {
|
if (facingNode instanceof NetworkNodeExternalStorage &&
|
||||||
|
facingNode.canUpdate() &&
|
||||||
|
((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite() &&
|
||||||
|
((NetworkNodeExternalStorage) facingNode).getType() == IType.ITEMS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,6 +198,11 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
|||||||
return getType() == IType.ITEMS ? itemFilter : fluidFilter;
|
return getType() == IType.ITEMS ? itemFilter : fluidFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||||
super.writeConfiguration(tag);
|
super.writeConfiguration(tag);
|
||||||
|
|||||||
@@ -363,6 +363,11 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
ItemHandlerBase getItemFilters() {
|
ItemHandlerBase getItemFilters() {
|
||||||
return itemFilters;
|
return itemFilters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -406,6 +406,11 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
|
|||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !world.isRemote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMode(int mode) {
|
public void setMode(int mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
@@ -20,6 +21,6 @@ public class ExternalStorageProviderFluid implements IExternalStorageProvider<Fl
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IStorageExternal<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, EnumFacing direction) {
|
public IStorageExternal<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, EnumFacing direction) {
|
||||||
return new StorageExternalFluid(context, () -> WorldUtils.getFluidHandler(tile.get(), direction.getOpposite()));
|
return new StorageExternalFluid(context, () -> WorldUtils.getFluidHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileFluidInterface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
|||||||
private IExternalStorageContext context;
|
private IExternalStorageContext context;
|
||||||
private Supplier<IFluidHandler> handlerSupplier;
|
private Supplier<IFluidHandler> handlerSupplier;
|
||||||
private List<FluidStack> cache;
|
private List<FluidStack> cache;
|
||||||
|
private boolean connectedToInterface;
|
||||||
|
|
||||||
public StorageExternalFluid(IExternalStorageContext context, Supplier<IFluidHandler> handlerSupplier) {
|
public StorageExternalFluid(IExternalStorageContext context, Supplier<IFluidHandler> handlerSupplier, boolean connectedToInterface) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.handlerSupplier = handlerSupplier;
|
this.handlerSupplier = handlerSupplier;
|
||||||
|
this.connectedToInterface = connectedToInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnectedToInterface() {
|
||||||
|
return connectedToInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -72,11 +78,25 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
|||||||
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
||||||
} else if (actual != null && cached == null) {
|
} else if (actual != null && cached == null) {
|
||||||
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
||||||
|
|
||||||
|
// When we use an interface + crafting upgrade + external storage combo, we don't want the crafting task
|
||||||
|
// to think we inserted twice.
|
||||||
|
if (!isConnectedToInterface()) {
|
||||||
|
network.getCraftingManager().track(actual, actual.amount);
|
||||||
|
}
|
||||||
} else if (!API.instance().getComparer().isEqual(actual, cached, IComparer.COMPARE_NBT)) {
|
} else if (!API.instance().getComparer().isEqual(actual, cached, IComparer.COMPARE_NBT)) {
|
||||||
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
||||||
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
||||||
|
|
||||||
|
if (!isConnectedToInterface()) {
|
||||||
|
network.getCraftingManager().track(actual, actual.amount);
|
||||||
|
}
|
||||||
} else if (actual.amount > cached.amount) {
|
} else if (actual.amount > cached.amount) {
|
||||||
network.getFluidStorageCache().add(actual, actual.amount - cached.amount, false, true);
|
network.getFluidStorageCache().add(actual, actual.amount - cached.amount, false, true);
|
||||||
|
|
||||||
|
if (!isConnectedToInterface()) {
|
||||||
|
network.getCraftingManager().track(actual, actual.amount - cached.amount);
|
||||||
|
}
|
||||||
} else if (actual.amount < cached.amount) {
|
} else if (actual.amount < cached.amount) {
|
||||||
network.getFluidStorageCache().remove(actual, cached.amount - actual.amount, true);
|
network.getFluidStorageCache().remove(actual, cached.amount - actual.amount, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.container;
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.*;
|
import com.raoulvdberge.refinedstorage.container.slot.*;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGridPatternFluidAmount;
|
import com.raoulvdberge.refinedstorage.gui.GuiFluidAmount;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
||||||
@@ -90,15 +90,15 @@ public abstract class ContainerBase extends Container {
|
|||||||
} else if (!player.inventory.getItemStack().isEmpty()) {
|
} else if (!player.inventory.getItemStack().isEmpty()) {
|
||||||
slot.putStack(ItemHandlerHelper.copyStackWithSize(player.inventory.getItemStack(), ((SlotFilter) slot).getInitialAmount(player.inventory.getItemStack())));
|
slot.putStack(ItemHandlerHelper.copyStackWithSize(player.inventory.getItemStack(), ((SlotFilter) slot).getInitialAmount(player.inventory.getItemStack())));
|
||||||
} else if (slot.getHasStack()) {
|
} else if (slot.getHasStack()) {
|
||||||
if (slot instanceof SlotFilterType && ((SlotFilterType) slot).getType().getType() == IType.FLUIDS) {
|
if (slot instanceof SlotFilterItemOrFluid && ((SlotFilterItemOrFluid) slot).getType().getType() == IType.FLUIDS) {
|
||||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||||
Minecraft.getMinecraft().addScheduledTask(() -> {
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
||||||
// Prevent JEI crash - this needs to run on the main thread and not on the packet handler thread
|
// Prevent JEI crash - this needs to run on the main thread and not on the packet handler thread
|
||||||
FMLClientHandler.instance().showGuiScreen(new GuiGridPatternFluidAmount((GuiBase) Minecraft.getMinecraft().currentScreen, player, slot.getSlotIndex(), ((SlotFilterType) slot).getActualStack()));
|
FMLClientHandler.instance().showGuiScreen(new GuiFluidAmount((GuiBase) Minecraft.getMinecraft().currentScreen, player, slot.slotNumber, ((SlotFilterItemOrFluid) slot).getActualStack(), ((SlotFilterItemOrFluid) slot).getMaxFluidAmount()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slot.getStack().setCount(((SlotFilter) slot).getAmountModified(dragType));
|
slot.getStack().setCount(((SlotFilter) slot).getModifiedAmount(dragType));
|
||||||
|
|
||||||
detectAndSendChanges();
|
detectAndSendChanges();
|
||||||
}
|
}
|
||||||
@@ -157,9 +157,9 @@ public abstract class ContainerBase extends Container {
|
|||||||
|
|
||||||
if (stackInSlot.isEmpty()) {
|
if (stackInSlot.isEmpty()) {
|
||||||
if (slot instanceof SlotFilterFluid) {
|
if (slot instanceof SlotFilterFluid) {
|
||||||
stackInSlot = ((SlotFilterFluid) slot).getRealStack();
|
stackInSlot = ((SlotFilterFluid) slot).getActualStack();
|
||||||
} else if (slot instanceof SlotFilterType) {
|
} else if (slot instanceof SlotFilterItemOrFluid) {
|
||||||
stackInSlot = ((SlotFilterType) slot).getActualStack();
|
stackInSlot = ((SlotFilterItemOrFluid) slot).getActualStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
|
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -15,7 +15,7 @@ public class ContainerConstructor extends ContainerBase {
|
|||||||
addSlotToContainer(new SlotItemHandler(constructor.getNode().getUpgrades(), i, 187, 6 + (i * 18)));
|
addSlotToContainer(new SlotItemHandler(constructor.getNode().getUpgrades(), i, 187, 6 + (i * 18)));
|
||||||
}
|
}
|
||||||
|
|
||||||
addSlotToContainer(new SlotFilterType(constructor.getNode(), 0, 80, 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(constructor.getNode(), 0, 80, 20));
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
|
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -16,7 +16,7 @@ public class ContainerDestructor extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(destructor.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(destructor.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileDetector;
|
import com.raoulvdberge.refinedstorage.tile.TileDetector;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -10,7 +10,7 @@ public class ContainerDetector extends ContainerBase {
|
|||||||
public ContainerDetector(TileDetector detector, EntityPlayer player) {
|
public ContainerDetector(TileDetector detector, EntityPlayer player) {
|
||||||
super(detector, player);
|
super(detector, player);
|
||||||
|
|
||||||
addSlotToContainer(new SlotFilterType(detector.getNode(), 0, 107, 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(detector.getNode(), 0, 107, 20));
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
|
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -19,7 +19,7 @@ public class ContainerDiskDrive extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(drive.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(drive.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 141);
|
addPlayerInventory(8, 141);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
|
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -24,7 +24,7 @@ public class ContainerDiskManipulator extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(manipulator.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(manipulator.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 129);
|
addPlayerInventory(8, 129);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -19,7 +19,7 @@ public class ContainerExporter extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(exporter.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(exporter.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
|
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -11,7 +11,7 @@ public class ContainerExternalStorage extends ContainerBase {
|
|||||||
super(externalStorage, player);
|
super(externalStorage, player);
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(externalStorage.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(externalStorage.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 141);
|
addPlayerInventory(8, 141);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
public class ContainerFluidInterface extends ContainerBase {
|
public class ContainerFluidInterface extends ContainerBase {
|
||||||
@@ -16,7 +20,31 @@ public class ContainerFluidInterface extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addSlotToContainer(new SlotItemHandler(fluidInterface.getNode().getIn(), 0, 44, 32));
|
addSlotToContainer(new SlotItemHandler(fluidInterface.getNode().getIn(), 0, 44, 32));
|
||||||
addSlotToContainer(new SlotFilterFluid(!fluidInterface.getWorld().isRemote, fluidInterface.getNode().getOut(), 0, 116, 32));
|
addSlotToContainer(new SlotFilterItemOrFluid(new IType() {
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return IType.FLUIDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(int type) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IItemHandler getFilterInventory() {
|
||||||
|
return fluidInterface.getNode().getOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return !fluidInterface.getNode().getWorld().isRemote;
|
||||||
|
}
|
||||||
|
}, 0, 116, 32, SlotFilter.FILTER_ALLOW_SIZE, (slot, amount) -> {
|
||||||
|
if (amount > 0 && amount <= NetworkNodeFluidInterface.TANK_CAPACITY) {
|
||||||
|
fluidInterface.getNode().getOut().getStackInSlot(0).setCount(amount);
|
||||||
|
}
|
||||||
|
}, NetworkNodeFluidInterface.TANK_CAPACITY));
|
||||||
|
|
||||||
addPlayerInventory(8, 122);
|
addPlayerInventory(8, 122);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||||||
import net.minecraft.inventory.IContainerListener;
|
import net.minecraft.inventory.IContainerListener;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -95,7 +96,11 @@ public class ContainerGrid extends ContainerBase {
|
|||||||
int y = headerAndSlots + 4;
|
int y = headerAndSlots + 4;
|
||||||
|
|
||||||
for (int i = 0; i < 9 * 2; ++i) {
|
for (int i = 0; i < 9 * 2; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType((NetworkNodeGrid) grid, i, x, y, SlotFilter.FILTER_ALLOW_SIZE));
|
addSlotToContainer(new SlotFilterItemOrFluid((NetworkNodeGrid) grid, i, x, y, SlotFilter.FILTER_ALLOW_SIZE, (slot, amount) -> {
|
||||||
|
if (amount > 0 && amount <= Fluid.BUCKET_VOLUME && slot < ((NetworkNodeGrid) grid).getMatrixProcessingFluids().getSlots()) {
|
||||||
|
((NetworkNodeGrid) grid).getMatrixProcessingFluids().getStackInSlot(slot).setCount(amount);
|
||||||
|
}
|
||||||
|
}, Fluid.BUCKET_VOLUME));
|
||||||
|
|
||||||
x += 18;
|
x += 18;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileImporter;
|
import com.raoulvdberge.refinedstorage.tile.TileImporter;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -16,7 +16,7 @@ public class ContainerImporter extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilterType(importer.getNode(), i, 8 + (18 * i), 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(importer.getNode(), i, 8 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container;
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor;
|
import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -10,7 +10,7 @@ public class ContainerStorageMonitor extends ContainerBase {
|
|||||||
public ContainerStorageMonitor(TileStorageMonitor storageMonitor, EntityPlayer player) {
|
public ContainerStorageMonitor(TileStorageMonitor storageMonitor, EntityPlayer player) {
|
||||||
super(storageMonitor, player);
|
super(storageMonitor, player);
|
||||||
|
|
||||||
addSlotToContainer(new SlotFilterType(storageMonitor.getNode(), 0, 80, 20));
|
addSlotToContainer(new SlotFilterItemOrFluid(storageMonitor.getNode(), 0, 80, 20));
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class SlotFilter extends SlotItemHandler {
|
|||||||
return (flags & FILTER_ALLOW_BLOCKS) == FILTER_ALLOW_BLOCKS;
|
return (flags & FILTER_ALLOW_BLOCKS) == FILTER_ALLOW_BLOCKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAmountModified(int dragType) {
|
public int getModifiedAmount(int dragType) {
|
||||||
int amount = getStack().getCount();
|
int amount = getStack().getCount();
|
||||||
|
|
||||||
if (dragType == 0) {
|
if (dragType == 0) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class SlotFilterFluid extends SlotFilter {
|
|||||||
return server ? super.getStack() : ItemStack.EMPTY;
|
return server ? super.getStack() : ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getRealStack() {
|
public ItemStack getActualStack() {
|
||||||
return super.getStack();
|
return super.getStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,34 @@
|
|||||||
package com.raoulvdberge.refinedstorage.container.slot;
|
package com.raoulvdberge.refinedstorage.container.slot;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class SlotFilterItemOrFluid extends SlotFilter {
|
||||||
|
public interface IFluidAmountChangeListener {
|
||||||
|
void onChangeRequested(int slot, int amount);
|
||||||
|
}
|
||||||
|
|
||||||
public class SlotFilterType extends SlotFilter {
|
|
||||||
private IType type;
|
private IType type;
|
||||||
|
|
||||||
public SlotFilterType(IType type, int id, int x, int y, int flags) {
|
@Nullable
|
||||||
|
private IFluidAmountChangeListener listener;
|
||||||
|
private int maxFluidAmount;
|
||||||
|
|
||||||
|
public SlotFilterItemOrFluid(IType type, int id, int x, int y, int flags, @Nullable IFluidAmountChangeListener listener, int maxFluidAmount) {
|
||||||
super(null, id, x, y, flags);
|
super(null, id, x, y, flags);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.listener = listener;
|
||||||
|
this.maxFluidAmount = maxFluidAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlotFilterType(IType type, int id, int x, int y) {
|
public SlotFilterItemOrFluid(IType type, int id, int x, int y) {
|
||||||
this(type, id, x, y, 0);
|
this(type, id, x, y, 0, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -34,7 +44,7 @@ public class SlotFilterType extends SlotFilter {
|
|||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack getStack() {
|
public ItemStack getStack() {
|
||||||
return (type.getType() == IType.ITEMS || !((NetworkNode) type).getWorld().isRemote) ? super.getStack() : ItemStack.EMPTY;
|
return (type.getType() == IType.ITEMS || type.isServer()) ? super.getStack() : ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getActualStack() {
|
public ItemStack getActualStack() {
|
||||||
@@ -53,4 +63,13 @@ public class SlotFilterType extends SlotFilter {
|
|||||||
|
|
||||||
return super.getInitialAmount(stack);
|
return super.getInitialAmount(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public IFluidAmountChangeListener getFluidAmountChangeListener() {
|
||||||
|
return listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxFluidAmount() {
|
||||||
|
return maxFluidAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ package com.raoulvdberge.refinedstorage.gui;
|
|||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||||
import com.raoulvdberge.refinedstorage.gui.control.SideButton;
|
import com.raoulvdberge.refinedstorage.gui.control.SideButton;
|
||||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||||
@@ -189,11 +190,11 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
FLUID_RENDERER.draw(mc, guiLeft + slot.xPos, guiTop + slot.yPos, stack);
|
FLUID_RENDERER.draw(mc, guiLeft + slot.xPos, guiTop + slot.yPos, stack);
|
||||||
|
|
||||||
if (slot instanceof SlotFilterType) {
|
if (slot instanceof SlotFilterItemOrFluid) {
|
||||||
int count = ((SlotFilterType) slot).getActualStack().getCount();
|
int count = ((SlotFilterItemOrFluid) slot).getActualStack().getCount();
|
||||||
|
|
||||||
if (count != 1) {
|
if (count != 1) {
|
||||||
drawQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, String.valueOf(count));
|
drawQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, API.instance().getQuantityFormatter().formatInBucketForm(count));
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui.grid;
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidAmount;
|
import com.raoulvdberge.refinedstorage.container.ContainerFluidAmount;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying;
|
import com.raoulvdberge.refinedstorage.network.MessageFluidAmount;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageGridFluidAmount;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
|
|
||||||
public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
public class GuiFluidAmount extends GuiAmountSpecifying {
|
||||||
private int slot;
|
private int containerSlot;
|
||||||
private ItemStack fluidContainer;
|
private ItemStack fluidContainer;
|
||||||
|
private int maxAmount;
|
||||||
|
|
||||||
public GuiGridPatternFluidAmount(GuiBase parent, EntityPlayer player, int slot, ItemStack fluidContainer) {
|
public GuiFluidAmount(GuiBase parent, EntityPlayer player, int containerSlot, ItemStack fluidContainer, int maxAmount) {
|
||||||
super(parent, new ContainerFluidAmount(player, fluidContainer), 172, 99);
|
super(parent, new ContainerFluidAmount(player, fluidContainer), 172, 99);
|
||||||
|
|
||||||
this.slot = slot;
|
this.containerSlot = containerSlot;
|
||||||
this.fluidContainer = fluidContainer;
|
this.fluidContainer = fluidContainer;
|
||||||
|
this.maxAmount = maxAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -33,7 +32,7 @@ public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMaxAmount() {
|
protected int getMaxAmount() {
|
||||||
return Fluid.BUCKET_VOLUME;
|
return maxAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,7 +42,7 @@ public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTitle() {
|
protected String getTitle() {
|
||||||
return t("gui.refinedstorage:pattern_grid.fluid_amount");
|
return t("gui.refinedstorage:fluid_amount");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -54,8 +53,8 @@ public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
|||||||
@Override
|
@Override
|
||||||
protected int[] getIncrements() {
|
protected int[] getIncrements() {
|
||||||
return new int[]{
|
return new int[]{
|
||||||
10, 50, 100,
|
100, 500, 1000,
|
||||||
-10, -50, -100
|
-100, -500, -1000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +62,8 @@ public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
|||||||
protected void onOkButtonPressed(boolean shiftDown) {
|
protected void onOkButtonPressed(boolean shiftDown) {
|
||||||
Integer amount = Ints.tryParse(amountField.getText());
|
Integer amount = Ints.tryParse(amountField.getText());
|
||||||
|
|
||||||
if (amount != null && amount > 0 && amount <= Fluid.BUCKET_VOLUME) {
|
if (amount != null) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridFluidAmount(slot, amount));
|
RS.INSTANCE.network.sendToServer(new MessageFluidAmount(containerSlot, amount));
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui;
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
|
import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
public class GuiFluidInterface extends GuiBase {
|
public class GuiFluidInterface extends GuiBase {
|
||||||
private static final RenderUtils.FluidRenderer TANK_RENDERER = new RenderUtils.FluidRenderer(NetworkNodeFluidInterface.TANK_CAPACITY, 12, 47);
|
private static final RenderUtils.FluidRenderer TANK_RENDERER = new RenderUtils.FluidRenderer(NetworkNodeFluidInterface.TANK_CAPACITY, 12, 47);
|
||||||
@@ -18,8 +18,6 @@ public class GuiFluidInterface extends GuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void init(int x, int y) {
|
public void init(int x, int y) {
|
||||||
addSideButton(new SideButtonRedstoneMode(this, TileFluidInterface.REDSTONE_MODE));
|
addSideButton(new SideButtonRedstoneMode(this, TileFluidInterface.REDSTONE_MODE));
|
||||||
|
|
||||||
addSideButton(new SideButtonCompare(this, TileFluidInterface.COMPARE, IComparer.COMPARE_NBT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,11 +47,11 @@ public class GuiFluidInterface extends GuiBase {
|
|||||||
drawString(7, 111, t("container.inventory"));
|
drawString(7, 111, t("container.inventory"));
|
||||||
|
|
||||||
if (inBounds(46, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_IN.getValue() != null) {
|
if (inBounds(46, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_IN.getValue() != null) {
|
||||||
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_IN.getValue().getLocalizedName() + "\n" + TileFluidInterface.TANK_IN.getValue().amount + " mB");
|
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_IN.getValue().getLocalizedName() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_IN.getValue().amount) + TextFormatting.RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBounds(118, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_OUT.getValue() != null) {
|
if (inBounds(118, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_OUT.getValue() != null) {
|
||||||
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_OUT.getValue().getLocalizedName() + "\n" + TileFluidInterface.TANK_OUT.getValue().amount + " mB");
|
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_OUT.getValue().getLocalizedName() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_OUT.getValue().amount) + TextFormatting.RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.network;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterItemOrFluid;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
|
||||||
|
public class MessageFluidAmount extends MessageHandlerPlayerToServer<MessageFluidAmount> implements IMessage {
|
||||||
|
private int containerSlot;
|
||||||
|
private int amount;
|
||||||
|
|
||||||
|
public MessageFluidAmount(int containerSlot, int amount) {
|
||||||
|
this.containerSlot = containerSlot;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageFluidAmount() {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handle(MessageFluidAmount message, EntityPlayerMP player) {
|
||||||
|
Container container = player.openContainer;
|
||||||
|
|
||||||
|
if (container != null) {
|
||||||
|
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||||
|
Slot slot = container.getSlot(message.containerSlot);
|
||||||
|
|
||||||
|
if (slot instanceof SlotFilterItemOrFluid && ((SlotFilterItemOrFluid) slot).getFluidAmountChangeListener() != null) {
|
||||||
|
((SlotFilterItemOrFluid) slot).getFluidAmountChangeListener().onChangeRequested(slot.getSlotIndex(), message.amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
containerSlot = buf.readInt();
|
||||||
|
amount = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(containerSlot);
|
||||||
|
buf.writeInt(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.network;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
public class MessageGridFluidAmount extends MessageHandlerPlayerToServer<MessageGridFluidAmount> implements IMessage {
|
|
||||||
private int slot;
|
|
||||||
private int amount;
|
|
||||||
|
|
||||||
public MessageGridFluidAmount(int slot, int amount) {
|
|
||||||
this.slot = slot;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageGridFluidAmount() {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handle(MessageGridFluidAmount message, EntityPlayerMP player) {
|
|
||||||
Container container = player.openContainer;
|
|
||||||
|
|
||||||
if (container instanceof ContainerGrid && message.slot >= 0 && message.amount > 0 && message.amount <= Fluid.BUCKET_VOLUME) {
|
|
||||||
IGrid grid = ((ContainerGrid) container).getGrid();
|
|
||||||
|
|
||||||
if (grid instanceof NetworkNodeGrid) {
|
|
||||||
NetworkNodeGrid node = (NetworkNodeGrid) grid;
|
|
||||||
|
|
||||||
if (message.slot < node.getMatrixProcessingFluids().getSlots()) {
|
|
||||||
node.getMatrixProcessingFluids().getStackInSlot(message.slot).setCount(message.amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
slot = buf.readInt();
|
|
||||||
amount = buf.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeInt(slot);
|
|
||||||
buf.writeInt(amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -188,7 +188,7 @@ public class ProxyCommon {
|
|||||||
RS.INSTANCE.network.registerMessage(MessageStorageDiskSizeRequest.class, MessageStorageDiskSizeRequest.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageStorageDiskSizeRequest.class, MessageStorageDiskSizeRequest.class, id++, Side.SERVER);
|
||||||
RS.INSTANCE.network.registerMessage(MessageStorageDiskSizeResponse.class, MessageStorageDiskSizeResponse.class, id++, Side.CLIENT);
|
RS.INSTANCE.network.registerMessage(MessageStorageDiskSizeResponse.class, MessageStorageDiskSizeResponse.class, id++, Side.CLIENT);
|
||||||
RS.INSTANCE.network.registerMessage(MessageConfigSync.class, MessageConfigSync.class, id++, Side.CLIENT);
|
RS.INSTANCE.network.registerMessage(MessageConfigSync.class, MessageConfigSync.class, id++, Side.CLIENT);
|
||||||
RS.INSTANCE.network.registerMessage(MessageGridFluidAmount.class, MessageGridFluidAmount.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageFluidAmount.class, MessageFluidAmount.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, Action action) {
|
public FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, Action action, Predicate<IStorage<FluidStack>> filter) {
|
||||||
int requested = size;
|
int requested = size;
|
||||||
int received = 0;
|
int received = 0;
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
for (IStorage<FluidStack> storage : this.fluidStorage.getStorages()) {
|
for (IStorage<FluidStack> storage : this.fluidStorage.getStorages()) {
|
||||||
FluidStack took = null;
|
FluidStack took = null;
|
||||||
|
|
||||||
if (storage.getAccessType() != AccessType.INSERT) {
|
if (filter.test(storage) && storage.getAccessType() != AccessType.INSERT) {
|
||||||
took = storage.extract(stack, requested - received, flags, action);
|
took = storage.extract(stack, requested - received, flags, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
@@ -15,12 +14,10 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
||||||
public static final TileDataParameter<Integer, TileFluidInterface> COMPARE = IComparable.createParameter();
|
|
||||||
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_IN = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankIn().getFluid());
|
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_IN = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankIn().getFluid());
|
||||||
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_OUT = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankOut().getFluid());
|
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_OUT = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankOut().getFluid());
|
||||||
|
|
||||||
public TileFluidInterface() {
|
public TileFluidInterface() {
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
|
||||||
dataManager.addParameter(TANK_IN);
|
dataManager.addParameter(TANK_IN);
|
||||||
dataManager.addParameter(TANK_OUT);
|
dataManager.addParameter(TANK_OUT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,6 @@ public interface IType {
|
|||||||
void setType(int type);
|
void setType(int type);
|
||||||
|
|
||||||
IItemHandler getFilterInventory();
|
IItemHandler getFilterInventory();
|
||||||
|
|
||||||
|
boolean isServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ gui.refinedstorage:grid=Grid
|
|||||||
gui.refinedstorage:grid.craft=Craft
|
gui.refinedstorage:grid.craft=Craft
|
||||||
gui.refinedstorage:crafting_grid=Crafting Grid
|
gui.refinedstorage:crafting_grid=Crafting Grid
|
||||||
gui.refinedstorage:pattern_grid=Pattern Grid
|
gui.refinedstorage:pattern_grid=Pattern Grid
|
||||||
gui.refinedstorage:pattern_grid.fluid_amount=Fluid amount in mB
|
|
||||||
gui.refinedstorage:grid.pattern_create=Create Pattern
|
gui.refinedstorage:grid.pattern_create=Create Pattern
|
||||||
gui.refinedstorage:fluid_grid=Fluid Grid
|
gui.refinedstorage:fluid_grid=Fluid Grid
|
||||||
|
gui.refinedstorage:fluid_amount=Fluid amount in mB
|
||||||
gui.refinedstorage:disk_drive=Drive
|
gui.refinedstorage:disk_drive=Drive
|
||||||
gui.refinedstorage:disk_drive.disks=Disks
|
gui.refinedstorage:disk_drive.disks=Disks
|
||||||
gui.refinedstorage:external_storage=External Storage
|
gui.refinedstorage:external_storage=External Storage
|
||||||
|
|||||||
Reference in New Issue
Block a user