mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
parent
3632c619ec
commit
f9d72a3b87
2 changed files with 18 additions and 21 deletions
|
@ -122,7 +122,7 @@ public class ItemFilter extends ItemStackHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ItemFilter> getAllFilters() {
|
public List<ItemFilter> getAllFilters() {
|
||||||
List<ItemFilter> filters = this.pipe.streamModules()
|
List<ItemFilter> filters = this.pipe.streamModules()
|
||||||
.filter(p -> p.getRight() instanceof FilterIncreaseModuleItem)
|
.filter(p -> p.getRight() instanceof FilterIncreaseModuleItem)
|
||||||
.map(p -> new ItemFilter(18, p.getLeft(), this.pipe))
|
.map(p -> new ItemFilter(18, p.getLeft(), this.pipe))
|
||||||
|
|
|
@ -6,8 +6,6 @@ import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||||
import de.ellpeck.prettypipes.misc.ItemEqualityType;
|
import de.ellpeck.prettypipes.misc.ItemEqualityType;
|
||||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||||
import de.ellpeck.prettypipes.network.NetworkLocation;
|
|
||||||
import de.ellpeck.prettypipes.network.PipeItem;
|
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
|
@ -15,11 +13,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RetrievalModuleItem extends ModuleItem {
|
public class RetrievalModuleItem extends ModuleItem {
|
||||||
private final int maxExtraction;
|
private final int maxExtraction;
|
||||||
private final int speed;
|
private final int speed;
|
||||||
|
@ -45,21 +40,23 @@ public class RetrievalModuleItem extends ModuleItem {
|
||||||
ItemFilter filter = new ItemFilter(this.filterSlots, module, tile);
|
ItemFilter filter = new ItemFilter(this.filterSlots, module, tile);
|
||||||
ItemEqualityType[] equalityTypes = ItemFilter.getEqualityTypes(tile);
|
ItemEqualityType[] equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||||
filter.isWhitelist = true;
|
filter.isWhitelist = true;
|
||||||
// loop through filter to see which items to pull
|
// loop through filters to see which items to pull
|
||||||
for (int f = 0; f < filter.getSlots(); f++) {
|
for (ItemFilter subFilter : filter.getAllFilters()) {
|
||||||
ItemStack filtered = filter.getStackInSlot(f);
|
for (int f = 0; f < subFilter.getSlots(); f++) {
|
||||||
if (filtered.isEmpty())
|
ItemStack filtered = subFilter.getStackInSlot(f);
|
||||||
continue;
|
if (filtered.isEmpty())
|
||||||
ItemStack copy = filtered.copy();
|
continue;
|
||||||
copy.setCount(this.maxExtraction);
|
ItemStack copy = filtered.copy();
|
||||||
Pair<BlockPos, ItemStack> dest = tile.getAvailableDestination(copy, true, this.preventOversending);
|
copy.setCount(this.maxExtraction);
|
||||||
if (dest == null)
|
Pair<BlockPos, ItemStack> dest = tile.getAvailableDestination(copy, true, this.preventOversending);
|
||||||
continue;
|
if (dest == null)
|
||||||
ItemStack remain = dest.getRight().copy();
|
continue;
|
||||||
// are we already waiting for crafting results? If so, don't request those again
|
ItemStack remain = dest.getRight().copy();
|
||||||
remain.shrink(network.getCurrentlyCraftingAmount(tile.getPos(), copy, equalityTypes));
|
// are we already waiting for crafting results? If so, don't request those again
|
||||||
if (network.requestItem(tile.getPos(), dest.getLeft(), remain, equalityTypes).isEmpty())
|
remain.shrink(network.getCurrentlyCraftingAmount(tile.getPos(), copy, equalityTypes));
|
||||||
break;
|
if (network.requestItem(tile.getPos(), dest.getLeft(), remain, equalityTypes).isEmpty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue