mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-29 11:59:17 +00:00
Fix jade issue
This commit is contained in:
@@ -73,7 +73,7 @@ public class ItemCollector<T> {
|
||||
items.addTo(def, stack.getCount());
|
||||
}
|
||||
});
|
||||
iterator.afterPopulate(count.get());
|
||||
iterator.afterPopulate(container, count.get());
|
||||
if (mergedResult != null && !iterator.isFinished()) {
|
||||
updateCollectingProgress(mergedResult.getFirst());
|
||||
return mergedResult;
|
||||
|
||||
@@ -15,6 +15,7 @@ public abstract class ItemIterator<T> {
|
||||
protected final int fromIndex;
|
||||
protected boolean finished;
|
||||
protected int currentIndex;
|
||||
protected float progress;
|
||||
|
||||
protected ItemIterator(Function<Object, @Nullable T> containerFinder, int fromIndex) {
|
||||
this.containerFinder = containerFinder;
|
||||
@@ -35,16 +36,19 @@ public abstract class ItemIterator<T> {
|
||||
|
||||
public abstract Stream<ItemStack> populate(T container);
|
||||
|
||||
protected abstract int getSlotCount(T container);
|
||||
|
||||
public void reset() {
|
||||
currentIndex = fromIndex;
|
||||
finished = false;
|
||||
}
|
||||
|
||||
public void afterPopulate(int count) {
|
||||
public void afterPopulate(T container, int count) {
|
||||
currentIndex += count;
|
||||
if (count == 0 || currentIndex >= 10000) {
|
||||
finished = true;
|
||||
}
|
||||
progress = (float) (currentIndex - fromIndex) / (getSlotCount(container) - fromIndex);
|
||||
}
|
||||
|
||||
public float getCollectingProgress() {
|
||||
@@ -52,14 +56,11 @@ public abstract class ItemIterator<T> {
|
||||
}
|
||||
|
||||
public static abstract class SlottedItemIterator<T> extends ItemIterator<T> {
|
||||
protected float progress;
|
||||
|
||||
public SlottedItemIterator(Function<Object, @Nullable T> containerFinder, int fromIndex) {
|
||||
super(containerFinder, fromIndex);
|
||||
}
|
||||
|
||||
protected abstract int getSlotCount(T container);
|
||||
|
||||
protected abstract ItemStack getItemInSlot(T container, int slot);
|
||||
|
||||
@Override
|
||||
@@ -70,7 +71,6 @@ public abstract class ItemIterator<T> {
|
||||
toIndex = slotCount;
|
||||
finished = true;
|
||||
}
|
||||
progress = (float) (currentIndex - fromIndex) / (slotCount - fromIndex);
|
||||
return IntStream.range(currentIndex, toIndex).mapToObj(slot -> getItemInSlot(container, slot));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user