Backport lock crafting function for ME Interface (#423)
This commit is contained in:
@@ -48,6 +48,7 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
@@ -473,7 +474,12 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(final IAEFluidTank inventory, final int slot) {
|
||||
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
|
||||
onFluidInventoryChanged(inv, slot, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(final IAEFluidTank inventory, final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
|
||||
if (this.isWorking == slot) {
|
||||
return;
|
||||
}
|
||||
@@ -486,6 +492,9 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
} else if (inventory == this.tanks) {
|
||||
if (added != null) {
|
||||
iHost.onStackReturnNetwork(AEFluidStack.fromFluidStack(added));
|
||||
}
|
||||
this.saveChanges();
|
||||
|
||||
final boolean had = this.hasWorkToDo();
|
||||
|
||||
@@ -21,9 +21,11 @@ package appeng.fluids.helper;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -36,4 +38,7 @@ public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgra
|
||||
TileEntity getTileEntity();
|
||||
|
||||
void saveChanges();
|
||||
|
||||
default void onStackReturnNetwork(IAEFluidStack stack) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.parts.automation.PartAbstractFormationPlane;
|
||||
import appeng.parts.automation.PlaneModels;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
|
||||
@@ -36,6 +36,7 @@ import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -46,6 +47,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -63,6 +63,7 @@ import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -75,6 +76,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
@@ -543,6 +545,7 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
}
|
||||
|
||||
// TODO: 1/28/2024 Unify both methods.
|
||||
|
||||
/**
|
||||
* Filters the changes to only include items that pass the storage filter.
|
||||
* Optimally, this should be handled by the underlying monitor.
|
||||
|
||||
@@ -4,6 +4,7 @@ package appeng.fluids.util;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
@@ -37,24 +38,27 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
if (Objects.equals(this.fluids[slot], fluid)) {
|
||||
if (fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize()) {
|
||||
this.fluids[slot].setStackSize(fluid.getStackSize());
|
||||
this.onContentChanged(slot);
|
||||
this.onContentChanged(slot, InvOperation.SET, fluid.getFluidStack(), null);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (fluid == null) {
|
||||
IAEFluidStack removeStack = this.fluids[slot].copy();
|
||||
this.fluids[slot] = null;
|
||||
this.onContentChanged(slot, InvOperation.SET, null, removeStack.getFluidStack());
|
||||
} else {
|
||||
IAEFluidStack removeStack = this.fluids[slot];
|
||||
this.fluids[slot] = fluid.copy();
|
||||
this.fluids[slot].setStackSize(fluid.getStackSize());
|
||||
this.onContentChanged(slot, InvOperation.SET, fluid.getFluidStack(), removeStack == null ? null : removeStack.getFluidStack());
|
||||
}
|
||||
|
||||
this.onContentChanged(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onContentChanged(final int slot) {
|
||||
private void onContentChanged(final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
|
||||
if (this.handler != null && Platform.isServer()) {
|
||||
this.handler.onFluidInventoryChanged(this, slot);
|
||||
this.handler.onFluidInventoryChanged(this, slot, operation, added, removed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +111,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource).setStackSize(amountToStore));
|
||||
} else {
|
||||
fluid.setStackSize(fluid.getStackSize() + amountToStore);
|
||||
this.onContentChanged(slot);
|
||||
this.onContentChanged(slot, InvOperation.INSERT, resource, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +143,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
if (fluid.getStackSize() <= 0) {
|
||||
this.fluids[slot] = null;
|
||||
}
|
||||
this.onContentChanged(slot);
|
||||
this.onContentChanged(slot, InvOperation.EXTRACT, null, new FluidStack(fluid.getFluid(), drained));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.fluids.util;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
|
||||
@@ -19,7 +19,13 @@
|
||||
package appeng.fluids.util;
|
||||
|
||||
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IAEFluidInventory {
|
||||
void onFluidInventoryChanged(final IAEFluidTank inv, final int slot);
|
||||
|
||||
default void onFluidInventoryChanged(final IAEFluidTank inv, final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user