Minor fixes to autocrafting, fixes #1501
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
### 1.5.26
|
### 1.5.26
|
||||||
- Added Funky Locomotion integration (raoulvdberge)
|
- Added Funky Locomotion integration (raoulvdberge)
|
||||||
|
- Minor fixes to autocrafting (raoulvdberge)
|
||||||
|
|
||||||
### 1.5.25
|
### 1.5.25
|
||||||
- Fixed not being able to autocraft different Storage Drawers' wood drawers (raoulvdberge)
|
- Fixed not being able to autocraft different Storage Drawers' wood drawers (raoulvdberge)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public abstract class CraftingStep implements ICraftingStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getInputs() {
|
public List<ItemStack> getInputs() {
|
||||||
return pattern.getInputs().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
return pattern.getInputs().stream().filter(Objects::nonNull).filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class CraftingStepCraft extends CraftingStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getInputs() {
|
public List<ItemStack> getInputs() {
|
||||||
return inputs == null ? super.getInputs() : inputs.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
return inputs == null ? super.getInputs() : inputs.stream().filter(Objects::nonNull).filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(@Nonnull ItemStack stack, int size) {
|
public void add(@Nonnull ItemStack stack, int size) {
|
||||||
|
if (stack.isEmpty() || size <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
||||||
if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) {
|
if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) {
|
||||||
if ((long) otherStack.getCount() + (long) size > Integer.MAX_VALUE) {
|
if ((long) otherStack.getCount() + (long) size > Integer.MAX_VALUE) {
|
||||||
@@ -34,7 +38,7 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stacks.put(stack.getItem(), size == 0 ? stack.copy() : ItemHandlerHelper.copyStackWithSize(stack, size));
|
stacks.put(stack.getItem(), ItemHandlerHelper.copyStackWithSize(stack, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
@Override
|
@Override
|
||||||
public void add(@Nonnull ItemStack stack, int size) {
|
public void add(@Nonnull ItemStack stack, int size) {
|
||||||
underlyingList.add(stack, size);
|
underlyingList.add(stack, size);
|
||||||
|
|
||||||
ItemStack internalStack = underlyingList.get(stack);
|
ItemStack internalStack = underlyingList.get(stack);
|
||||||
|
|
||||||
if (internalStack != null && internalStack.getCount() == stack.getCount()) {
|
if (internalStack != null && internalStack.getCount() == stack.getCount()) {
|
||||||
for (int id : OreDictionary.getOreIDs(internalStack)) {
|
for (int id : OreDictionary.getOreIDs(internalStack)) {
|
||||||
stacks.put(id, internalStack);
|
stacks.put(id, internalStack);
|
||||||
@@ -49,10 +51,13 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean remove(@Nonnull ItemStack stack, int size) {
|
public boolean remove(@Nonnull ItemStack stack, int size) {
|
||||||
boolean rvalue = underlyingList.remove(stack, size);
|
boolean rvalue = underlyingList.remove(stack, size);
|
||||||
|
|
||||||
if (underlyingList.needsCleanup) {
|
if (underlyingList.needsCleanup) {
|
||||||
touchedIds.addAll(Arrays.stream(OreDictionary.getOreIDs(stack)).boxed().collect(Collectors.toList()));
|
touchedIds.addAll(Arrays.stream(OreDictionary.getOreIDs(stack)).boxed().collect(Collectors.toList()));
|
||||||
|
|
||||||
clean();
|
clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rvalue;
|
return rvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +67,12 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
// When the underlying list empties the stack the reference will become empty, thus we need to copy before hand
|
// When the underlying list empties the stack the reference will become empty, thus we need to copy before hand
|
||||||
ItemStack original = stack.copy();
|
ItemStack original = stack.copy();
|
||||||
boolean rvalue = underlyingList.trackedRemove(stack, size);
|
boolean rvalue = underlyingList.trackedRemove(stack, size);
|
||||||
|
|
||||||
if (underlyingList.needsCleanup) {
|
if (underlyingList.needsCleanup) {
|
||||||
touchedIds.addAll(Arrays.stream(OreDictionary.getOreIDs(original)).boxed().collect(Collectors.toList()));
|
touchedIds.addAll(Arrays.stream(OreDictionary.getOreIDs(original)).boxed().collect(Collectors.toList()));
|
||||||
clean();
|
clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rvalue;
|
return rvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,17 +92,23 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
public ItemStack get(@Nonnull ItemStack stack, int flags) {
|
public ItemStack get(@Nonnull ItemStack stack, int flags) {
|
||||||
// Check the underlying list but don't do oredict things for exact match
|
// Check the underlying list but don't do oredict things for exact match
|
||||||
ItemStack exact = underlyingList.get(stack, flags & ~IComparer.COMPARE_OREDICT);
|
ItemStack exact = underlyingList.get(stack, flags & ~IComparer.COMPARE_OREDICT);
|
||||||
|
|
||||||
if (exact == null) {
|
if (exact == null) {
|
||||||
if ((flags & IComparer.COMPARE_OREDICT) == IComparer.COMPARE_OREDICT) {
|
if ((flags & IComparer.COMPARE_OREDICT) == IComparer.COMPARE_OREDICT) {
|
||||||
int[] ids = OreDictionary.getOreIDs(stack);
|
int[] ids = OreDictionary.getOreIDs(stack);
|
||||||
|
|
||||||
for (int id : ids) {
|
for (int id : ids) {
|
||||||
List<ItemStack> stacks = this.stacks.get(id);
|
List<ItemStack> stacks = this.stacks.get(id);
|
||||||
|
|
||||||
if (stacks != null && !stacks.isEmpty()) {
|
if (stacks != null && !stacks.isEmpty()) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
ItemStack returnStack = stacks.get(i++);
|
ItemStack returnStack = stacks.get(i++);
|
||||||
|
|
||||||
while (returnStack.isEmpty() && i < stacks.size()) {
|
while (returnStack.isEmpty() && i < stacks.size()) {
|
||||||
returnStack = stacks.get(i++);
|
returnStack = stacks.get(i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!returnStack.isEmpty()) {
|
if (!returnStack.isEmpty()) {
|
||||||
return returnStack;
|
return returnStack;
|
||||||
}
|
}
|
||||||
@@ -103,6 +116,7 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return exact;
|
return exact;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +126,7 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
if (underlyingList.needsCleanup) {
|
if (underlyingList.needsCleanup) {
|
||||||
clean();
|
clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return underlyingList.get(hash);
|
return underlyingList.get(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +173,11 @@ public class StackListItemOredicted implements IStackList<ItemStack> {
|
|||||||
public IStackList<ItemStack> copy() {
|
public IStackList<ItemStack> copy() {
|
||||||
StackListItemOredicted newList = new StackListItemOredicted();
|
StackListItemOredicted newList = new StackListItemOredicted();
|
||||||
newList.underlyingList = (StackListItem) this.underlyingList.copy();
|
newList.underlyingList = (StackListItem) this.underlyingList.copy();
|
||||||
|
|
||||||
for (Map.Entry<Integer, ItemStack> entry : this.stacks.entries()) {
|
for (Map.Entry<Integer, ItemStack> entry : this.stacks.entries()) {
|
||||||
newList.stacks.put(entry.getKey(), entry.getValue());
|
newList.stacks.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user