use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.
the class ServerRouter method getRoutersInterestedIn.
public static BitSet getRoutersInterestedIn(IResource item) {
if (item instanceof ItemResource) {
return ServerRouter.getRoutersInterestedIn(((ItemResource) item).getItem());
} else if (item instanceof FluidResource) {
return ServerRouter.getRoutersInterestedIn(((FluidResource) item).getFluid().getItemIdentifier());
} else if (item instanceof DictResource) {
DictResource dict = (DictResource) item;
BitSet s = new BitSet(ServerRouter.getBiggestSimpleID() + 1);
if (ServerRouter._genericInterests != null) {
for (IRouter r : ServerRouter._genericInterests) {
s.set(r.getSimpleID());
}
}
ServerRouter._globalSpecificInterests.entrySet().stream().filter(entry -> dict.matches(entry.getKey(), IResource.MatchSettings.NORMAL)).forEach(entry -> {
for (IRouter r : entry.getValue()) {
s.set(r.getSimpleID());
}
});
return s;
}
return new BitSet(ServerRouter.getBiggestSimpleID() + 1);
}
use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.
the class ModuleCrafter method registerExtras.
@Override
public void registerExtras(IPromise promise) {
if (promise instanceof LogisticsDictPromise) {
_service.getItemOrderManager().addExtra(((LogisticsDictPromise) promise).getResource());
return;
} else {
ItemIdentifierStack stack = new ItemIdentifierStack(promise.getItemType(), promise.getAmount());
_service.getItemOrderManager().addExtra(new DictResource(stack, null));
}
}
use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.
the class ModuleCrafter method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
// super.readFromNBT(nbttagcompound);
_dummyInventory.readFromNBT(nbttagcompound, "");
_liquidInventory.readFromNBT(nbttagcompound, "FluidInv");
_cleanupInventory.readFromNBT(nbttagcompound, "CleanupInv");
satelliteId = nbttagcompound.getInteger("satelliteid");
priority = nbttagcompound.getInteger("priority");
for (int i = 0; i < 9; i++) {
advancedSatelliteIdArray[i] = nbttagcompound.getInteger("advancedSatelliteId" + i);
}
if (nbttagcompound.hasKey("fuzzyCraftingFlag0")) {
for (int i = 0; i < 9; i++) {
int flags = nbttagcompound.getByte("fuzzyCraftingFlag" + i);
DictResource dict = fuzzyCraftingFlagArray[i];
if ((flags & 0x1) != 0) {
dict.use_od = true;
}
if ((flags & 0x2) != 0) {
dict.ignore_dmg = true;
}
if ((flags & 0x4) != 0) {
dict.ignore_nbt = true;
}
if ((flags & 0x8) != 0) {
dict.use_category = true;
}
}
}
if (nbttagcompound.hasKey("fuzzyFlags")) {
NBTTagList lst = nbttagcompound.getTagList("fuzzyFlags", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < 9; i++) {
NBTTagCompound comp = lst.getCompoundTagAt(i);
fuzzyCraftingFlagArray[i].ignore_dmg = comp.getBoolean("ignore_dmg");
fuzzyCraftingFlagArray[i].ignore_nbt = comp.getBoolean("ignore_nbt");
fuzzyCraftingFlagArray[i].use_od = comp.getBoolean("use_od");
fuzzyCraftingFlagArray[i].use_category = comp.getBoolean("use_category");
}
}
if (nbttagcompound.hasKey("outputFuzzyFlags")) {
NBTTagCompound comp = nbttagcompound.getCompoundTag("outputFuzzyFlags");
outputFuzzyFlags.ignore_dmg = comp.getBoolean("ignore_dmg");
outputFuzzyFlags.ignore_nbt = comp.getBoolean("ignore_nbt");
outputFuzzyFlags.use_od = comp.getBoolean("use_od");
outputFuzzyFlags.use_category = comp.getBoolean("use_category");
}
for (int i = 0; i < 6; i++) {
craftingSigns[i] = nbttagcompound.getBoolean("craftingSigns" + i);
}
if (nbttagcompound.hasKey("FluidAmount")) {
amount = nbttagcompound.getIntArray("FluidAmount");
}
if (amount.length < ItemUpgrade.MAX_LIQUID_CRAFTER) {
amount = new int[ItemUpgrade.MAX_LIQUID_CRAFTER];
}
for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
liquidSatelliteIdArray[i] = nbttagcompound.getInteger("liquidSatelliteIdArray" + i);
}
for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
liquidSatelliteIdArray[i] = nbttagcompound.getInteger("liquidSatelliteIdArray" + i);
}
liquidSatelliteId = nbttagcompound.getInteger("liquidSatelliteId");
cleanupModeIsExclude = nbttagcompound.getBoolean("cleanupModeIsExclude");
}
use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.
the class ModuleCrafter method canProvide.
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
if (!_service.getItemOrderManager().hasExtras() || tree.hasBeenQueried(_service.getItemOrderManager())) {
return;
}
IResource requestedItem = tree.getRequestType();
if (!canCraft(requestedItem)) {
return;
}
for (IFilter filter : filters) {
if (filter.isBlocked() == filter.isFilteredItem(requestedItem) || filter.blockProvider()) {
return;
}
}
int remaining = 0;
for (LogisticsItemOrder extra : _service.getItemOrderManager()) {
if (extra.getType() == ResourceType.EXTRA) {
if (extra.getResource().getItem().equals(requestedItem)) {
remaining += extra.getResource().stack.getStackSize();
}
}
}
remaining -= root.getAllPromissesFor(this, getCraftedItem().getItem());
if (remaining < 1) {
return;
}
if (this.getUpgradeManager().isFuzzyUpgrade() && outputFuzzyFlags.getBitSet().nextSetBit(0) != -1) {
DictResource dict = new DictResource(getCraftedItem(), null).loadFromBitSet(outputFuzzyFlags.getBitSet());
LogisticsExtraDictPromise promise = new LogisticsExtraDictPromise(dict, Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
} else {
LogisticsExtraPromise promise = new LogisticsExtraPromise(getCraftedItem().getItem(), Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
}
tree.setQueried(_service.getItemOrderManager());
}
use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.
the class PipeItemsProviderLogistics method canProvide.
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
if (!isEnabled()) {
return;
}
if (tree.getRequestType() instanceof ItemResource) {
ItemIdentifier item = ((ItemResource) tree.getRequestType()).getItem();
for (IFilter filter : filters) {
if (filter.isBlocked() == filter.isFilteredItem(item.getUndamaged()) || filter.blockProvider()) {
return;
}
}
// Check the transaction and see if we have helped already
int canProvide = getAvailableItemCount(item);
canProvide -= root.getAllPromissesFor(this, item);
if (canProvide < 1) {
return;
}
LogisticsPromise promise = new LogisticsPromise(item, Math.min(canProvide, tree.getMissingAmount()), this, ResourceType.PROVIDER);
tree.addPromise(promise);
} else if (tree.getRequestType() instanceof DictResource) {
DictResource dict = (DictResource) tree.getRequestType();
HashMap<ItemIdentifier, Integer> available = new HashMap<>();
getAllItems(available, filters);
for (Entry<ItemIdentifier, Integer> item : available.entrySet()) {
if (!dict.matches(item.getKey(), IResource.MatchSettings.NORMAL)) {
continue;
}
int canProvide = getAvailableItemCount(item.getKey());
canProvide -= root.getAllPromissesFor(this, item.getKey());
if (canProvide < 1) {
continue;
}
LogisticsPromise promise = new LogisticsPromise(item.getKey(), Math.min(canProvide, tree.getMissingAmount()), this, ResourceType.PROVIDER);
tree.addPromise(promise);
if (tree.getMissingAmount() <= 0) {
break;
}
}
}
}
Aggregations