parent
0b182ae608
commit
b8563aa703
2 changed files with 37 additions and 8 deletions
|
@ -84,12 +84,25 @@ public class LogisticsPipes implements ILogisticsPipes, IIntegrationModule {
|
|||
Map<IAEItemStack, IAEItemStack> stacks = new HashMap<>();
|
||||
for(ItemStack s : api.getProvidedItems()) {
|
||||
IAEItemStack stack = AEItemStack.create(s);
|
||||
int stacksize = s.stackSize;
|
||||
stack.reset();
|
||||
stack.setCountRequestable(stacksize);
|
||||
if (stacks.containsKey(stack)) {
|
||||
stacks.get(stack).incStackSize(stack.getStackSize());
|
||||
stacks.get(stack).incCountRequestable(stack.getCountRequestable());
|
||||
} else {
|
||||
stacks.put(stack, stack);
|
||||
}
|
||||
}
|
||||
for(ItemStack s : api.getCraftedItems()) {
|
||||
IAEItemStack stack = AEItemStack.create(s);
|
||||
stack.reset();
|
||||
if (stacks.containsKey(stack)) {
|
||||
stacks.get(stack).setCraftable(true);
|
||||
} else {
|
||||
stack.setCraftable(true);
|
||||
stacks.put(stack, stack);
|
||||
}
|
||||
}
|
||||
return stacks.keySet();
|
||||
}
|
||||
return new HashSet<>();
|
||||
|
@ -104,15 +117,21 @@ public class LogisticsPipes implements ILogisticsPipes, IIntegrationModule {
|
|||
if (res.missing.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return AEItemStack.create(res.missing.get(0));
|
||||
ItemStack m = res.missing.get(0);
|
||||
if (request.equals(m)) {
|
||||
return AEItemStack.create(res.missing.get(0));
|
||||
} else {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<ItemStack> returned = api.performRequest(request.getItemStack());
|
||||
if (returned.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
int missing = returned.get(0).stackSize;
|
||||
if (missing > 0) {
|
||||
ItemStack m = returned.get(0);
|
||||
int missing = m.stackSize;
|
||||
if (missing > 0 && request.equals(m)) {
|
||||
IAEItemStack newRequest = request.copy();
|
||||
newRequest.decStackSize(missing);
|
||||
// LP should still request the items, which are available
|
||||
|
|
|
@ -93,9 +93,12 @@ public class RequestGridCache
|
|||
if (requestable.containsKey(stack)) {
|
||||
Requestable r = requestable.get(stack);
|
||||
r.addProvider(provider);
|
||||
r.increaseAmount(stack.getStackSize());
|
||||
r.increaseAmount(stack.getCountRequestable());
|
||||
if (stack.isCraftable()) {
|
||||
r.setCraftable();
|
||||
}
|
||||
} else {
|
||||
Requestable r = new Requestable(stack.getStackSize());
|
||||
Requestable r = new Requestable(stack);
|
||||
r.addProvider(provider);
|
||||
requestable.put(stack, r);
|
||||
}
|
||||
|
@ -151,6 +154,7 @@ public class RequestGridCache
|
|||
stack.reset();
|
||||
Requestable r = requestable.get(s);
|
||||
stack.setCountRequestable(r.amount);
|
||||
stack.setCraftable(r.craftable);
|
||||
out.add(stack);
|
||||
}
|
||||
return out;
|
||||
|
@ -212,10 +216,12 @@ public class RequestGridCache
|
|||
static class Requestable {
|
||||
public Set<IRequestProvider> providers;
|
||||
public long amount;
|
||||
public boolean craftable;
|
||||
|
||||
public Requestable(long amount) {
|
||||
public Requestable(IAEItemStack stack) {
|
||||
this.providers = new HashSet<>();
|
||||
this.amount = amount;
|
||||
this.amount = stack.getCountRequestable();
|
||||
this.craftable = stack.isCraftable();
|
||||
}
|
||||
|
||||
public void addProvider(IRequestProvider provider) {
|
||||
|
@ -225,5 +231,9 @@ public class RequestGridCache
|
|||
public void increaseAmount(long amount) {
|
||||
this.amount += amount;
|
||||
}
|
||||
|
||||
public void setCraftable() {
|
||||
this.craftable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue