use of logisticspipes.interfaces.routing.IRequestFluid in project LogisticsPipes by RS485.
the class ModuleCrafter method addCrafting.
@Override
public ICraftingTemplate addCrafting(IResource toCraft) {
List<ItemIdentifierStack> stack = getCraftedItems();
if (stack == null) {
return null;
}
IReqCraftingTemplate template = null;
if (getUpgradeManager().isFuzzyUpgrade() && outputFuzzy().nextSetBit(0) != -1) {
for (ItemIdentifierStack craftable : stack) {
DictResource dict = new DictResource(craftable, null);
dict.loadFromBitSet(outputFuzzy().copyValue());
if (toCraft.matches(dict, IResource.MatchSettings.NORMAL)) {
template = new DictCraftingTemplate(dict, this, priority.getValue());
break;
}
}
} else {
for (ItemIdentifierStack craftable : stack) {
if (toCraft.matches(craftable.getItem(), IResource.MatchSettings.NORMAL)) {
template = new ItemCraftingTemplate(craftable, this, priority.getValue());
break;
}
}
}
if (template == null) {
return null;
}
IRequestItems[] target = new IRequestItems[9];
for (int i = 0; i < 9; i++) {
target[i] = this;
}
if (!isSatelliteConnected()) {
// has a satellite configured and that one is unreachable
return null;
}
if (!getUpgradeManager().isAdvancedSatelliteCrafter()) {
IRouter r = getSatelliteRouter(-1);
if (r != null) {
IRequestItems sat = r.getPipe();
for (int i = 6; i < 9; i++) {
target[i] = sat;
}
}
} else {
for (int i = 0; i < 9; i++) {
IRouter r = getSatelliteRouter(i);
if (r != null) {
target[i] = r.getPipe();
}
}
}
// Check all materials
for (int i = 0; i < 9; i++) {
ItemIdentifierStack resourceStack = dummyInventory.getIDStackInSlot(i);
if (resourceStack == null || resourceStack.getStackSize() == 0) {
continue;
}
IResource req;
if (getUpgradeManager().isFuzzyUpgrade() && inputFuzzy(i).nextSetBit(0) != -1) {
DictResource dict;
req = dict = new DictResource(resourceStack, target[i]);
dict.loadFromBitSet(inputFuzzy(i).copyValue());
} else {
req = new ItemResource(resourceStack, target[i]);
}
template.addRequirement(req, new CraftingChassisInformation(i, getPositionInt()));
}
int liquidCrafter = getUpgradeManager().getFluidCrafter();
IRequestFluid[] liquidTarget = new IRequestFluid[liquidCrafter];
if (!getUpgradeManager().isAdvancedSatelliteCrafter()) {
IRouter r = getFluidSatelliteRouter(-1);
if (r != null) {
IRequestFluid sat = (IRequestFluid) r.getPipe();
for (int i = 0; i < liquidCrafter; i++) {
liquidTarget[i] = sat;
}
}
} else {
for (int i = 0; i < liquidCrafter; i++) {
IRouter r = getFluidSatelliteRouter(i);
if (r != null) {
liquidTarget[i] = (IRequestFluid) r.getPipe();
}
}
}
for (int i = 0; i < liquidCrafter; i++) {
FluidIdentifier liquid = getFluidMaterial(i);
int amount = liquidAmounts.get(i);
if (liquid == null || amount <= 0 || liquidTarget[i] == null) {
continue;
}
template.addRequirement(new FluidResource(liquid, amount, liquidTarget[i]), null);
}
if (getUpgradeManager().hasByproductExtractor() && getByproductItem() != null) {
template.addByproduct(getByproductItem());
}
return template;
}
use of logisticspipes.interfaces.routing.IRequestFluid in project LogisticsPipes by RS485.
the class SubmitFluidRequestPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(getDimension(), getPosX(), getPosY(), getPosZ(), player);
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe) || !(pipe.pipe instanceof IRequestFluid)) {
return;
}
RequestHandler.requestFluid(player, getStack(), (CoreRoutedPipe) pipe.pipe, (IRequestFluid) pipe.pipe);
}
Aggregations