Search in sources :

Example 1 with BlueprintPositionInfo

use of com.ldtteam.structurize.util.BlueprintPositionInfo in project Structurize by ldtteam.

the class AbstractBlueprintIterator method iterateWithCondition.

/**
 * Execute a supplier function to avoid duplicate code for increment and decrement functions.
 * @param skipCondition the skipCondition.
 * @param function the supplier function.
 * @return the Result.
 */
private Result iterateWithCondition(final TriPredicate<BlueprintPositionInfo, BlockPos, IStructureHandler> skipCondition, final Supplier<Result> function) {
    int count = 0;
    do {
        if (function.get() == Result.AT_END) {
            return Result.AT_END;
        }
        final BlockPos worldPos = structureHandler.getProgressPosInWorld(progressPos);
        final BlueprintPositionInfo info = getBluePrintPositionInfo(progressPos);
        if (skipCondition.test(info, worldPos, structureHandler)) {
            continue;
        } else if (!isRemoving && BlockUtils.areBlockStatesEqual(info.getBlockInfo().getState(), structureHandler.getWorld().getBlockState(worldPos), structureHandler::replaceWithSolidBlock, structureHandler.fancyPlacement(), structureHandler::shouldBlocksBeConsideredEqual) && info.getEntities().length == 0) {
            structureHandler.triggerSuccess(progressPos, Collections.emptyList(), false);
            continue;
        }
        return Result.NEW_BLOCK;
    } while (count++ < structureHandler.getMaxBlocksCheckedPerCall());
    return Result.CONFIG_LIMIT;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlueprintPositionInfo(com.ldtteam.structurize.util.BlueprintPositionInfo)

Aggregations

BlueprintPositionInfo (com.ldtteam.structurize.util.BlueprintPositionInfo)1 BlockPos (net.minecraft.util.math.BlockPos)1