Search in sources :

Example 11 with SimplePredicate

use of com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate in project Multiblocked by Low-Drag-MC.

the class TraceabilityPredicate method setMinGlobalLimited.

/**
 * Set the minimum number of candidate blocks.
 */
public TraceabilityPredicate setMinGlobalLimited(int min) {
    limited.addAll(common);
    common.clear();
    for (SimplePredicate predicate : limited) {
        predicate.minCount = min;
    }
    return this;
}
Also used : SimplePredicate(com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate)

Example 12 with SimplePredicate

use of com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate in project Multiblocked by Low-Drag-MC.

the class TraceabilityPredicate method test.

public boolean test(MultiblockState blockWorldState) {
    blockWorldState.io = IO.BOTH;
    boolean flag = false;
    for (SimplePredicate predicate : limited) {
        if (predicate.testLimited(blockWorldState)) {
            flag = true;
        }
    }
    return flag || common.stream().anyMatch(predicate -> predicate.test(blockWorldState));
}
Also used : BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) Arrays(java.util.Arrays) List(java.util.List) Predicate(java.util.function.Predicate) SimplePredicate(com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate) IO(com.lowdragmc.multiblocked.api.capability.IO) Comparator(java.util.Comparator) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) SimplePredicate(com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate)

Example 13 with SimplePredicate

use of com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate in project Multiblocked by Low-Drag-MC.

the class PatternError method getCandidates.

public List<List<ItemStack>> getCandidates() {
    TraceabilityPredicate predicate = worldState.predicate;
    List<List<ItemStack>> candidates = new ArrayList<>();
    for (SimplePredicate common : predicate.common) {
        candidates.add(common.getCandidates());
    }
    for (SimplePredicate limited : predicate.limited) {
        candidates.add(limited.getCandidates());
    }
    return candidates;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TraceabilityPredicate(com.lowdragmc.multiblocked.api.pattern.TraceabilityPredicate) SimplePredicate(com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate)

Aggregations

SimplePredicate (com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate)13 BlockPos (net.minecraft.util.math.BlockPos)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 List (java.util.List)6 Set (java.util.Set)6 BlockInfo (com.lowdragmc.lowdraglib.utils.BlockInfo)5 TrackedDummyWorld (com.lowdragmc.lowdraglib.utils.TrackedDummyWorld)4 ControllerTileEntity (com.lowdragmc.multiblocked.api.tile.ControllerTileEntity)4 HashMap (java.util.HashMap)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)3 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)3 BlockComponent (com.lowdragmc.multiblocked.api.block.BlockComponent)3 IO (com.lowdragmc.multiblocked.api.capability.IO)3 PredicateComponent (com.lowdragmc.multiblocked.api.pattern.predicates.PredicateComponent)3 ComponentTileEntity (com.lowdragmc.multiblocked.api.tile.ComponentTileEntity)3 CycleBlockStateRenderer (com.lowdragmc.multiblocked.client.renderer.impl.CycleBlockStateRenderer)3 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)3 Map (java.util.Map)3